TransWikia.com

Ndsolve with NIntegerate

Mathematica Asked by Sachin Kaushik on March 8, 2021

 N1 = 5000;
th = Pi/4;
s1 = 0.01 Sin[th];
s0 = 0.01 Sin[th];
sig = 0.01;
h = 0.5;
nst1 = NDSolve[{
   (x (1 - x) )/2  D[T1[x], x, x] +  s0 N1  x (1 - x) D[T1[x], x] + 
  sig Cos[th] x (1 - x) == 
 NIntegrate[x2 NIntegrate[x1, {x1, 0, x2}], {x2, 0, x}],
T1[0.000000001] == 0, T1[.99999999] == 0
}, {T1}, {x, 0.000000001, .99999999}];

I have attached the code below, the main error is I am not able to use double Nintegerate in the ndsolve where NIntegerate has x dependence. Please don’t simplify the double integration by hand because, in the original code, the double integration can not be done analytically.

One Answer

You can not do an numerical integral with symbolic bounds. You must ensure that the integral is only called with numeric values. Towards this aim, you can define a function for each integral and constrain the undefined bound to be numeric. Here is one way of doing this:

N1 = 5000;
th = Pi/4;
s1 = 0.01 Sin[th];
s0 = 0.01 Sin[th];
sig = 0.01;
h = 0.5;

int1[x_] /; NumericQ[x] := NIntegrate[x2 int2[x2], {x2, 0, x}]
int2[x2_] /; NumericQ[x2] := NIntegrate[x1, {x1, 0, x2}];

nst1 = NDSolve[{(x (1 - x))/2 D[T1[x], x, x] + 
     s0 N1 x (1 - x) D[T1[x], x] + sig Cos[th] x (1 - x) == int1[x], 
   T1[0.000000001] == 0, T1[.99999999] == 0}, {T1}, {x, 
   0.000000001, .99999999}][[1]]

enter image description here

Correct answer by Daniel Huber on March 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP