I need to extract constant C[1] from expression which I get when solve equation. i.e.


In result Mathematica gives me this one

y[x]->C[1]+1/2 Log[x]

But I want something like this

C[1]=x Exp[-2y]

I'll try to use DSolve.Constant[] (sound like exactly what I want, but isn't working unfortunately) Please, help me.


closed as off-topic by dr.blochwave, Sjoerd C. de Vries, Mr.Wizard Jul 1 '15 at 10:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – dr.blochwave, Sjoerd C. de Vries, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ So, transform the rule to an equation and Solve it. You can transform it using the prediction interface of Mathematica $\endgroup$ – Sektor Jul 1 '15 at 6:37
  • 1
    $\begingroup$ @Sektor Thanks. I did it. sol = DSolveValue[y'[x] - 1/(2x) == 0, y[x], x] Solve[y[x] == sol, C[1]] $\endgroup$ – PilgrimViis Jul 1 '15 at 7:32
  • $\begingroup$ Or: Solve[Keys[#] == Values[#] &[DSolve[y'[x] == 1/(2 x), y[x], x]], C[1]] $\endgroup$ – Mariusz Iwaniuk Jul 3 '15 at 15:35
       expr1 = y[x] -> C[1] + 1/2 Log[x]

  (*   y[x] -> C[1] + Log[x]/2   *)

    expr2 = expr1[[2]] == y

  (*    C[1] + Log[x]/2 == y  *)

    expr3 = Map[Subtract[#, Log[x]/2] &, expr2]

    (*  C[1] == y - Log[x]/2  *)

        Map[Exp, expr3] /. E^C[1] -> C2

     (*     C2 == E^y/Sqrt[x]    *)

Have fun!

  • $\begingroup$ This only answers the question in this specific case. Which the OP has already done by hand. $\endgroup$ – Myridium Jul 1 '15 at 8:19
  • $\begingroup$ @Myridium 6 Of course. But this is also the way in a more complex case, and no general solution at all. $\endgroup$ – Alexei Boulbitch Jul 1 '15 at 14:51
  • $\begingroup$ @PilgrimViis demonstrated a general solution. $\endgroup$ – Myridium Jul 1 '15 at 15:21
  • $\begingroup$ @ Myridium No, he did not. It is just an illusion. In a general case equation for C[1] may be a transcendental one, Solve returning nothing in that case. But the point is that one in reality needs no such general solution, but a reasonable case by case consideration. $\endgroup$ – Alexei Boulbitch Jul 2 '15 at 7:24

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