/************************************************************* * Approximating a function F(x) By Maclaurin's Series * * ---------------------------------------------------------- * * This is the general Maclaurin's formula: * * * * f'(0) f"(0) f"'(0) fn-1(0) * * f(x) = f(0) + ---- + ---- + ----- + ... + ------- + ... * * 1! 2! 3! (n-1)! * * * * In the case of sin(x) between x=0 and x=2*PI, the formula * * becomes: * * * * sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! ... * * * * This small program shows that with 9 terms, we have a fair * * approximation of sin(x) between 0 and 2*PI. * * * * With option 2, you can approximate exp(x). * * ---------------------------------------------------------- * * REFERENCE: * * "Graphisme dans le plan et dans l'espace avec Turbo * * Pascal 4.0 By R. Dony - MASSON, Paris 1990". * * * * C++ Version in API style By J-P Moreau, Paris. * *************************************************************/ //Import with associated file. //Link with Gr2d.cpp. #include #include #include #include HDC hdc; RECT rect; HPEN hpen, hpenOld; //Functions used here of module Gr2D.cpp void Fenetre(double,double,double,double); void Cloture(int,int,int,int); void Axes(); void Bordure(); void Gradue(double,double); void Grille(double,double); void MoveXY(double,double); void LineXY(double,double); //"home made" graphic commands for hdc environment used by above functions void DrawPixel(int ix,int iy) { //sorry, no other available command found Rectangle(hdc,rect.left+ix,rect.top+iy, rect.left+ix+2,rect.top+iy+1); } void Swap(int *i1,int *i2) { int it; it=*i1; *i1=*i2; *i2=it; } void DrawLine(int ix1,int iy1,int ix2,int iy2) { int i,il,ix,iy; float dx,dy; if (ix2