16

I am trying to find a numerical solution for an equation of the form:

$$ f(t) = \int_{t_{min}}^{t} \mathrm{d}t' {\exp[2 (t^\prime - t)] E(t^\prime) f(t^\prime)} + \int_{t}^{0}{\mathrm{d}t' \exp(t^\prime - t) E(t^\prime) f(t^\prime)} $$

where $E$ is the complete elliptic integral of the first kind and $t_{min}$ can be in principle any negative integer. I have tried NIntegrate and some iteration but didn't get me too far... can anyone help me with a better idea?

Thank you very much for your help!!!

mia
  • 361
  • 2
  • 9
  • you might want to look at http://mathematica.stackexchange.com/a/11609/1089 http://mathematica.stackexchange.com/questions/9544/integro-differential-equation – chris Dec 07 '12 at 06:19
  • @chris, I have already seen the links, but it seems that the standard methods to solve Fredholm equations somehow don't work in this case :(. can you be a little more explicit with your second suggestion? Thank you very much! – mia Dec 07 '12 at 06:32
  • @chris, I have tried your suggestion but the problem is that the function is very badly oscillating around $t=0$ and I am not really able to keep it under control. If you have time and if I am not asking too much, would you like try it out yourself and tell me how it looks like, in particular for small values of t? Thank you! – mia Dec 07 '12 at 07:33
  • The integral equation can be turned into the 2nd order DE, $f''(t)+3f'(t)+(2+E(t))f(t)=0$, (modulo mistakes) but the initial/boundary conditions are a little tricky to work out. – Simon Dec 07 '12 at 22:27
  • @Simon yes that's another venue. Do you know off hand if its generically better (say with mathematica) to solve the DE or the integral equation? – chris Dec 08 '12 at 07:55
  • @chris: No, I'm not particularly knowledgeable on the subject. mia, have you read http://www.mathematica-journal.com/issue/v9i2/IntegralEquations.html ? – Simon Dec 08 '12 at 09:52
  • @chris, I am also not an expert but I would think that DEs are far easier to handle as long as the BCs are good under control. – mia Dec 08 '12 at 10:07
  • @Simon, yes I have seen that but the 'problem' with this kind of standard text book examples is that they are designed to work, whereas in the real life the kernels are much more complicated; for example just now I am trying again to solve my equation as Fredholm eq and it breaks down due to the complexity of the kernel... – mia Dec 08 '12 at 10:11
  • mia, I find the implicit boundary conditions $f'(t_{min})=-f(t_{min})$ and $f'(0)=-2f(0)$, then NDSolve yields $f(t) \approx 0$. Did I make a mistake? – Simon Dec 08 '12 at 11:12
  • clearly $f(t)=0$ is a solution but it should not be the only one. I don't think you made a mistake, I would say you are missing the second solution. Unless I am doing something wrong, this should be a typical example of an equation where the trivial solution bifurcates away from the nontrivial one at some particular values of the parameters (which are of course not present in the above example). In mathematics this is called bifurcation theory, in the kind of physics I am interested in we call it dynamical gap generation :). – mia Dec 08 '12 at 11:35
  • However in order to appreciate the full complexity one should see the whole thing and not just a working example like we have here – mia Dec 08 '12 at 11:35
  • @Simon which is why algebraically you are looking for a non empty null space as a solution to the integral equation. May be you should write up the DE solution to the pb. – chris Dec 08 '12 at 14:06
  • as a quick example you might like to look at this f = u /. NDSolve[{u''[w] + 3 u'[w] + 2 u[w] + 0.3 u[w]/Sqrt[1^2 + u[w]^2] == 0, u[0] == 0.0002, u'[0] == -0.0003126}, u, {w, -100, 0}][[1]]; Plot[Exp[t] f[t], {t, -11, 0}] – mia Dec 08 '12 at 14:58
  • sorry I don't manage to get the formatting right – mia Dec 08 '12 at 15:03
  • this sort of eq is extremely sensible to boundary conditions (notice the number of digits in the derivative; try change the last ones and see what happens...) – mia Dec 08 '12 at 15:04

2 Answers2

13

This might help you get started. I think this is a variation on a method called Frobenius' method. The idea is to use the fact that the equation is linear to expand the solution over a set of basis functions (here B-Splines) and find the corresponding coefficients. It should provide you with an approximate solution (which you can improve upon while adding more Splines in your basis), provided the sought solution is smooth enough and the Kernel is regular enough.

Let us define some sampling for the sought solution

np = 5; tmin = -5; Δt = -tmin;
kfun[n_, d_] := Join[ConstantArray[0, d], Range[0, 1, 1/(n - d)],  ConstantArray[1, d]];
knots = tmin + Δt*kfun[np + 1, 3];

Let us format the unknown $F(t)$ represented by a sum of B-Splines

Format[a[i_]] = Subscript[a, i];
F[t_] = Sum[BSplineBasis[{3, knots}, i, t] a[i], {i, 0, np}]

and define the corresponding basis

Clear[basis];
basis[t_] = Table[BSplineBasis[{3, knots}, i, t], {i, 0, np}]

Let's show the basis just because we can:

Plot[basis[t] // Evaluate, {t, -5, 0}]

Mathematica graphics

Now your equation is (in terms of F[t]=f[t] EllipticK[t])

eqn = F[t]/EllipticK[t] == Integrate[Exp[2 (t - s)] F[s], {s, tmin, t}] +
   Integrate[Exp[(t - s)] f[s], {s, t, 0}]

It involves the convolution kernel

Kern[s_, t_] = 
 Piecewise[{{Exp[2 (s - t)], s < t}, {Exp[(s - t)], s > t}}]

Now let us define the matrix of dot products of our basis over the kernel K

M = 
 ParallelTable[NIntegrate[
   basis[t][[i + 1]] basis[s][[j + 1]] Kern[s, t], {t, tmin, 0}, {s, 
    tmin, 0}],
  {i, 0,np}, {j, 0,np}]

and the matrix of dot products of our basis (as it is not ortho-normal)

Q = ParallelTable[
  NIntegrate[
   basis[t][[i + 1]] basis[t][[j + 1]]/EllipticK[t] , {t, tmin, 0}],
  {i, 0,np}, {j, 0,np}]

Now let us look at the eigen-space of that equation

{eig, vec} = 
  Inverse[Q].M - IdentityMatrix[Length[Q]] // Eigensystem;

Our approximate solution is corresponds to the eigenvector with the smallest eigenvalue:

var = Table[a[i], {i, 0, np}]; ra = Thread[var -> Last[vec]];


Plot[F[t] /EllipticK[t] /. ra // Evaluate, {t, -5, 0}]

Mathematica graphics

Note that this solution is defined up to a (possibly negative) multiplicative constant.

chris
  • 22,860
  • 5
  • 60
  • 149
  • 1
    Thank you so much Chris! I am trying to continue along your idea but I am quite slow -- mathematica is not really my forte, I have resorted to it after having failed in fortran :(. It is very frustrating, as I am stuck in this equation since a while now... Again, thank you so very much for your help, I hope I will manage to get it done... – mia Dec 07 '12 at 11:08
  • Sorry for annoying you again, but it seems to be a problem with the null space, which is always empty regardless of the kernel (I have tried several). Do you know what is happening? – mia Dec 07 '12 at 14:53
  • I have also corrected some bugs in your code, still doesn't do, but I am very tired so maybe I just don't see things. Please let me know if you notice anything and again, thank you for taking so much time... – mia Dec 07 '12 at 18:09
  • Note that I was a bit optimistic to assume that the approximate solution (the sum of BSplines) was exactly in the NullSpace of Q-M. Now I just look to the closest null solution. – chris Dec 07 '12 at 19:40
  • Chris, I know this is not the right place to say thank you, but apparently mia is not able to post anymore (no idea why), so I am just going to say that your code works just beautifully! I had spotted a couple of things that needed to be corrected, but you did it before I have noticed the possibility of editing somebody else's answer :). Thank you! ps. this is another mia, I just opened another account -- for unknown reasons the old mia is not able to write comments anymore :) – mia Dec 07 '12 at 21:40
  • well if you like my answer you can 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2)Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign – chris Dec 07 '12 at 21:42
  • Did you check that the solution actually satisfies the integral equation? I am failing to verify this but may be I am getting tired :-) – chris Dec 07 '12 at 21:45
  • Thank you for the tips, I would be very happy if there is anything I can help with. – mia Dec 07 '12 at 21:48
  • yes, it does satisfy the equation :). Now I need to replace the kernel with the 'real thing' (the real physical interaction), hopefully it will work as well. – mia Dec 07 '12 at 21:50
  • it seems that I can add comments only to my 'answer', the one that I started here, otherwise I can only give feedback to a particular answer (as I said I have no idea what happened with the account I did this morning, but I cannot login anymore) -- this is probably very confusing :-) – mia Dec 07 '12 at 21:52
  • @mia: As you earn more reputation, you can do more in the site. Also, it looks like you've opened up two different accounts. I'll flag this to get fixed for you. – Simon Dec 07 '12 at 22:06
  • @mia It should now be fixed. – Mr.Wizard Dec 07 '12 at 22:15
  • thank you Simon & Mr.Wizard! mia is happy to return to her old identity :) – mia Dec 07 '12 at 22:34
5

The commenters got it almost solved, missing only that $t_{\text{min}}$ is an unknown instead of a parameter. The question should be: for what values of $t_{\text{min}}$ does the integral equation have a nontrivial solution?

As shown in the comments, the function satisfies

$$ [2 + E(t)] f(t) + 3 f'(t) + f''(t) = 0\\ 2 f(0) + f'(0) = 0\\ f(t_{\text{min}}) + f'(t_{\text{min}}) = 0 $$

All of these equations are linear, so the solution can be multiplied by an arbitrary scalar and still remains a solution. This last observation allows us to set $f(0)=1$ as an additional boundary condition. Together with the first two conditions above, we thus get the solution

sol = NDSolve[{(2 + EllipticE[t]) f[t] + 3 f'[t] + f''[t] == 0, 
               2 f[0] + f'[0] == 0, f[0] == 1}, f, {t, -10, 0}];
F = f /. First[sol];
Plot[F[t], {t, -10, 0}]

enter image description here

The allowed values for $t_{\text{min}}$ are those where this solution satisfies the third condition $f(t_{\text{min}}) + f'(t_{\text{min}}) = 0$:

Plot[F[tmin] + F'[tmin], {tmin, -10, 0}]

enter image description here

which we can find numerically:

FindRoot[F[tmin] + F'[tmin] == 0, {tmin, -0.7}]
(*    {tmin -> -0.657447}    *)

FindRoot[F[tmin] + F'[tmin] == 0, {tmin, -3}]
(*    {tmin -> -2.92468}    *)

FindRoot[F[tmin] + F'[tmin] == 0, {tmin, -5}]
(*    {tmin -> -4.95128}    *)

These are the "eigenvalues" of the given integral equation and represent the set of discrete values of $t_{\text{min}}$ for which the integral equation has a nontrivial solution. There are infinitely many of them, stretching towards $-\infty$.

Numerical Stability & Automatic Solving

The function $f(t)$ oscillates with exponentially increasing amplitude. To regularize the problem, we can introduce the function

$$ g(t) = e^{\frac32t}f(t) $$

which satisfies

$$ [E(t)-1/4] g(t) + g''(t)= 0\\ g(0) + 2g'(0) = 0\\ g(t_{\text{min}}) - 2g'(t_{\text{min}}) = 0 $$

Solving for $g(t)$ gives a regularly oscillating function:

sol = NDSolve[{(EllipticE[t] - 1/4) g[t] + g''[t] == 0,
               g[0] + 2 g'[0] == 0, g[0] == 1}, g, {t, -20, 0}];
G = g /. First[sol];
Plot[G[t], {t, -20, 0}]

enter image description here

As @J.M. points out, WhenEvent can be used to extract the allowed values for $t_{\text{min}}$ directly,

sol = NDSolve[{(EllipticE[t] - 1/4) g[t] + g''[t] == 0, 
               g[0] + 2 g'[0] == 0, g[0] == 1, 
               WhenEvent[g[t] - 2 g'[t] == 0, Print[t]]},
              g, {t, -20, 0}];

(*    -0.657447
      -2.92468
      -4.95128
      -6.83972
      -8.63254
      -10.353
      -12.0157
      -13.6306
      -15.2049
      -16.744
      -18.2522
      -19.7327    *)

Use a Sow/Reap combination instead of Print in order to use these values later in a calculation.

Roman
  • 47,322
  • 2
  • 55
  • 121