I have the following formula

\[HBar] = hbar = (6.6260693*joule*sec)/(10^34*(2*Pi)); 

chp[Te_, ne_, 
  M_] := (1.3806505*(joule/kelvin)*Te*kelvin*
    Log[1 - Exp[-((2*Pi*hbar^2*

chp[50, 1, 0.5]

(* 6.90325*10^-22 joule Log[
  1 - E^(-((5.55596*10^-6 joule sec^2)/(cm^2 kg)))] *)

My question is what is the best way to have an output that is in eV. Please note that the argument of the Exp is unitless...even though it is expressed in terms of cm, kg etc. So the output should only be in terms of eV.

  • $\begingroup$ Have you looked into Quantity and UnitConvert? $\endgroup$ Nov 9, 2015 at 5:07
  • $\begingroup$ Yes.....just how do you use them for this particular relation.....in a neat way. I can do it ...a bit messily $\endgroup$
    – thils
    Nov 9, 2015 at 5:12

2 Answers 2


You could do this using Quantity and UnitConvert, and defining your units beforehand.

kelvin = Quantity[1, "Kelvins"];
joule = Quantity[1, "Joules"];
\[HBar] = hbar = Quantity[1, "ReducedPlanckConstant"];
cm = Quantity[1, "Centimeters"];
kg = Quantity[1, "Kilograms"];
chp[Te_, ne_, 
  M_] := (1.3806505*(joule/kelvin)*Te*kelvin*
    Log[1 - Exp[

UnitConvert[chp[50, 1, 0.5], "Electronvolts"]

results in

Quantity[-0.0125725, "Electronvolts"]
  • $\begingroup$ Thks, I have modified my code to include "DimensionlessUnit"...this was what I was looking for...useful in calculations involving several related formulas. $\endgroup$
    – thils
    Nov 9, 2015 at 6:33
  • $\begingroup$ @Michael Witt I had to wrap the argument of the exponent in the chp function with UnitConvert[-((2*Pi*hbar^2...] in order to get it to work. $\endgroup$ Nov 9, 2015 at 19:31
  • $\begingroup$ @JackLaVigne Yeah, for some reason it ran when I tested it initially, but didn't run now. I've updated my solution to include the UnitConvert in the argument of the exponential. $\endgroup$ Nov 10, 2015 at 17:53

Found out that "DimensionlessUnit" would help greatly, so the code is

\[HBar] = hbar = (6.6260693*10^-34)/(2 \[Pi]); (* Joule*Second*)

chp1[Te_] := 
 UnitConvert[Quantity[1.3806505*10^-23 Te, "Joule"], 

chp2[Te_, ne_, M_] := 
 chp1[Te]*Log[1 - Exp[-UnitConvert[ Quantity[(2 Pi hbar^2  ne 10^11)/
 (4 M 9.1093826*(10^-31) Te 1.3806505*(10^-23) ), "Joules"*"Seconds"^2
  /("Centimeters"^2*"Kilograms")], Quantity["DimensionlessUnit"]]]]

chp2[50, 1, 0.5]
 (* - 0.0125725 eV *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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