7
$\begingroup$

There have been numerous times when I've needed to invert an integral equation, i.e. I have something like $$f(x) = g_1(x)\int_{0}^x g_2(x') dx'$$ for arbitrary functions $g_1$ and $g_2$, and I would like to find $x$ for a given $f$. The way I've gotten around this is just making some sort of table of f(x) and x with spacing up to some required precision. Is there a more efficient method of doing it (numerically or analytically)?

When I try to use NSolve[ f(x) == a, x ] mathematica complains NIntegrate::nlim: x = x is not a valid limit of integration.

$\endgroup$
9
$\begingroup$

My interpretation of the question is that you want to find $x$ for given $f$, $g_2$ and $g_1$. Then just define $F=f/g_1$ and differentiate with respect to $x$ on both sides:

$\frac{d}{dx}F(x)=g_2(x)$

Now solve this equation for $x$. There's no integration involved.

$\endgroup$
  • 2
    $\begingroup$ Just implemented this and it works well. Using a simple finite-difference routine to calculate the derivative of 'F' is computationally trivial compared to the iterative numerical integrations. $\endgroup$ – DilithiumMatrix Apr 22 '12 at 4:59
  • $\begingroup$ I tried to implement this using ND and FindRoot, but I am getting strange problems. Maybe I need to ask a separate question. $\endgroup$ – Santi Aug 15 '14 at 11:59
  • $\begingroup$ Here is the separate question: mathematica.stackexchange.com/questions/57435/… $\endgroup$ – Santi Aug 19 '14 at 9:53
5
$\begingroup$

Answering your comment:

f[x_?NumericQ] := f[x] = g1[x] NIntegrate[g2[t], {t, 0, x}];
g1[x_] := Sin[x]; g2[x_] := Cos[x];
k = FindRoot[f[x] == Pi/9, {x, 1}]
Pi/9 - f[x] /. k[[1]]
(*
->
{x -> 0.632072}
-5.55112*10^-17
*)
$\endgroup$
  • $\begingroup$ Thanks @belisarius, but my g2 can't be integrated numerically. I.E. I have something like `f[x_]:=g1[x]*NIntegrate[g2[t],{t,0,x}]' and I get the above error $\endgroup$ – DilithiumMatrix Apr 21 '12 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.