# Transform a DSolveValue solution into a reasonable form

Here are two equations:

    eq1 = D[z[x], {x, 4}] + z[x] == 0;
eq2 = D[z[x], {x, 4}] + q^4*z[x] == 0;


They only differ from one another by the scale factor q^4, where q>0. I need to solve them in real numbers. If I solve the first one I get

  DSolveValue[eq1, z[x], x]

(* E^(x/Sqrt) C Cos[x/Sqrt] + E^(-(x/Sqrt)) C Cos[x/Sqrt] + E^(-(x/Sqrt)) C Sin[x/Sqrt] + E^(x/Sqrt) C Sin[x/Sqrt]     *) which is convenient to look at. However, if I solve the second one, I get:

 DSolveValue[eq2, z[x], x]

(*  E^((-1)^(3/4) q x) C + E^(-(-1)^(1/4) q x) C + E^(-(-1)^(3/4) q x) C + E^((-1)^(1/4) q x) C   *) which is alredy less convenient. Since q is real and positive, it is obvious, that the solution is like the solution of eq1, in which we make a replacement: x->q*x:

    DSolveValue[eq1, z[x], x] /. x -> q*x

(* E^((q x)/Sqrt) C Cos[(q x)/Sqrt] + E^(-((q x)/Sqrt)) C Cos[(q x)/Sqrt] + E^(-((q x)/Sqrt)) C Sin[(q x)/Sqrt] + E^((q x)/Sqrt) C Sin[(q x)/Sqrt]  *) However, I cannot find a regular operation which would transform the solution of eq2 into this form.

Any idea?

• Dirty trick, not recommended: DSolveValue[D[z[x], {x, 4}] + EulerGamma^4*z[x] == 0, z, x] /. EulerGamma -> q. (Any positive symbolic constant could have worked just as well.) – J. M.'s ennui Oct 5 '16 at 11:43
• @ J. M. I admire this trick, the more that one can use, say, Pi instead of the EulerGamma . However, I am preparing this for students, and poor students will go crazy with such tricks. They need something more regular. – Alexei Boulbitch Oct 5 '16 at 12:33
• Yes, that's why I emphasized "not recommended"... I tried Assumptions, but it does nothing useful in this case. – J. M.'s ennui Oct 5 '16 at 12:34
• Similar to questions 126132 and 126768. – bbgodfrey Oct 6 '16 at 11:33
• @ bbgodfrey Thank you. As much as I understood from your answer, there is no satisfactory answer, as yet, right? – Alexei Boulbitch Oct 6 '16 at 15:48

## 2 Answers

eq2 = D[z[x], {x, 4}] + q^4*z[x] == 0;
sol = DSolveValue[eq2, z[x], x] sol2 = ComplexExpand@sol rule = First@
Solve[{C + C == a, C + C == b, I (C - C) == c,
I (-C + C) == d}, {C, C, C, C}] sol2 /. rule // Expand Similar to corey979's answer

eq1 = D[z[x], {x, 4}] + z[x] == 0;
eq2 = D[z[x], {x, 4}] + q^4*z[x] == 0;

sol1 = DSolveValue[eq1, z[x], x] The terms without the GeneratedParameters are

terms1 = List @@ sol1 /. C[_] :> 1 Using distinct GeneratedParameters for sol2

sol2 = DSolveValue[eq2, z[x], x,
GeneratedParameters -> d] Finding the relations between the two sets of GeneratedParameters

rules =
Solve[
Thread[
(Coefficient[sol1 , #] & /@ terms1) ==
(Coefficient[
sol2 /. q -> 1 //
ComplexExpand[#, Array[d, 4]] &,
#] & /@ terms1)], Array[d, 4]][] //
Simplify[#, Element[Array[C, 4], Reals]] & Substituting the GeneratedParameters

sol2 = sol2 /. rules // ComplexExpand Verifying

sol1 == (sol2 /. q -> 1)

(*  True  *)