I am reading a paper on High Harmonics Generation (HHG) and a Lewenstein model The paper is here. I would like to reproduce some results but I am stuck at the following problem. I have: $$p(\tau_b,\tau)=\frac{e}{\tau-\tau_b}\int_{\tau_b}^\tau {\rm d}\tau^{'} A(\tau^{'})\,,$$ where $A(\tau)$ is vector potential (given).

The time of birth $t_b$ as a function of $\tau$ is determined by solution of the algebraic equation: $$p(\tau_b,\tau)-e \, A(\tau_b)=0$$

How should I approach solving such an equation. I was thinking:

A[t_] := -Sin[t];
τ = 0.5;
FindRoot[NIntegrate[A[t], {t, τb, τ}]/(τ - τb) - 
A[τb] == 0, {τb, 1}]

But Mathematica keeps saying

t = τb is not a valid limit of integration

Maybe there is an error in my solution. But besides making it work with Mathematica specific approach, what would a more general numerical approach be for such a solution?

Thank you.

  • 2
    $\begingroup$ A[t_] := -Sin[t]; k[s_?NumericQ] := NIntegrate[A[t], {t, s, tau}]; tau = 0.5; FindRoot[k[tb]/(tau - tb) - A[tb] == 0, {tb, 1}] $\endgroup$ Dec 14, 2015 at 21:24
  • $\begingroup$ This prior thread might give some indication of why this happens. In short, these are warning messages from attempts at symbolic preprocessing. To avoid that one can do, for example, In[27]:= rootfunc[\[Tau]b_?NumberQ] := NIntegrate[A[t], {t, \[Tau]b, \[Tau]}]/(\[Tau] - \[Tau]b) - A[\[Tau]b] FindRoot[rootfunc[\[Tau]b] == 0, {\[Tau]b, 1}] Out[28]= {\[Tau]b -> 0.5} $\endgroup$ Dec 14, 2015 at 21:26
  • 1
    $\begingroup$ Properly, if A is known this is not an integral equation. $\endgroup$
    – george2079
    Dec 14, 2015 at 21:45
  • $\begingroup$ @george2079 Thank you for clarification. Is there a special name to such a problem if $A$ is known? $\endgroup$
    – atapaka
    Dec 14, 2015 at 22:39

2 Answers 2


"FindRoot first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically" is written in the documentation in the Details and Options section.

The reason

A[t_] := -Sin[t]
τ = 0.5;
FindRoot[NIntegrate[A[t], {t, τb, τ}]/(τ - τb) - A[τb] == 0, {τb, 1}]

doesn't work is because it attempts to evaluate

NIntegrate[A[t], {t, τb, τ}]

symbolically which fails.

Using belisarius's solution

k[s_?NumericQ] := NIntegrate[A[t], {t, s, τ}]
FindRoot[k[τb]/(τ - τb) - A[τb] == 0, {τb, 1}]

works because k[τb] can be evaluated symbolically simply giving back k[τb].

When numerical evaluation is applied the function definition is used enabling

NIntegrate[A[t], {t, s, τ}]

to be evaluated.


As noted by Jack LaVigue, FindRoot by default tries first to evaluate its first argument symbolically, which fails here. However, it is possible to instruct FindRoot not to do so by employing the option Evaluated -> False.

A[t_] := -Sin[t];
τ = 0.5;
FindRoot[NIntegrate[A[t], {t, τb, τ}]/(τ - τb) - A[τb] == 0, {τb, 1}, Evaluated -> False]

FindRoot returns without error the not particularly interesting but correct answer {τb -> 0.5}. With an initial guess of 2, it instead returns {τb -> 2.0984}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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