I was trying to solve a nonlinear differential equation with the following code.
DSolve[3*x^2/D[u[x, y], x] + 3*y^2/D[u[x, y], y] == -1, u, {x, y}]
And I got the following output:
{{u -> Function[{x, y}, x^3/(-1 + C[1]) - y^3/C[1] + C[2]]}}
I would like to see steps. So, I used the following code:
WolframAlpha["DSolve[3*x^2/D[u[x,y],x]+3*y^2/D[u[x,y],y]\[Equal]-1,u,{\
x,y}]", IncludePods -> "Input", AppearanceElements -> {"Pods"},
PodStates -> {"Input__Show steps"}]
But this did not give steps. Is it possible to understand how mathematica solved this differential equation?
Answer
@Nasser's method seems to be what Mathematica does internally. The following gives hints of the steps taken, and one can see the elements of Nasser's solution. Some is left to the user to guess. The first code modifies Integrate
to print itself out; the second uses Trace
to see the calls to Integrate
.
Block[{DSolve`print = Print}, (* internal hook *)
Internal`InheritedBlock[{Integrate}, Unprotect[Integrate]; (* alter Integrate to print itself *)
i : Integrate[___] /; ! TrueQ[$in] :=
Block[{$in = True}, Print["***Integrate= ", HoldForm[i]]; i];
Protect[Integrate];
DSolve[3*x^2/D[u[x, y], x] + 3*y^2/D[u[x, y], y] == -1, u, {x, y}]
]]
This does something similar, but the Integrate
commands are output at the end, not at the time they are called:
Block[{DSolve`print = Print},
Trace[
DSolve[3*x^2/D[u[x, y], x] + 3*y^2/D[u[x, y], y] == -1, u, {x, y}],
_Integrate,
TraceInternal -> True
]]
Comments
Post a Comment