# How to solve Laplace transform question for a system in Mathematica

I know how to use the LaplaceTransform function but am struggling to do this with a system with two ODEs.

This is my question:

Use Mathematica and the Laplace transform method to solve the system: $$\begin{cases}f^\prime&=3f+5g-\sin(x)\\g^\prime&=2f-g+\cos(x)\end{cases}$$ with initial conditions $$f(0)=0$$ and $$g(0)=1$$

• How do you try solving the system with LaplaceTransform? Have you checked the Applications section of document of LaplaceTransform? – xzczd Apr 2 at 6:36
• The matrix {{3, 5}, {2, -1}} is diagonalizable, so you can decouple the system first and solve each equation via Laplace transform. – Henrik Schumacher Apr 2 at 6:43

odes = {f'[x] == 3 f[x] + 5 g[x] - Sin[x],  g'[x] == 2 f[x] - g[x] + Cos[x]};
ics = {f[0] == 0, g[0] == 1};

LaplaceTransform[odes, x, s] /. Rule @@@ ics /. HoldPattern@LaplaceTransform[a_, __] :> a


sol = {f[x], g[x]} /. First@Solve[%, {f[x], g[x]}]


InverseLaplaceTransform[sol, s, x] // FullSimplify


• Im assuming this is correct, but shouldn't the answer be one expression only? Also the seocnd part of the question says to solve this problem with Dsolve and show it the same, how would we do this? – greg Apr 2 at 9:38
• @greg You have one solution each for f [x] and g [x]. The solution is given as a list {f [x], g [x]}! The DSolve solution is also very simple: DSolve [{odes, ics}, {f [x], g [x]}, x] // FullSimplify. It is the same solution. Look in the mathematica documentation. Here you learn a lot! The next time you are able to do this without help from others. – rmw Apr 2 at 12:46