Tutorial Release 10.4 The Sage Development Team https://doc.sagemath.org/pdf/en/tutorial/sage_tutorial.pdf
Sage is free, open-source math software that supports research and teaching in algebra, geometry, number theory, cryptography, numerical computation, and related areas. Both the Sage development model and the technology in Sage itself are distinguished by an extremely strong emphasis on openness, community, cooperation, and collaboration: we are building the car, not reinventing the wheel. The overall goal of Sage is to create a viable, free, open-source alternative to Maple, Mathematica, Magma, and MATLAB.
This tutorial is the best way to become familiar with Sage in only a few hours. You can read it in HTML or PDF versions, or from the Sage notebook (click Help, then click Tutorial to interactively work through the tutorial from within Sage).
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.
ubuntu2204
2.4.3 Solving Differential Equations
You can use Sage to investigate ordinary differential equations. To solve the equation :
This uses Sage’s interface to Maxima [Max], and so its output may be a bit different from other Sage output. In this case, this says that the general solution to the differential equation is .
You can compute Laplace transforms also; the Laplace transform of is computed as follows:
Example: Solving Differential Equations for a Coupled Spring System
Here is a more involved example. The displacement from equilibrium for a coupled spring attached to a wall on the left
|------\/\/\/\/\------|mass1|------\/\/\/\/\/--------|mass2|
. spring1 spring2
is modeled by the system of 2nd order differential equations
where is the mass of object i, is the displacement from equilibrium of mass i, and is the spring constant for spring i.
Example: Use SageMath to solve the above problem with , , , , , , , .
Solution: Take the Laplace transform of the first equation (with the notation ):
This returns:
This is hard to read, but it says that
(where the Laplace transform of a lower case function like is the upper case function ).
Take the Laplace transform of the second equation:
This says
Plug in the initial conditions for , , , and , and solve the resulting two equations:
Now take inverse Laplace transforms to get the answer:
Therefore, the solution is
This can be plotted parametrically using:
The individual components can be plotted using:
For more on plotting, see Plotting. See section 5.5 of [NagleEtAl2004] for further information on differential equations.