Taylor series algorithm
From aemwiki
- Language
- C++
- Purpose
- Calculates complex Taylor series: <math>\underset{n=0}{\overset{N-1}{\sum}}a_nZ^{n}</math>
- Author
- James R. Craig, Igor Jankovic
#include <math.h> #include <complex> typedef complex<double> cmplex; /*********************************************************************** Taylor Series Expansion ------------------------------------------------------------------------ Returns Taylor series expansion using Horners Rule Taylor = sum{0..N-1} a_n Z^(n) ***********************************************************************/ cmplex Taylor(const cmplex &Z, const int N,const cmplex * const &a) { static cmplex sum; if (N==0){return a[0];} sum=a[N-1]; for (int n=N-2; n>=0; n--){ sum=(sum*Z)+a[n]; } return sum; }