
























































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
chapter 9 maxima
Tipologia: Manuais, Projetos, Pesquisas
1 / 64
Esta página não é visível na pré-visualização
Não perca as partes importantes!

























































In this chapter we present examples of solutions to ordinary differential equations (ODes) using Maxima.
Review of ODE solution methods from the wxMaxima interface In the introduction of menu options and interface buttons for the wxMaxima interface in previous chapters, we came across some simple examples of ODE solutions including general solutions, initial value problems, and boundary value. We review them next.
Function ode2 ( Equations > Solve ODE … or [Solve ODE...] button) – General solution to ODE In Chapter 1 (Introduction to Maxima ) we introduced a simple ODE solution when illustrating the use of the [ Solve ODE...] button in the wxMaxima interface. This solution is repeated here. Press the [ Solve ODE...] button, or use the menu item “ Equations > Solve ODE ...” in the wxMaxima interface, and try the following input:
Press the [ OK ] button to obtain:
The [ Solve ODE... ] button can be used, therefore, to activate function ode2 to produce the general solution of first and second order ODEs. For example, the 2nd^ order ODE:
d^2 y dx^2
y =sin3x (^) ,
can be solved by using the input:
The result is the following:
The constant of integration in the first solution is referred to as %c , while the two constants of integration in the second example are %k1 and %k.
An attempt to find a general solution to a third-order ODE fails:
This input produces a false result:
Function ic1 - Solving an initial value, first-order ODE problem To solve an initial value, first-order ODE problem, you can use the menu item Equations > Initial value problem (1), after you have used function ode2 (see above) to produce a general solution. The procedure, thus, requires two steps as illustrated in this example.
Solve the ODE dy dx
y = x
subject to the initial condition
y(0) = 1.
First, use Equations > Solve ODE... to produce the general solution:
Function ic2 - Solving an initial value, second-order ODE problem The solution to an initial value, second-order ODE problem requires two initial conditions at the initial point, one is a value of the function, and the second one is a value of the derivative at the same initial point. To solve an initial value, second-order ODE problem in Maxima , first solve the general solution, and then use the menu option Equations > Initial Value Problem(2) , as illustrated next.
Solve the ODE d^2 y dx^2
dy dx
y = 0
subject to the initial conditions
y(0) = 1 , and
dy dx
First, select Equations > Solve ODE... and enter:
This produces:
Then, select Equations > initial Value Problem(2) and enter:
The result is now:
Function bc2 - Solving a boundary value, second-order ODE problem To solve a boundary value, second-order ODE problem it is necessary to provide values of the function at two different values of the independent variable. To obtain the solution to a boundary value, second-order ODE problem in Maxima , first obtain a general solution, and then replace the boundary values using the menu item: “ Equations > Boundary Value Problem ...”
For example, solve the ODE d^2 y dx^2
dy dx
3y= 0
subject to the boundary conditions
y(0) = 1 , and y(5) = -.
First, obtain a general solution by using the menu item Equations > Solve ODE … and enter:
Replacing initial conditions If the initial conditions are known, you can replace them into the general solution by using function subst, available, for example, through the [Subst...] button in the w xMaxima interface. However, in order to produce this substitutions you should be able to write expressions for the derivatives at x = 0. For example, to produce the result
use the command:
Thus, if you have produced a general solution such as the one shown above, you can proceed to produced the required substitutions as indicated below. First, produce the solution using the command:
Then, substitute the values of the second and first derivatives, and of the function, at x= 0, in that order:
The final result is easier to understand, showing only missing constant such as D2y0 , Dy0 , and y0 , instead of the full expressions for the derivatives.
If you have specific values for these constants, you could substitute them at once using, for example:
Using initial conditions with the atvalue function If you want to solve an ODE using Laplace transforms, and provide the initial conditions from the start, rather than substituting them after obtaining the solution, you can load those initial conditions using function atvalue. This function can be obtained by using the menu item Equations > At Value …
Consider the solution to the second order equation:
d^2 y dx^2
dy dx
5y= 0
Additional examples of first-order, initial value ODE solutions ()* This section illustrates the use of functions ode2, and ic1, in the solution of 1st-order ODEs. The examples in this section, and in all sections of this chapter whose titles are marked with an asterisk (*), were generously contributed by:
Dr. Luigi Marino Professor of Informatics and Mathematics Liceo “Camilo Golgi” BRENO, Brescia, Italy
All the examples shown in this section start with a given differential equation ( ODE ) and an initial condition y = y0 , at x = x0. The general solution consists in using function ode2 to produce the general solution, followed by a call to function ic1 to substitute the initial condition into the solution. Plots of the solution then follow.
Example 1 – Solve
dy dx
=− xy 2 x (^) , subject to the initial conditions: y(0) = 3. The solution
using wxMaxima, including a plot y ( x ), is accomplished as follows:
Notice that the solution can be simplified algebraically by using function expand , namely:
Example 2 - Solve
dy dx
=−cos x y exp sin x (^) , subject to the initial conditions: y(0) = 3.
Solution and plot:
Example 3 - Solve
dy dx
y x
x (^) , subject to the initial conditions: y(1) = 3.
Solution and plot:
An attempt to solve for y , out of this expression produces:
These can be re-written as:
Now we can solve for y :
and produce a plot of the solution:
Example 4 - Solve dy dx
x^2 y^2 2 x y
, subject to the initial conditions: y(0) = 0. Also, solve
the ODE using the initial conditions y(2) = 3.
First, we obtain a general solution:
This result includes y(x) in an implicit expression. We can use function ic1 to substitute the initial condition y(0) = 0 , i.e.,
Solving for y indicates that the solutions are imaginary:
Next, we use function ic1 to substitute the second initial condition proposed, y(2) = 3 , i.e.,
Solving for y we now find two real solutions:
Example 6 - Solve
dy dx
=− y^2 , subject to the initial conditions: y(0) = 0. Also, solve the
ODE using the initial conditions y(1) = 1.
Solution:
Additional examples of second order, initial value ODE solutions ()* This section illustrates the use of functions ode2, and ic2, in the solution of initial-value, 2nd-order ODEs. The examples in this section were also generously contributed by:
Dr. Luigi Marino Professor of Informatics and Mathematics Liceo “Camilo Golgi” BRENO Brescia, Italy
All the examples shown in this section start with a given differential equation ( ODE ) and an initial conditions y = y0 and diff(y,x) = y0p , at x = x0. The general solution consists in using function ode2 to produce the general solution, followed by a call to function ic2 to substitute the initial condition into the solution. Plots of the solution then follow.
Example 1 – Solve
d^2 y dx^2
dy dx
2 y = (^0) , subject to the initial conditions: y = 2 , and
dy dx
=− (^1) , at x = 0.
Solution:
Example 2 – Solve
d^2 y dx^2
dy dx
− y = (^0) , subject to the initial conditions: y = 1 , and
dy dx
= (^0) , at x = 0.
Solution:
Example 4 – Solve
d^2 y dx^2
dy dx
− 13 y = (^0) , subject to the initial conditions: y = 4, and
dy dx
= (^0) , at x = 0.
Solution:
A plot of the solution is shown next:
Example 5 – Solve d^2 y dx^2
6 dy dx
8 y = (^0) , subject to the initial conditions: y = 1, and
dy dx
= (^1) , at x = 1.
Solution:
A plot of the solution follows: