1/* Filename <name>.mac 2 3 *************************************************************** 4 * * 5 * <package name> * 6 * <functionality description> * 7 * * 8 * from: Computer Algebra in Applied Math. * 9 * by Rand (Pitman,1984) * 10 * Programmed by Richard Rand * 11 * These files are released to the public domain * 12 * * 13 *************************************************************** 14*/ /* 15 16(d5) This program generates the Taylor series solution 17 18 19to the 1st order ODE: 20 21 22 Y' = F(X,Y) 23 24 25for an arbitrary initial condition at X = 0. 26 27 28To call it, type: 29 30 31 SOLUTION() 32 33*/ 34 35 36solution():=(input(),u:z,v:f, 37 for i thru m do (u:u+evaluate(v)*x^i/i!,v:deriv(v)),output())$ 38input():=(m:read("ENTER DEGREE OF TRUNCATION"), 39 f:read("ENTER RIGHT HAND SIDE OF ODE Y'=F(X,Y)"),print(" "), 40 print("Y' =",f),print(" "),z:read("ENTER INITIAL VALUE OF Y"))$ 41deriv(g):=diff(g,x)+diff(g,y)*f$ 42evaluate(g):=ev(g,x:0,y:z)$ 43output():=print("Y =",u)$ 44