0
$\begingroup$

I'm trying to plot this function without any success, any help is more than welcome. The function f contains a sum of integral which depends on T and then the function g is a derivative of the function f Thank you very much.

An = 10^-10;
amu = 1.660539 10^-27 ;                                             
μ = 132.905451/2 amu;
Subscript[N, a] = 6.0221409 10^23;
m = 4 μ;
Subscript[ω, e] = 28.8918*100;
r = 5.3474208 An;
c = 2.99792 10^8;
h = 6.6260755  10^-34;
De = 2722.28*100*h*c;
hbar = h/(2 π);
kb = 1.38064852 10^-23;
R = 8.314511;
λ = (hbar α)^2/(2 μ);
a = μ/(hbar α)^2 De (Exp[2 α r] - 1);
b = 1/2 (1 - Sqrt[
 1 + (8 μ De (Exp[α r] + 1)^2)/(hbar α)^2]);
Subscript[k, 1] = a/b - b/2;
v = 207;
Subscript[k, 2] = a/(v + 1 + b) - (v + 1 + b)/2;
Subscript[A,1] = -π c Subscript[ω, e] r Sqrt[(2 μ)/De]
Exp[-π c Subscript[ω, e] r Sqrt[(2 μ)/De]];
α = π c Subscript[ω, e] Sqrt[(2 μ)/De] + 1/r (1 - Log[1 + Log[1 + Subscript[A, 1]]]/(2 + Log[1 + Subscript[A, 1]])) Log[1 + Subscript[A, 1]];
 f[T_] := 2 Sum[
NIntegrate[
 Exp[-(1/(kb T)) (De - λ (a/(x + b) - (x + b)/2)^2)] Cos[
   2 π i x], {x, 0, v + 1}, Method -> "LocalAdaptive"], {i, 1,
  20}];
 g[T_] := kb T^2 D[Log[f[T]], T];  
Plot[g[T], {T, 0, 100}]
$\endgroup$
1
  • 4
    $\begingroup$ Before you can plot the function, you need to make sure it works... Try g[1], which just falls over $\endgroup$
    – ktm
    Commented Nov 20, 2019 at 17:12

1 Answer 1

1
$\begingroup$
Clear["Global`*"]

An = 10^-10;
amu = 1.660539 10^-27;
μ = 132.905451/2 amu;
Subscript[N, a] = 6.0221409 10^23;
m = 4 μ;
Subscript[ω, e] = 28.8918*100;
r = 5.3474208 An;
c = 2.99792 10^8;
h = 6.6260755 10^-34;
De = 2722.28*100*h*c;
hbar = h/(2 π);
kb = 1.38064852 10^-23;
R = 8.314511;
λ = (hbar α)^2/(2 μ);
a = μ/(hbar α)^2 De (Exp[2 α r] - 1);
b = 1/2 (1 -
     Sqrt[1 + (8 μ De (Exp[α r] + 1)^2)/(hbar α)^2]);
Subscript[k, 1] = a/b - b/2;
v = 207;
Subscript[k, 2] = a/(v + 1 + b) - (v + 1 + b)/2;
Subscript[A, 1] =
  -π c Subscript[ω, e] r Sqrt[(2 μ)/De];
Exp[-π c Subscript[ω, e] r Sqrt[(2 μ)/De]];
α = π c Subscript[ω, e] Sqrt[(2 μ)/De] +
   1/r (1 - Log[1 + Log[1 + Subscript[A, 1]]]/
       (2 + Log[1 + Subscript[A, 1]]))*
    Log[1 + Subscript[A, 1]];

f[T_?NumericQ] := 2 Sum[
    NIntegrate[
     Exp[-(1/(kb T))*
        (De - λ (a/(x + b) - (x + b)/2)^2)]*
      Cos[2 π i x], {x, 0, v + 1},
     Method -> "LocalAdaptive"], {i, 1, 20}];

Needs["NumericalCalculus`"]

g[T_?NumericQ] := kb T^2 ND[Log[f[t]], t, T];

Module[{y},
 Plot[{Re[y = g[T]], Im@y}, {T, 0, 100},
  PlotLegends -> Placed[{Re, Im}, {0.25, 0.25}]]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you very much $\endgroup$ Commented Nov 21, 2019 at 4:53

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.