Download Lab2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Kerr metric wikipedia , lookup

Schrödinger equation wikipedia , lookup

Unification (computer science) wikipedia , lookup

Maxwell's equations wikipedia , lookup

Debye–Hückel equation wikipedia , lookup

Two-body problem in general relativity wikipedia , lookup

Equation of state wikipedia , lookup

Derivation of the Navier–Stokes equations wikipedia , lookup

BKL singularity wikipedia , lookup

Perturbation theory wikipedia , lookup

Navier–Stokes equations wikipedia , lookup

Euler equations (fluid dynamics) wikipedia , lookup

Equations of motion wikipedia , lookup

Itô diffusion wikipedia , lookup

Schwarzschild geodesics wikipedia , lookup

Differential equation wikipedia , lookup

Exact solutions in general relativity wikipedia , lookup

Partial differential equation wikipedia , lookup

Transcript
Matlab Lab 2
Example 1 To find the general solution to the second order equation
𝑥 ′′ − 3𝑥 ′ + 2𝑥 = 2𝑡 , type at the command line
and Matlab returns the general solution:
To solve the same equation with the initial condition 𝑥(0) = 2, 𝑥 ′ (0) = 1, type the following
two lines and the output follows:
__________________________________________
Not all differential solutions can be solved in closed forms, much fewer can be solved by Matlab in
formulas. The next example shows if an implicit solution is found, Matlab can be used to plot the
solutions as the level curves of the implicit solution.
𝑥
Example 2 Solve the differential equation 𝑦 ′ = 𝑦4 −1 to obtain the implicit solution
In this case the solution 𝑦(𝑥) is defined implicitly as the root of the algebraic equation
𝑦 5 − 5𝑦 −
5𝑥 2
=𝐶
2
Type the following to plot the level curves of the potential function on the left side:
1
The figure shows as follows (without ‘Answer Graph’)
which has also an initial point (1,-0.5) included by typing this after the last command:
__________________________________________
All higher order equations of one variable can be converted to a system of first order equations. For
example, by introducing the new variable 𝑦 = 𝑥 ′ , a second order equation 𝑥 ′′ = 𝐹(𝑡, 𝑥, 𝑥 ′ ) is
transformed to a system of two first order equations
𝑥′ = 𝑦
𝑦 ′ = 𝐹(𝑡, 𝑥, 𝑦)
This is a special case of the general form of systems of two differential equations
𝑥 ′ = 𝑓(𝑡, 𝑥, 𝑦)
𝑦 ′ = 𝑔(𝑡, 𝑥, 𝑦)
Euler’s method can also be extended to systems of differential equations.
Example 3 (Numerical Solutions) To obtain the numerical solution by Euler’s method for the equation
7𝑥 ′ 25𝑥
𝑥 ′′ = −
− 2 + sin(𝑡)
𝑡
𝑡
with the initial condition 𝑥(1) = 1, 𝑥 ′ (1) = 2 , in the time interval [0, 20] with the step size h=0.01, type
at the command lines
2
The solutions are plotted in two different types (without the figure labels):
__________________________________________
(See Lab 1 for instruction to prepare your hand-in work.)
End Lab 2
3