0
$\begingroup$

When I execute the following code, Mathematica returns a blank plot. What is the problem?

es[e1_, w2_, δx_, δy_, x_, y_] = 
  e1*Exp[-((x - δx)^2 + (y - δy)^2)/w2^2]*Exp[I*ω*t];
el1[e2_, wl2_, x_, y_, t_, β_, Ω_] = 
  e2*Exp[-(x^2 + y^2)/wl2^2]*Exp[I*β*Sin[Ω*t]]*Exp[I*ω*t];

sum[e1_Real, w2_Real, δx_Real, δy_Real, e2_Real, 
   wl2_Real, t_Real, r_real, β_Real, Ω_Real] := 
  NIntegrate[(Abs[es[e1, w2, δx, δy, x, y] + 
       el1[e2, wl2, x, y, t, β, Ω]])^2, {x, 0, r}, {y, -(r^2 - x^2)^0.5, (r^2 - x^2)^0.5}];
Plot[sum[3, 0.00015, 0, 0, 100, 0.00015, t, 0.005, 0, 0], {t, 0, 1}]
$\endgroup$

closed as off-topic by m_goldberg, MarcoB, Michael Seifert, Itai Seggev, Bob Hanlon Jul 16 '17 at 5:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, MarcoB, Michael Seifert, Itai Seggev, Bob Hanlon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ There is a mistake in one of the arguments of sum, it should be r_Real. Also, in the plot you call sum with Integer arguments. Make it real by adding a . next to the integer. There is an undefined variable $\omega$ in the definitions of es and es11. $\endgroup$ – Anjan Kumar Jul 14 '17 at 7:38
  • $\begingroup$ I recommend that you use the form e1_?NumericQ NumericQ encompasses Reals, Integers, Rationals, Complexes, and numeric constants (e.g., E, Pi). $\endgroup$ – Bob Hanlon Jul 16 '17 at 5:14
2
$\begingroup$

There are a fearful number of syntax errors in your code. Here is your code corrected for those errors.

Clear[es, el1]
es[e1_, w2_, δx_, δy_, x_, y_, t_, Ω_] := 
  e1*Exp[-((x - δx)^2 + (y - δy)^2)/w2^2]*Exp[I*Ω*t]
el1[e2_, wl2_, x_, y_, t_, β_, Ω_] := 
  e2*Exp[-(x^2 + y^2)/wl2^2]*Exp[I*β*Sin[Ω*t]]*Exp[I*Ω*t]
Clear[sum]
sum[e1_Real, w2_Real, δx_Real, δy_Real, e2_Real, 
    wl2_Real, t_Real, r_Real, β_Real, Ω_Real] := 
  NIntegrate[
    (Abs[es[e1, w2, δx, δy, x, y, t, Ω] + el1[e2, wl2, x, y, t, β, Ω]])^2, 
    {x, 0, r}, {y, -(r^2 - x^2)^0.5, (r^2 - x^2)^0.5}]

 Plot[sum[3, 0.00015, 0., 0., 100., 0.00015, t, 0.005, 0., 0.], {t, 0., 1.}]

plot

$\endgroup$

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