[BACK]Return to taylor CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-contrib / packages / sample

Annotation of OpenXM/src/asir-contrib/packages/sample/taylor, Revision 1.2

1.1       tam         1: def taylor(F,X,P,N){
                      2:        R = 0;
                      3:        A = F;
                      4:
                      5:        for(I=0;I<N;I++){
                      6:                R += subst(A,X,P) * x^I;
1.2     ! tam         7:                A = diff(A,X)/(I+1);
1.1       tam         8:        }
                      9:        return R;
                     10: }
                     11:
1.2     ! tam        12: def taylor_test(){
        !            13:        print(taylor(exp(z),z,0,10));
        !            14:        print(taylor(sin(z),z,0,10));
        !            15:        print(taylor(cos(z),z,0,10));
        !            16:        print(taylor(cos(z),z,1,10));
        !            17:        print(taylor(1/(1-z),z,0,10));
        !            18:        print(taylor((1-z)^(1/2),z,0,10));
        !            19:        print(taylor((1-z)^(1/2),z,2,10));
        !            20: }
        !            21:
        !            22: /* taylor_test(); */
1.1       tam        23: quit;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>