First Order Equations
Solutions ToWeb Site Examples
Here is some Maple code to solve web site Exam I example 10 and graph the solution.
Example 10
First solve for x between 0 and 3.
| > | ode1:=diff(y(x),x)=-2*y(x)+1; |
| > | dsolve(ode1,{y(x)}); |
| > | dsolve({ode1,y(0)=0},{y(x)}); |
| > | f:=rhs(%); |
Now solve for x greater than 3 with the necessary value for y(3) to give continuity at x = 3.
| > | ode2:=diff(y(x),x)=-2*y(x); |
| > | dsolve({ode2,y(3)=1/2-exp(-6)/2},{y(x)}); |
| > | g:=rhs(%); |
Graph the solution.
| > | h:=x->piecewise(x<=3,f,g); |
| > | with(plots): |
Warning, the name changecoords has been redefined
| > | plot(h(x),x=0..6,y=0..0.6); |
Here is another way of defining the solution function.
| > | q(x):=piecewise(x<=3,f,g); |
| > | plot(q(x),x=0..6,y=0..0.6); |
| > |