Kosinusreihe n P 2k 2n x (−1)k (2k )! , x (n ∈ N0 ) an := (−1)n (2n)! k =0 x 2n Abbruch der Summation, falls (−1)n (2n)! ≤ ε|sn | x 2n d.h. Fortsetzung der Summation, solange (−1)n (2n)! > ε|sn | sn := Rekursion: a0 = 1, s0 = 1, Pseudocode 2 x an = −an−1 2n(2n−1) (n ∈ N) sn = sn−1 + an (n ∈ N) [Formulierung in Worten] s0 = 1; a0 = 1; n = 1; while (|an−1 | > ε|sn−1 |) { x2 an = −an−1 · 2n(2n−1) ; sn = sn−1 + an ; n →n+1 } Kosinusreihe - Fortsetzung Programmfragment s = 1; a = 1; n = 1; // s: s0 , a: a0 while (abs(a)>eps*abs(s)) { // s: sn−1 , a: an−1 a = -a*x*x/(2*n*(2*n-1)); x2 = an // a: −an−1 · 2n(2n−1) s = s+a; // s: sn−1 + an = sn n = n+1; // s: sn−1 , a: an−1 }
© Copyright 2024 ExpyDoc