352 - Topic 02 - Separable Equations

78 days ago by Professor352

Solving Separable Differential Equations

John Travis

Mississippi College

Blanchard, Devaney and Hall, 4th edition.

Enter the right-hand-side for a separable differential equation of the form

$\frac{\mathrm{dy}}{\mathrm{dt}} = f(t,y)$

with y as a function of t entered as "y(t)" instead of just plain "y".

Of course, the DE will be separable if it is possible to write $f(t,y) = g(y) h(t)$ for some functions $g$ and $h$.

var('t,k,M,m') y = function('y')(t) f = 3*y^2/t # f = 1*y*(10-y)*(y-2) F = maxima.factor(f) html('Differential Equation can be separated into\n\n<center>$dy/dx = %s$</center>'%str(latex(F))) # Enter the domain value for the initial condition t0=0 t1=2 # Enter the range value for the initial condition y0=1 sol = desolve(diff(y,t) - f, y) sol_p = desolve(diff(y,t) - f, y, ics=[t0,y0]) html('The exact general solution for this problem is given by $y(t)=%s $'%str(latex(sol))) var('y') G = plot(sol_p,(t,t0,t1)) + point2d((t0,y0),color='red',pointsize=20) show(G) 
       
#0: ic1(soln=-1/(3*y) = log(_SAGE_VAR_t)+%c,xc=_SAGE_VAR_t = 0,yc=y = 1)
Traceback (click to the left of this block for traceback)
...
TypeError: ECL says: Error executing code in Maxima: log: encountered
log(0).
#0: ic1(soln=-1/(3*y) = log(_SAGE_VAR_t)+%c,xc=_SAGE_VAR_t = 0,yc=y = 1)
Traceback (most recent call last):    F = maxima.factor(f)
  File "", line 1, in <module>
    
  File "/tmp/tmptebzU_/___code___.py", line 20, in <module>
    sol_p = desolve(diff(y,t) - f, y, ics=[t0,y0])
  File "/home/sageserver/sage-8.7/local/lib/python2.7/site-packages/sage/calculus/desolvers.py", line 614, in desolve
    soln=P(cmd)
  File "/home/sageserver/sage-8.7/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 288, in __call__
    return cls(self, x, name=name)
  File "/home/sageserver/sage-8.7/local/lib/python2.7/site-packages/sage/interfaces/interface.py", line 703, in __init__
    raise TypeError(x)
TypeError: ECL says: Error executing code in Maxima: log: encountered log(0).
# You might need to remember to use partial factions on some separable differential equations. Sage is your friend. var('x,y,M') pretty_print("----sometimes you have all linear factors----") f = 1/(x*(M-x)) f.show() f.partial_fraction(x).show() pretty_print("----and then sometimes you have irreducible quadratic factors----") f = (5*x-7)/(x*(6-x)*(x^2+7)) f.show() f.partial_fraction(x).show() pretty_print("----and then sometimes you have repeated factors----") f = (5*x-7)/(x*(6-x)^3*(x^2+7)^2) f.show() f.partial_fraction(x).show()