1
$\begingroup$

When trying to Plot the function

1/(1 + E^(((e + Quantity[-7.05, "Electronvolts"]) 
  *(Quantity[1, 1/("BoltzmannConstant")]))/T))

I get an incorrect plot looking likeincorrect Plot

However, if I first evaluate the points with Table and then use ListLinePlot it works as expected

correct Table@ListPlot

$\endgroup$
  • 2
    $\begingroup$ I'm not sure why you want to keep the units in the definition of f, but the following works: f[e_, T_] := 1/(1 + E^(((e + -7.05)*1)/T)). A good start when Plot returns an empty plot is to evaluate the function for some arbitrary values. Try and you'll understand why nothing plots. $\endgroup$ – anderstood Mar 27 '18 at 20:27
  • $\begingroup$ If you really must have units: With[{T = 5000}, Plot[1/(1 + E^(((Quantity[e, "Electronvolts"] + Quantity[-7.05, "Electronvolts"])*(Quantity[1, 1/("BoltzmannConstant")]))/Quantity[T, "Kelvins"])) // Evaluate, {e, 1, 20}]] $\endgroup$ – J. M. will be back soon Mar 28 '18 at 1:13
  • 1
    $\begingroup$ @anderstood Whenever Plot returns nothing I always evaluate the function for arbitrary values. That's why, after Plot failed, I replaced Plot with Table. As you can see, evaluating the function for arbitrary values in Table works. And when I ListPlot those arbitrary values, the function works. My question was why Plot fails when the function successfully evaluates for arbitrary values. $\endgroup$ – Max Coplan Mar 28 '18 at 10:35

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.