Skip to main content

plotting - Replacing solution NDSolve


I have an equation that I solve :


 sol = NDSolve[{  Div[(1 - f[x]) Grad[f[x], {x, y}, "Polar"], {x, y}, 
"Polar"] == -(1 - f[x]) f[x] (f[x] - 0.8), f[1] == 0.7, f'[0.00001] == 0.0001}, f,
{x, 0.0001, 1}]

I want to plot the function : $(1-f(x))f'(x)/f(x)$. How can I do it simply, meaning, by replacing the interpolating function by a function. I do not want to do :


Plot[1-InterpolatingFunction[..][x]...]

because it is too long, and not easy to handle if I change the equation.



I tried :


f[x]/.sol[[1]]
Plot[(1-f[x])f'[x]/f[x],{x,0.0001,1}]

but it doesn't work



Answer



Like Daniel Lichtblau, I recommend using NDSolveValue rather than NDSolve, because it returns the interpolation function directly.


Clear[f]
f =
NDSolveValue[

{Div[(1 - f[x]) Grad[f[x], {x, y}, "Polar"], {x, y}, "Polar"] ==
-(1 - f[x]) f[x] (f[x] - 0.8),
f[1] == 0.7,
f'[0.00001] == 0.0001},
f, {x, 0.0001, 1}];
g[x_] = (1 - f[x]) f'[x]/f[x];
Plot[g[x], {x, 0.0001, 1}]

plot


Comments