My code involves integrating the a function, which requires the end value of the NDSolve
. My differential equations and integrating functions are very complex (not related to complex numbers) so I need to use NDSolve
and NIntegrate
.
I was able to get to the point of getting the result of NDSolve
. Now I'm unable to get any further.
Here is a toy problem which is similar to my big code.
ClearAll[Evaluate[StringJoin[Context[], "*"]]]
Needs["Utilities`CleanSlate`"];
CleanSlate[];
ClearInOut[];
c[r_] := E^(-r);
func1[r_, t_] := r + t;
x1x2[r2_, c2_, t2_] := Module[{r = r2, c = c2, t0 = t2},
Reap[
NDSolve[{Derivative[1][x11][t3] == x11[t3]^2 +c func1[r, t3],
WhenEvent[t3 == t0, Sow[x11[t3]]],
x11[0] == 0},
{},
{t3, t0}]][[-1,1,1]]];
x1[r_, t_] := x1x2[r, c[r], t];
x1[0, 1/30]
l[r_, t_] := func1[r, t]*x1[r, t];
finalF[(t_)?NumericQ] := NIntegrate[l[rr, t], {rr, 0, 1}, MaxRecursion -> 50,
AccuracyGoal -> 10, Method -> {"LocalAdaptive", "SymbolicProcessing" -> 0},
PrecisionGoal -> 10];
finalF[1/30]
Plot[final[tt],{tt,0,1}]
I used the solution method described in this answer to obtain the final result of NDSolve
.
Any one kindly suggest me how to proceed. Thank you
NDSolve
solution withIntegrate
. For instance,yFN = y /. First@NDSolve[{y''[x] == x y[x] - y[x]^2, y'[0] == 0, y[0] == 1}, y, {x, 0, 10}]; Integrate[yFN[x], x]
$\endgroup$c=c2
plays in a module? $\endgroup$