2

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!

zhk
  • 11,939
  • 1
  • 22
  • 38
M.Pow
  • 65
  • 7

1 Answers1

1

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

zhk
  • 11,939
  • 1
  • 22
  • 38
  • 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? – M.Pow Feb 08 '17 at 06:53
  • @M.Pow What you mean by two variables? – zhk Feb 08 '17 at 07:08
  • 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 – M.Pow Feb 08 '17 at 08:01
  • @M.Pow you need to share your complete try – zhk Feb 08 '17 at 08:15
  • 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]`

    – M.Pow Feb 08 '17 at 08:31