0
$\begingroup$

When I solve this differential equation with NDSolve, I get a numerical solution for H[x]:

Code for the differential equation:

sol1 = NDSolve[{(H'[x])^2 - ((1 + 6 H[x]^2)^2 H[x]^2)/(
 6 (1 + 18 H[x]^2)) + ((1 + 6 H[x]^2)^2 E^-x)/(
 18 (1 + 18 H[x]^2)) == 0, H[0] == 1}, H, {x, 0, 20}]

I want to use the numerical solution (The solution that I get for the equation that is above) for solving numerically this equation ( I want to get x[t])

Code for the equation that I want to solve

x'[t] == -2 H'[x]

Thanks!!

$\endgroup$
  • 2
    $\begingroup$ x'[t] == -2 H'[x] /. sol1 $\endgroup$ – J42161217 Nov 23 '18 at 14:49
  • $\begingroup$ sol1=NDSolve[{system},H[x],{x,0,1.7}] because your system appears to blow up beyond 1.7 then Plot[H[x]/.sol1,{x,0,1.7}] then x1=Integrate[-2*H[x]/.sol1[[1]],x] and x2=Integrate[-2*H[x]/.sol1[[2]],x] because there appear to be two solutions then Plot[{x1,x2},{x,0,1.7}] and x1/.x->1.0 to find the value of x1 when t==1.0 $\endgroup$ – Bill Nov 23 '18 at 15:47
1
$\begingroup$
Clear["Global`*"]

sol1 = NDSolve[{(H'[
         x])^2 - ((1 + 6 H[x]^2)^2 H[x]^2)/(6 (1 + 
           18 H[x]^2)) + ((1 + 6 H[x]^2)^2 E^-x)/(18 (1 + 
           18 H[x]^2)) == 0, H[0] == 1}, H[x], {x, 0, 20}] // Flatten

We get 2 branches of the solution. The first branch is well-behaved and the second blows up at about x = 1.73 I will use the first well-behaved branch.

H1[x_] = H[x] /. sol1[[1]];

Plot[H1[x], {x, 0, 20}, PlotRange -> All]

enter image description here

For the second part

NDSolve[{x'[t] == -2 H1'[x[t]], x[0] == 0}, x[t], {t, 0, 20}] // Flatten;

x[t_] = x[t] /. %

Plot[x[t], {t, 0, 20}]

enter image description here

Check the solution

Plot[{x'[t], (-2 H1'[x[t]])}, {t, 0, 20}, PlotRange -> All]

enter image description here

They pretty much overlay. Or more accurately:

Plot[{x'[t] - (-2 H1'[x[t]])}, {t, 0, 20}, PlotRange -> All]

enter image description here

$\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.