1
$\begingroup$

So I got a question. Everytime I use a derivative of a function during plotting or ongoing evaluation, it seems Mathematica misunderstands me, and just derives a value (a constant) which always results in a 0. What could be the problem? I demonstrate this with the solution of the Blassius boundary layer equation:

sol1 = NDSolve[{
    D[f1[ξ], ξ] == g1[ξ], D[g1[ξ], ξ] == h1[ξ],
    D[h1[ξ], ξ] + f1[ξ]*h1[ξ] == 0, 
    f1[0] == 0, g1[0] == 1, g1[10] == 0},
   {f1, g1, h1},
   {ξ, 0, 10}];

f1rand = f1[10] /. sol1;
g1rand = g1[10] /. sol1;
h1rand = h1[10] /. sol1;

Plot[D[g1[ξ], ξ] /. sol1, {ξ, 0, 10}, PlotRange -> All]
Plot[h1[ξ] /. sol1, {ξ, 0, 10}, PlotRange -> All]

Any help would be greatly appreciated!

$\endgroup$
1
$\begingroup$

The correct way to do it is to use g1'[ξ]

 Plot[g1'[ξ] /. sol1, {ξ, 0, 10}, PlotRange -> All]

enter image description here

Plotting f1'[ξ], g1'[ξ] and h1'[ξ] in one plot,

Plot[Evaluate[{f1'[ξ], g1'[ξ], h1'[ξ]} /. sol1], {ξ,0, 10}, PlotRange -> All, 
PlotStyle -> {Red, Green, Blue},Frame -> True, PlotLegends -> {"f1'", "g1'", "h1'"}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks, thats what I was looking for. But if for instance I were to do this with 2 variables the '-command wouldn't apply anymore. How would I go about that? $\endgroup$ – M.Pow Feb 8 '17 at 6:53
  • $\begingroup$ @M.Pow What you mean by two variables? $\endgroup$ – zhk Feb 8 '17 at 7:08
  • $\begingroup$ Well I just asked that question because I have a differential equation where I have a function like f(x,y) and I would like to Plot the derivative of ∂f(x,y)/∂y $\endgroup$ – M.Pow Feb 8 '17 at 8:01
  • $\begingroup$ @M.Pow you need to share your complete try $\endgroup$ – zhk Feb 8 '17 at 8:15
  • $\begingroup$ Same example only 2D sol1 = NDSolve[{ D[f1[x, \[Xi]], \[Xi]] == g1[x, \[Xi]], D[g1[x, \[Xi]], \[Xi]] == h1[x, \[Xi]], D[h1[x, \[Xi]], \[Xi]] + f1[x, \[Xi]]*h1[x, \[Xi]] == 0, f1[x, 0] == 0, g1[x, 0] == 1, g1[x, 10] == 0, f1[0, \[Xi]] == 0, g1[0, \[Xi]] == 0, h1[0, \[Xi]] == 0 }, {f1, g1, h1}, {x, 0, 1}, {\[Xi], 0, 10}] Plot[D[g1[x, \[Xi]], \[Xi]] /. sol1, {\[Xi], 0, 10}, PlotRange -> All] Plot[h1[x, \[Xi]] /. sol1, {\[Xi], 0, 10}, PlotRange -> All] $\endgroup$ – M.Pow Feb 8 '17 at 8:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.