0
$\begingroup$
m0 = 0.0055;    
Gs = 10.08;
Gv[x_] := x*Gs ;
M[\[Sigma]_] := m0 - Gs \[Sigma];
Ep[\[Sigma]_, p_] := (M[\[Sigma]]^2 + p^2)^(1/2)
\[Mu]e[n_, \[Mu]_, x_] := \[Mu] - Gv[x]*n; 

fn[\[Sigma]_?NumericQ, n_?NumericQ, T_?NumericQ, \[Mu]_?NumericQ, 
x_?NumericQ] := -  (6 /\[Pi]^2) T NIntegrate[ 
p^2 (Log[1 + Exp[-(( Ep[\[Sigma], p] - \[Mu]e[n, \[Mu], x])/T)]] + 
  Log[1 + Exp[-(( Ep[\[Sigma], p] + \[Mu]e[n, \[Mu], x])/
      T)]]), {p, 0, \[Infinity]}, AccuracyGoal -> 5]

dfnd\[Mu][\[Sigma]_?NumericQ, n_?NumericQ, 
T_?NumericQ, \[Mu]_?NumericQ, x_?NumericQ] := 
D[fn[\[Sigma], n, T, \[Mu]d, x], \[Mu]d] /. {\[Mu]d -> \[Mu]}

dfndT[\[Sigma]_?NumericQ, n_?NumericQ, T_?NumericQ, \[Mu]_?NumericQ, 
x_?NumericQ] := D[fn[\[Sigma], n, Td, \[Mu], x], Td] /. {Td -> T}

dfnd\[Mu][-0.03, 0.05, 0.1, 0.1, 0.2]    

dfndT[-0.03, 0.05, 0.1, 0.1, 0.2]

I have defined the function as fn, which contains NIntegrate. Now I can take derivative with respect to \mu but cannot with respect to T. What am I missing here? Here I have slightly redefined the question.

$\endgroup$
6
  • $\begingroup$ Try: fn[s_?NumericQ, n_?NumericQ, x_?NumericQ] := 5 s^2 - n^2 - (6/(\[Pi]^2)) NIntegrate[p^2*Sqrt[p^2 + s^2], {p, 0, 0.65}] $\endgroup$
    – rmw
    Feb 19, 2019 at 13:04
  • $\begingroup$ Possible duplicate: mathematica.stackexchange.com/a/26037/193 $\endgroup$
    – Michael E2
    Feb 20, 2019 at 2:17
  • $\begingroup$ I know that ?NumericQ attribution helps to avoid the 'NIntegrate::inumr' warning while performing the NIntegrate. But I cannot take the derivative without getting the warning. I want to avoid the warning while taking the derivative. That is my concern. $\endgroup$ Feb 20, 2019 at 13:10
  • $\begingroup$ Works for me: i.stack.imgur.com/omopl.png -- Please clarify if ?NumericQ does not fix the problem as shown the link. $\endgroup$
    – Michael E2
    Feb 21, 2019 at 2:00
  • $\begingroup$ It fixes the problem. $\endgroup$ Feb 21, 2019 at 11:57

1 Answer 1

1
$\begingroup$
fn[s_, n_, x_] := 5 s^2 - n^2 - (6/(\[Pi]^2))* Integrate[p^2*Sqrt[p^2 + s^2], {p, 0, 0.65}]

dfndT[sd_, n_, x_] := D[fn[s, n, x], s] /. {s -> sd}

dfndT[-0.03, 0.05, 0.2]

-0.296174

fn[s_?NumericQ, n_, x_] :=  5 s^2 - n^2 - (6/(\[Pi]^2))*
NIntegrate[p^2*Sqrt[p^2 + s^2], {p, 0, 0.65}]

dfndT[sd_, n_, x_] := D[fn[s, n, x], s] /. {s -> sd}

dfndT[-0.03, 0.05, 0.2]
$\endgroup$
2
  • $\begingroup$ @ChowdhuryAminulIslam I have used NIntegrate too $\endgroup$
    – zhk
    Feb 20, 2019 at 13:31
  • $\begingroup$ Thanks for your help. That worked. Now I have redefined the problem. Please have a look. $\endgroup$ Feb 21, 2019 at 16:37

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