# Not plotting solution to the coupled non linear ODE system using NDSolve [closed]

Im trying to solve the following system of non-linear coupled first-order ordinary differential equations: $$\frac{dh}{dx}=-h^2c^2$$ $$\frac{dc}{dx}=-hc$$ with the conditions: $$h(5)=5, c(5)=0.79e^{-12.5}$$

Using NDSolve I tried to plot the solution for $$h$$:

 In[1]:= Clear[x]
sol = NDSolve[{h'[x] == -h[x]^2c[x]^2+1, c'[x] == -h[x]c[x],h[5] == 5, c[5] == 0.79Exp[-12.5] }, {h, c}, {x, -10, 10}]
Plot[Evaluate[{{h[x]} /. sol}], {x, -10, 10},PlotRange -> All]


But unfortunately, I didnt see a graph, only an empty plot appeared, and error messages before the plot:

NDSolve::dsvar: -9.99959 cannot be used as a variable.
NDSolve::dsvar: -9.99959 cannot be used as a variable.
NDSolve::dsvar: -9.59143 cannot be used as a variable.
General::stop: Further output of NDSolve::dsvar will be suppressed during this calculation.


How to solve this, so the plot will generate a graph corresponding to the solution of the equations?

• Range \[Rightarrow] All should be PlotRange -> All. Please don't use math assistent to input the right arrow, simply type -> is the right way to go. Also, the system becomes stiff at x == -0.266228 as mentioned in the warning. If it should not be stiff, please double check if the system itself is correct. Commented Jan 25, 2023 at 9:49
• It's PlotRange, not Range. And, please don't add bugs until the community has confirmed it. Commented Jan 25, 2023 at 9:54
• ok thank you, but there is other problem poping it after I edited my post Commented Jan 25, 2023 at 9:54
• This time your variable (probably x) is polluted. Please always pay attention to the color of variable. If it's empty, it'll (in most cases) be blue, otherwise it's black. Execute Clear[x, c, h, Derivative] to remove the pollution. Commented Jan 25, 2023 at 10:22
• @Daniel Vainshtein Im quite sure that changing the range might help. See my answer. Commented Jan 25, 2023 at 10:32

Using the solution range provided by NDSolve try:
{xmin, xmax} = (h   /. sol[[1]])["Domain"][[1]];(*{-0.266228, 10.}*)
`