# Using DSolve to solve fourth order ODE

I am solving the following equation using Dsolve command in Mathematica:

DSolve[a1*y''[x] + y''''[x] == 0, y[x], x]


The general solution of these equations are of the form:

y = c1+c2*x+c3*Cos[Sqrt[a1]*x]+c4*Sin[Sqrt[a1]*x]


But, Mathematica gives me the following solution:

C[3] + x C[4] + (-((C[1] Cos[x Sqrt[a1]])) - (C[2] Sin[x Sqrt[a1]]))/a1


Although, both of the solutions are equivalent since you can always you can change your constants, however, I want the general solution (y= c1+c2*x+c3*Cos[Sqrt[a1]*x]+c4*Sin[Sqrt[a1]*x]) as the output from Mathematica. Can you please suggest what additional conditions I need to impose so that Mathematica gives result exactly as general solution?

Thank you very much for your help!

• DSolve[a1*y''[x] + y''''[x] == 0, y[x], x] Feb 5, 2019 at 10:26
• Apply Expand to the output of NDSolve. Apart from naming conventions for the constants, the result is very close to the desired form. You can replace the constants with ReplaceAll. Feb 5, 2019 at 10:35
• You mean DSolve and not NDSolve ? Feb 5, 2019 at 10:38
• Oops. Yes. I meant DSolve. Feb 5, 2019 at 10:46

You could use boundary conditions to fix the names of your parameters:

DSolve[{a1*y''[x] + y''''[x] == 0,
y[0] == c1 + c3,
y'[0] == c2 + Sqrt[a1] c4,
y''[0] == -a1 c3,
y'''[0] == -a1^(3/2) c4},
y[x], x] // Expand
(* {{y[x] -> c1 + c2 x + c3 Cos[Sqrt[a1] x] + c4 Sin[Sqrt[a1] x]}} *)


Just combine constants.

DSolve[a1*y''[x] + y''''[x] == 0, y[x], x] // Flatten // Simplify

(*{y[x] -> (a1 C[4] x - C[2] Sin[Sqrt[a1] x] - C[1] Cos[Sqrt[a1] x] + a1 C[3])/a1}*)

y[x_] = y[x] /. % /. {C[1] -> -a1 C[1], C[2] -> -a1 C[2]} // Simplify

(*C[2] Sin[Sqrt[a1] x] + C[1] Cos[Sqrt[a1] x] + C[4] x + C[3]*)


Works because a1 * an arbitrary constant is still an arbitrary constant.