Ask Your Question
0

Solve differential equation using Laplace transform

asked 2023-08-18 15:08:25 +0200

anonymous user

Anonymous

updated 2023-08-18 16:20:18 +0200

slelievre gravatar image

The question is to solve the following differential equation

$x'''(t)-2x''(t)+5x'=0$, $x(0)=0$, $x'(0)=0$, $x''(0)=1$

using Laplace transform.

i got this solution so far but it isn't working, please help.

# Define symbolic variable
t = var('t')

# Define the function x(t) and its derivatives
x = function('x')(t)
x1 = diff(x, t)
x2 = diff(x1, t)

# Define the differential equation
diff_eq = x^3 - 2*x^2 + 5*x == 0

# Define initial conditions
initial_conditions = [x(0) == 0, x1(0) == 0, x2(0) == 1]

# Solve the differential equation
solutions = desolve_system([diff_eq] + initial_conditions, [x(t)], ivar=t)

# Display the solution
print(solutions[0])
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-08-18 21:49:42 +0200

dan_fulea gravatar image

The following code is working, there is no third power of $x$ involved...

s, t = var('s, t')

# Define the function x(t) and its derivatives
x = function('x')(t)

de = diff(x, t, 3) - 2*diff(x, t, 2) + 5*diff(x, t)
de.laplace(t, s)

This gives so far:

s^3*laplace(x(t), t, s) - 2*s^2*laplace(x(t), t, s)
    - s^2*x(0) + 5*s*laplace(x(t), t, s) 
    + 2*s*x(0) - s*D[0](x)(0) - 5*x(0) + 2*D[0](x)(0) - D[0, 0](x)(0)

The given boundary conditions imply that the transformed function $Lx(s)$ is the function which satisfies the equation: $$ (s^3 -2s^2 +5s)Lx(s) = 1\ . $$

So we have an equation for $Lx$, the solution is obtained by using partial fraction decomposition:

 sage: ( 1/(s^3 - 2*s^2 + 5*s) ).partial_fraction()
-1/5*(s - 2)/(s^2 - 2*s + 5) + 1/5/s

and then transform back, which can be done even directly:

sage: inverse_laplace( 1/(s^3 - 2*s^2 + 5*s), s, t )
-1/10*(2*cos(2*t) - sin(2*t))*e^t + 1/5

Let us test that this is a solution:

sage: X = inverse_laplace( 1/(s^3 - 2*s^2 + 5*s), s, t )
sage: X0, X1, X2, X3 = [diff(X, t, k) for k in [0,1,2,3]]
sage: (X3 - 2*X2 + 5*X1).simplify_full()
0
sage: X.subs(t=0)
0
sage: X1.subs(t=0)
0
sage: X2.subs(t=0)
1
edit flag offensive delete link more

Comments

Noticing that $x$ does not belong to your DE, we can substitute $x'$ by $f$, solve for that and integrate (not forgetting to add the coresponding integration constant) :

sage: var("t")
t
sage: f=function("f")
sage: de=f(t).diff(t,2)-2*f(t).diff(t)+5*f(t)==0
sage: f1(t)=desolve(de, f(t), ivar=t)
sage: var([repr(u) for u in set(f1(t).variables())-set((t,))])
(_K1, _K2)
sage: var("_K0")
_K0
sage: F1(t)=f1(t).integrate(t)+_K0 ; F1
t |--> -1/5*_K1*(2*cos(2*t) - sin(2*t))*e^t + 1/5*_K2*(cos(2*t) + 2*sin(2*t))*e^t + _K0

The integration constants are the solution for the initial conditions :

sage: x=F1.subs(solve([F1(0)==0, F1.diff(t)(0)==0, F1.diff(t, 2)(0)==1], [_K0, _K1, _K2])[0]) ; x
t ...
(more)
Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-08-19 10:06:44 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-08-18 15:08:25 +0200

Seen: 213 times

Last updated: Aug 18 '23