0
$\begingroup$

Greeting I am trying to numerically solve a differential equation expressed in a code below, as an analytical solution is not feasible (probably, correct me if I am wrong)

z1,z2- are actually the functions of time and should be within boundaries {z1,0,tmax*G},where G - any positive constant. However, in the code below me trying to treat them as a

The terminal condition for the b=b(tmax)=-P. b(t) is a non-zero value.

Ane help will be appreciated. Probably, I have done a lot of newbies mistakes again.

Thank you very much!

The code:

 ClearAll["Global`*"]
tmax = 10; r = 0.5; lambda = 0.3; P = 20;


j = D[b[t, z1, z2], t] + (3/2 + z2^2 + z1^2)*b[t, z1, z2]^2*lambda^2*
    Exp[r*t] + (1 + z1^2)*b[t, z1, z2]*P*lambda^2*Exp[r*t] == 0


s = NDSolve[ {j , b[tmax, z1, z2] == -P}, b, {t, 0, tmax}, {z1, 0, 100}, {z2, 0, 100}]

Plot3D[b[t, z1, 100], {t, 0, tmax}, {z1, 0, 100}]
$\endgroup$

closed as off-topic by zhk, MarcoB, garej, Michael E2, m_goldberg Jun 20 '17 at 23:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – zhk, MarcoB, garej, Michael E2, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ You missed to use the solution in Plot3D. Plot3D[b[t, z1, 100] /. s, {t, 0, tmax}, {z1, 0, 100}] works $\endgroup$ – Lotus Jun 20 '17 at 10:29
  • $\begingroup$ Probably, that is all $\endgroup$ – Oleh Jun 20 '17 at 10:40
  • $\begingroup$ I have another stupid question: I now need to use the solution of the NDsolve (b) to estimate my value function, and plot it for {z1, 0, 100}, {z2, 0, 100}: V = b[t, z1, z2]*Exp[-lambda*(z1 + z2)] + PExp[lambdaz2] What is the appropriate command to do that? $\endgroup$ – Oleh Jun 20 '17 at 10:57
1
$\begingroup$

The issue with getting an empty plot has been answered by @Lotus.

My response is to the OP's comment regrading calling the numerical solution outside of the NDSolve into an expression and then plotting it. For this purpose, I have used SetDelay like this,

f[t_, z1_, z2_] := (b /. s[[1, 1]])[t, z1, z2];

V[t_, z1_, z2_] := f[t, z1, z2]*Exp[-lambda*(z1 + z2)] + P*Exp[lambda*z2];

Plot3D[V[1, z1, z2], {z1, 0, 100}, {z2, 0, 100}]

Since OP has not mentioned a specific value for t, so I choose a random one here.

$\endgroup$

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