1
$\begingroup$

I'm new to Mathematica and trying to solve some ODE's through it. But, whenever I try solving these ODE's I get pure functions as solutions with exponents only. Here's a pic for example. enter image description here

Now, if I do this problem by hand the general solution I get is enter image description here.

Is there anyway in mathematica that I can get solutions like these?

$\endgroup$
1
$\begingroup$

ps. I do not know why you have $c$ in your solution, since you have initial condition there, so there should not be a constant of integration. The solution you show by hand is general implicit. There is no option in DSolve to ask for an implicit solution. At least not directly.

ClearAll[y, x];
ode = y'[x] == (4*x + y[x] + 1)^2
ic = y[0] == 1;
sol = DSolve[{ode, ic}, y[x], x]
ExpToTrig[sol] // FullSimplify

Mathematica graphics

May be future version of DSolve will have `implicit' option. It will good to have.

In Maple, there is one. Here is an example

ode := diff(y(x),x) = (4*x + y(x) + 1)^2;
dsolve(ode,y(x),'implicit')

enter image description here

Just to clarify the implicit/explicit solutions. In Maple, it has an option to return either explicit or implicit. Ofcourse, the explicit solution is returned if $y(x)$ can be solved for in the first place, otherwise it will do like DSolve does when it can't solve for $y(x)$. The default is explicit like with DSolve now.

enter image description here

This is illustrated in this example by

enter image description here

It will be good if DSolve also had such an option to allow one to choose at user level.

$\endgroup$
7
  • $\begingroup$ Is there any other function in mathematica which could give me implicit solutions? $\endgroup$ Nov 22 '21 at 5:35
  • $\begingroup$ @AyushYadav Not that I know about. I asked about having an implicit option for DSolve myself before a few times. It will be nice to have. $\endgroup$
    – Nasser
    Nov 22 '21 at 5:36
  • $\begingroup$ Is there any other software/program/lang other than mathematica which could give implicit solutions? $\endgroup$ Nov 22 '21 at 5:38
  • $\begingroup$ @AyushYadav updated. $\endgroup$
    – Nasser
    Nov 22 '21 at 5:39
  • $\begingroup$ @Nasser Sometimes Mathematica shows some kind of implicit solution. Try to solve for x[y] : DSolve[{1 == x'[y] (1 + 4 x[y] + y + 1)^2, x[1] == 0}, x[y], y] and Mathematica retrurns an evaluated implicit expression Solve[2 ArcTan[1/2 (2 + y + 4 x[y])] - 4 x[y] == 2 ArcTan[3/2], x[y]] $\endgroup$ Nov 22 '21 at 7:14
0
$\begingroup$
Clear["Global`*"]

eqn = {y'[x] == (4 x + y[x] + 1)^2, y[0] == 1};

A pure function results from not providing an explicit argument to the function y in DSolve

sol1 = DSolve[eqn, y, x][[1]]

(* {y -> Function[{x}, -(((-2 - I) + (1 + 2 I) E^(4 I x) - 4 I x + 
     4 E^(4 I x) x)/(-I + E^(4 I x)))]} *)

This form is useful when replacing the function y in expressions that may also include its derivatives. For example, to verify the solution:

eqn /. sol1 // Simplify

(* {True, True} *)

However, to simplify the result, the pure function must be evaluated

sol2 = {y[x] -> (y[x] /. sol1) // ExpToTrig // FullSimplify}

(* {y[x] -> 1 - 4 x + 4/(-1 + Cot[2 x])} *)

In this form, replacing derivatives is somewhat more involved, particularly if high-order derivatives are involved.

eqn[[1]] /. {sol2[[1]], D[sol2[[1]], x]} // Simplify

(* True *)

With an explicit argument to the function in DSolve, the solution can be directly simplified

sol3 = DSolve[eqn, y[x], x][[1]] // ExpToTrig // FullSimplify

(* {y[x] -> 1 - 4 x + 4/(-1 + Cot[2 x])} *)

sol3 === sol2

(* True *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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