# 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 + x C + (-((C Cos[x Sqrt[a1]])) - (C 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] – user7056953 Feb 5 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. – Henrik Schumacher Feb 5 at 10:35
• You mean DSolve and not NDSolve ? – user7056953 Feb 5 at 10:38
• Oops. Yes. I meant DSolve. – Henrik Schumacher Feb 5 at 10:46

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

DSolve[{a1*y''[x] + y''''[x] == 0,
y == c1 + c3,
y' == c2 + Sqrt[a1] c4,
y'' == -a1 c3,
y''' == -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 x - C Sin[Sqrt[a1] x] - C Cos[Sqrt[a1] x] + a1 C)/a1}*)

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

(*C Sin[Sqrt[a1] x] + C Cos[Sqrt[a1] x] + C x + C*)


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