Mathematica Asked by leosenko on December 18, 2020
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.
"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.
Answered by Jack LaVigne on December 18, 2020
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}
Answered by bbgodfrey on December 18, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP