| > | restart; |
| > | # Set up the ODE and boundary conditions: ode := eps*diff(u(x),x,x)+(x-1/2)*diff(u(x),x)-(x-1/2)*u(x)=0; bc := {u(0)=-2, u(1)=exp(1.)}; |
| > | # The uniform asymptotic expansion is given by: unif := exp(x)*(-1/2+3/2*sqrt(2/Pi)* int(exp(-s^2/2), s=0..(x-1/2)/eps^(1/2))); |
| > | eps := 0.01; |
| > | # Solve the problem numerically: pp := dsolve({ode} union bc, numeric); |
| > | # Plot the solution and compare with the asymptotic expansion: with(plots): |
| > | odeplot(pp, [[x, u(x)], [x, unif]]); |
| > | # Save this plot for future use: pic := %: |
| > |
| > | # Try another epsilon value: |
| > | eps := 0.001; |
| > | pp := dsolve({ode} union bc, numeric); |
| > | odeplot(pp, [[x, u(x)], [x, unif]]); |
| > | display(%, pic); |
| > |
| > |