I am trying to solve a linear ODE with a variable coefficient which is given in terms of an integral I can only do numerically. That is, I have an equation of the form
$$
u'(t)=u(t)\int_0^t\sqrt{1+e^{-\tau^2}\sin(\tau)}d\tau,
$$
where the integrand could be pretty much any well-behaved function - but which in general will cause Mathematica to choke when given to Integrate
and eventually say it can't do it.
I know that such a lack of an analytic handle on the coefficients in the equation essentially disqualifies me from an analytic solution of the equation. However, given that I am, or should be, perfectly able to numerically compute this coefficient, Mathematica ought to be able to numerically solve the equation.
My initial guess as to how to do this would be to simply indicate the integral should be done numerically:
NDSolve[{D[u[t], t] == NIntegrate[
Sqrt[1 + E^tt^2 Sin[tt^2]], {tt, 0, t}] u[t], u[0] == 1}, u, {t, 0, 1}]
but this simply outputs the error
NIntegrate::nlim: tt = t is not a valid limit of integration. >>
.
I've also tried with plain Integrate
and setting GenerateConditions->False
, but none of them work and they also take a long time to return their errors, which I assume is because they're trying to symbolically solve the integral - and I specifically don't want that.
Can someone provide a way to make Mathematica understand it just needs to buckle down and calculate?
f[t_?NumericQ] := NIntegrate[Sqrt[1 + Exp[-tt^2] Sin[tt^2]], {tt, 0, t}]; NDSolve[{u'[t] == f[t] u[t], u[0] == 1}, u, {t, 0, 1}]
$\endgroup$tt
to describe\[Tau]
. Hit escape key , t and then escape again to get tau. I see thistt
a lot with matlab and C users alike but this isn't needed in mathematica. $\endgroup$