# Reduction/Elimination of some terms in DSolve output

I have a specific problem regarding differential equation output:

As you may see, the first input is my function.

DSolve[D[w[x], {x, 4}] + k^2*D[w[x], {x, 2}] == 0, w[x], x]

In there any way to obtain the output as shown in w0[x_] in the third line?

w0[x_] = A1*Cos[k*x] + B1*Sin[k*x] + C1*x + D1

I would like to get rid of some signs and constants from Out[1] equation which are not necessary for me: for instance, I'd like -c1/k^2 to become the unknown constant A1. I would like to get rid of other constants in a similar manner.

Would it also be possible to assign all of this as a simple equation as in In[2]?

I am rather new at Mathematica, so an easy solution would be highly appreciated.

You may replace k^-2 in the solution by 1 like:

sol = DSolve[D[w[x], {x, 4}] + k^2*D[w[x], {x, 2}] == 0, w[x], x][[1]];
sol = sol /. {k^-2 -> 1}

{w[x] -> C[3] + x  C[4] - C[1] Cos[k x] - C[2] Sin[k x]}

With this you can define w0 like:

w0[x_] = w[x] /. sol

C[3] + x  C[4] - C[1] Cos[k x] - C[2] Sin[k x]

To get positive parameters in the form "Ai" :

sol = DSolve[D[w[x], {x, 4}] + k^2*D[w[x], {x, 2}] == 0, w[x], x][[1]];
sol = sol /. k^-2 -> 1 /. -C[i_] :> C[i] /.
C[i_] :> Symbol["A" <> ToString[i]];

t = w0[x_] = w[x] /. sol

A3 + A4 x + A1 Cos[k x] + A2 Sin[k x]
• Thank you, but still how about renaming constants C[1] into A1 etc.? Jan 31 at 10:15
• @Krzysztof add GeneratedParameters->A to your DSolve command !Mathematica graphics Jan 31 at 10:19
• @Nasser okay, thanks, however I have specified my question wrong previously about renaming constatns. I would like to get positive A1 variable instead of -C[1]/k^2 any solution to that and A2 as a -C[2]/k^2, then A3 for C[3]. All variables without square brackets. Is it possible? Jan 31 at 11:37
• Look at the "Addendum" in my answer. Jan 31 at 12:01
• @DanielHuber Thank you so much! It resolves all my problems! :) Jan 31 at 12:23