I want to do 2nd derivative of the function f1 w.r.t l and then integrate the function w.r.t. l1. Actually both the functions contain same set of variables (l,Eg,Ry and L). But to use f1''[l] syntax, I had to remove the other variables from the f1. But the same variables has to be used in f2[]. Below shows the code that I was trying to run:

f1[l_] := -Exp[-4 Log[2] (1240/l1 - 1240/l)^2/(L)^2] (
      2 Pi 1240)/(l1^2 (1 - Exp[-((2 Pi)/Sqrt[(1240/l1 - Eg)/Ry])]))

f2[l_, Eg_, l1_, L_] := NIntegrate[
   f1''[l], {l1, 1240/(Eg + 0.0001), 1240/(Eg + 1.25)}

Somehow the integration variable l1 in f2 is same as in f1. But I want to use all four variables in f2.

I have also tried to put the derivative function directly into f2; but in that case, I got NIntegrate::izero error from the NIntegrate.

f3[λ_, Eg_, λ1_, L_] := NIntegrate[
 -(-(( 2 4 Log[2] (1240)^2/(L L))/λ^4) - ((
        4 4 Log[2] (1240)^2/(L L))/λ^3) (1/λ - 1240/
         l1) + (4 Log[2] (1240)^2/(L L))^2/λ^4 (1/λ - 
          1240/l1)^2) (
   Exp[-4 Log[2] (1240)^2/(L L) (1/λ - 1240/l1)^2] 1240)/(
   l1^2 (1 - 
      Exp[(-2 Pi Sqrt[Eg - 1240/λ1])/
       Sqrt[1240/l1 - Eg]])), {l1, 1240/(Eg + 0.0001), 1240/(Eg + 2)}]

Plot[f3[l, 1.928, 674, 0.08], {l, 500, 700}]

Please help.

  • $\begingroup$ In f2 you try to use l1 both as a local variable and as an iterator variable. To see the problem, evaluate this: Clear[f,x]; f[x_] := Table[x, {x, 1, 2}];f[2]. $\endgroup$ – Alan Jun 17 '18 at 14:46

Your Answer

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

Browse other questions tagged or ask your own question.