0
$\begingroup$

I have a specific problem regarding differential equation output:

enter image description here

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.

$\endgroup$

1 Answer 1

1
$\begingroup$

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]

Addendum

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]
$\endgroup$
5
  • $\begingroup$ Thank you, but still how about renaming constants C[1] into A1 etc.? $\endgroup$
    – Krzysztof
    Commented Jan 31 at 10:15
  • 2
    $\begingroup$ @Krzysztof add GeneratedParameters->A to your DSolve command !Mathematica graphics $\endgroup$
    – Nasser
    Commented Jan 31 at 10:19
  • $\begingroup$ @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? $\endgroup$
    – Krzysztof
    Commented Jan 31 at 11:37
  • $\begingroup$ Look at the "Addendum" in my answer. $\endgroup$ Commented Jan 31 at 12:01
  • $\begingroup$ @DanielHuber Thank you so much! It resolves all my problems! :) $\endgroup$
    – Krzysztof
    Commented Jan 31 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.