Skip to main content
Fixed grammar.
Source Link
Emilio Pisanty
  • 10.3k
  • 1
  • 37
  • 71

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 sayssay 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?

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 says 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?

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?

Missing bracket
Source Link
István Zachar
  • 47.2k
  • 20
  • 145
  • 293

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 MathematicaMathematica to choke when given it onto Integrate and eventually saysays 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, MathematicaMathematica 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[1NIntegrate[
     Sqrt[1 + E^tt^2 Sin[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 MMMathematica understand it just needs to buckle down and calculate?

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 it on 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 MM understand it just needs to buckle down and calculate?

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 says 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?

Source Link
Emilio Pisanty
  • 10.3k
  • 1
  • 37
  • 71

Numerical solution of a differential equation with NIntegrate coefficients

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 it on 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 MM understand it just needs to buckle down and calculate?