Separable Differential Equations
Separable Differential Equations
This is a Sage worksheet. It consists of "cells". Each "cell" contains several commands.
To "execute" a cell, i.e. to execute the commands of a cell, press Shift+Enter.
You can use this worksheet to:
1) Solve differential equations
2) Use an initial condition
3) Draw the direction field
4) Draw the integral curves
Example:
Consider the differential equation:
dy/dx= 2x/(y+x^2*y) which can written as dy/dy- 2x/(y+x^2*y)=0
The next cell uses the command desolve to solve a differential equation.
The quantity diff(y,x)- 2*x/(y+x^2*y) is the left-side of the equation dy/dx- 2*x/(y+x^2*y)=0.
Notes:
(1) diff(y,x) stands for the derivative of y with respect to x.
(2) Sage will understand 2*x, but will give an error for 2x
(3) Sage can not solve ALL differential equations.
The output of the cell is the implicit solution of the differential equation.
Observe that the implicit solution contains the constant c.
The initial condition is given by the command ics=[0,-2].
The output of the cell is the implicit solution of the differential equation, but this time, there is no c involved.
If you copy and paste the implicit solution from the previous cell to this cell, be careful to replace y(x) with y.
I.e. 1/4*y(x)^2 == 1/2*log(x^2 + 1) + 1 becomes 1/4*y^2 == 1/2*log(x^2 + 1) + 1.
If you do not replace y(x) by y, either you will get an error message, or the plot will be inaccurate.
The viewing window is from x=-5 to x=5 and from y=-5 to y=5. Adjust this accordingly.
From the first cell we know that the implicit solution of the diff.eq. dy/dy- 2x/(y+x^2*y)=0 equals 1/4*y^2 == c + 1/2*log(x^2 + 1).
Different values of c will give different integral curves.
The command "implicit_plot(1/4*y^2 == 1 + 1/2*log(x^2 + 1),(x,-5,5),(y,-5,5))+implicit_plot(1/4*y^2 == 2 + 1/2*log(x^2 + 1),(x,-5,5),(y,-5,5))" will generate two implicit plots, the one on top of the other.
Instead of adding many implicit plots together, we use the sum() command and we specify the values for the c.
We enter only the right-hand side 2x/(y+x^2*y), and we adjust the viewing window for our purposes
The commands for plot_slope_field and implicit_plot are the same we used before.
The commands for plot_slope_field and implicit_plot are the same we used before.