Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.4K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to integrate and plot equation below in short time?

Posted 10 years ago
POSTED BY: Ka Me
2 Replies
Posted 10 years ago

Hi Gianluca,

Thanks a lot for your reply. I have changed my script according to your suggestion and it is working much better now. The integral can be calculated and plotted in reasonable time, as you have written.

However, using the Manipulate function to adjust the fit is still not very comfortable, as Mathematica is running for a long time after moving one slider. I will see if I can directly use the NonlinearModelFit function.

Ka Me

POSTED BY: Ka Me

The function If is not well suited for symbolic computation. I would use something like Max instead. I doubt that those integrals can be computed symbolically. You can compute them numerically in a reasonable time:

e1[x_, \[Phi]r_] := Exp[I (x + \[Phi]r)];
e2[x_, \[Phi]p_, \[CapitalDelta]e_] := (1 + \[CapitalDelta]e) Exp[
    I (x + \[Phi]p)];
Int = (e1[x, \[Phi]r] + 
     e2[x, \[Phi]p, de]) Conjugate[(e1[x, \[Phi]r] + 
      e2[x, \[Phi]p, de])];
res1 = ExpToTrig[Simplify[Int]];
res2 = Simplify[res1 /. x -> 0];
\[Phi][t_, \[Phi]0_, n_] = Sqrt[Max[0, 1 - (Abs[t])^n]];
g[t_, de_, \[Phi]r_, a_, dt_, 
  n_] = (res2 /. \[Phi]p -> \[Phi][a (t + dt), \[Phi]0, n]); 
function[t_Real, w_, de_, \[Phi]r_, a_, dt_, n_] := 
 NIntegrate[
  g[s + t, de, \[Phi]r, a, dt, n]*Exp[-((s)/w)^2], {s, -w, w}];
Plot[function[t, 1, 0, 0, 1, 0, 2], {t, 0, 1}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard