> ?series -------------------------------------------------------------------------------- > series(BesselJ(0,x),x=0); -------------------------------------------------------------------------------- > Order:=12; -------------------------------------------------------------------------------- > series(BesselJ(0,x),x=0); -------------------------------------------------------------------------------- > series(sin(x),x=0); -------------------------------------------------------------------------------- > sinx:=convert(",polynom); -------------------------------------------------------------------------------- > diff(sinx,x); -------------------------------------------------------------------------------- > series(cos(x),x=0); -------------------------------------------------------------------------------- > diff(sinx,x$2); -------------------------------------------------------------------------------- # Observe that this is equal to the negative of the truncated series for sin(x) originally, except # with the last term missing. # Series solutions have some seriesous limitations. [Boo!] # The worst limitation is the limited range of useful validity. The theoretical concept of radius of # convergence tells us that in many cases, the series is only convergent (the sum comes to a # sensible total) only when x is in a certain interval. # > series(log(x),x=1); -------------------------------------------------------------------------------- > logx:=convert(",polynom); -------------------------------------------------------------------------------- > logg:=unapply(evalf(logx),x); -------------------------------------------------------------------------------- > logg(1.2); -------------------------------------------------------------------------------- > log(1.2); -------------------------------------------------------------------------------- > plot({log(x),logg(x)},x=0.8..1.2); -------------------------------------------------------------------------------- > plot({log(x),logg(x)},x=0.4..1.6); -------------------------------------------------------------------------------- # Not bad! But watch what happens when we push our luck! > plot({log(x),logg(x)},x=0.2..2.2); -------------------------------------------------------------------------------- # It may seem as though extra terms are needed. > Order:=100;logo:=convert(series(log(x),x=1),polynom):logxx:=unapply(evalf(logo),x): -------------------------------------------------------------------------------- > logxx(1.2); -------------------------------------------------------------------------------- > log(1.2); -------------------------------------------------------------------------------- # Now the error has been pushed back into the less significant digits. Yes! More terms IS a # panacea. # But wait. Is this not hasty? Let's look a bit further afield. > plot({log(x),logxx(x)},x=0.01..2.07); -------------------------------------------------------------------------------- # The radius of convergence of this series is 1. No matter how many terms we take, the series # will never converge when x>2 or x<0. > sine:=series(sin(x),x=0); -------------------------------------------------------------------------------- # That's another problem with series...compared to closed form solutions, they're data hogs. But # let's see what we really have here. > sinex:=convert(sine,polynom):sinewv:=unapply(evalf(sinex),x): -------------------------------------------------------------------------------- > plot(sinewv(x),x=-10..10); -------------------------------------------------------------------------------- # Looks good. The radius of convergence of the series for sine x is infinite. > plot(sinewv(x),x=10..20); -------------------------------------------------------------------------------- > plot(sinewv(x),x=15..25); -------------------------------------------------------------------------------- > plot(sinewv(x),x=20..27); -------------------------------------------------------------------------------- # Yes folks. Even with so many terms, the series provides a reasonable approximation only out to # about + or - 20. # Now if series gives such poor answers, why bother? Well, # (1) They're quite good on that limited interval where they're any good at all. # (2) Compared to closed-form solutions, they're data hogs, but compared to simple # interpolation schemes they are better if high accuracy is required. # (3) It's a lot easier to do further calculus with a series solution than with even a closed-form # solution. For instance, how would you integrate sin(x^2)/x? # Well, the series expansion of sin(x^2)/x can be got without need of Maple: sin(z)=z- # z^3/3!+z^5/5!..., so sin(x^2)=x^2-x^6/3!+x^(10)/5!... and so sin(x^2)/x=x- # x^5/3!+x^9/5! - ... . > expn:=int(sinewv(x^2)/x,x=0..t): -------------------------------------------------------------------------------- > plot(expn,t=0..10); -------------------------------------------------------------------------------- > subs(t=1.,expn); -------------------------------------------------------------------------------- > subs(t=0.,expn); -------------------------------------------------------------------------------- > fn:=unapply(evalf(expn),t): -------------------------------------------------------------------------------- > plot(fn(t),t=0.01..4.5); -------------------------------------------------------------------------------- # We have to be careful though, as the approximation breaks down when x^2 exceeds about 20. > plot(int(sin(x^2)/x,x=0..t),t=0..4.5); -------------------------------------------------------------------------------- # The connection between this and DE comes when we treat a DE as a series equation. For instance, # consider y''=-xy. This is the DE governing a mass bobbing back and forth on an ever-stronger # spring. What will happen? > springer:=dsolve({diff(y(x),x$2)=-x*y(x),y(0)=1,D(y)(0)=0},y(x),series); -------------------------------------------------------------------------------- > springr:=map(evalf,convert(rhs(springer),polynom)); -------------------------------------------------------------------------------- > plot(springr,x=0..10); -------------------------------------------------------------------------------- # Well, it's been fun, but now we have to put in some work and learn how this black box works. # Where do all these coefficients come from etc? >