Guest User

Untitled

a guest
Jan 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. f = (1 + Exp[-(Sqrt[x*x + M*M] - mu)/T])
  2.  
  3. CForm[D[f, M]]
  4.  
  5. -((Power(E,(mu - Sqrt(Power(M,2) + Power(x,2)))/T)*M)/
  6. (T*Sqrt(Power(M,2) + Power(x,2))))
  7.  
  8. ClearAll[foo]
  9. foo = RawBoxes[Replace[ToBoxes@#, InterpretationBox[a_, b_, c___] :>
  10. With[{aa = StringReplace[a,
  11. { "Sqrt" -> "sqrt", "Power(E," -> "exp(", "Power" -> "pow"}]}, aa],
  12. {0, Infinity}]] &;
  13.  
  14. foo@CForm[D[f, M]]
  15.  
  16. Unprotect[Power];
  17. Format[Power[E, a_], CForm] := exp[a]
  18. Format[Power[a_, 1/2], CForm] := sqrt[a]
  19. Format[Power[a_, b_], CForm] := pow[a, b]
  20. Protect[Power];
  21.  
  22. D[f, M] //CForm
Add Comment
Please, Sign In to add comment