1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ This knowledge base article should help. If you need additional help, read through other questions on this site - there are countless questions on this exact topic (maybe not for NDSolve specifically, but for Solve, NSolve and related functions - and they all work the same in terms of using their output) $\endgroup$ – Lukas Lang Jun 11 '18 at 8:55
  • 1
    $\begingroup$ In addition, your code example does not evaluate because the definition for alpha is missing. People, in general, are more likely to help if they have a working minimal example. You can simply edit your question and add what you use for alpha. $\endgroup$ – halirutan Jun 11 '18 at 9:03
  • 1
    $\begingroup$ Also might want to use NDSolveValue. $\endgroup$ – Daniel Lichtblau Jun 11 '18 at 9:40
1
$\begingroup$

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

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