I am trying to integrate blackbody radiation law under 1500 Kelvin using the FormulaData command.

The integration seems not to work properly after I designate the integration range. Mathematica does not return me the numeric value that I want, and there is no error message popping up. So I guess my command is actually not a problem?

Is it because Mathematica simply cannot handle this kind of complicated integration?

f = FormulaData[
      {"PlanckRadiationLaw", "Wavelength"}, 
      {"T" -> Quantity[1500, "Kelvins"]}

N[ Integrate[ f[[2]], {λ, 1*^-6, 10*^-6} ] ]

output1 output2


1 Answer 1


There are two issues here:

The first one is that the result of FormulaData is given in terms of QuantityVariable objects. Change them to normal symbols:

f = FormulaData[{"PlanckRadiationLaw", "Wavelength"}, {"T" -> Quantity[1500, "Kelvins"]}];
expr = f[[2]] /. QuantityVariable["\[Lambda]", "Wavelength"] -> lambda;

The second is that you should use Quantity values for the limits of integration:

N[Integrate[expr, {lambda, Quantity[1, "Micrometers"], Quantity[10, "Micrometers"]}]]
(* Quantity[87362.1, ("Kilograms")/("Seconds")^3] *)
  • 1
    $\begingroup$ Thank you very much! It does work. uh, but it is a little bit strange, because I wrote my code based on the document of FormulaData and Quantity: link, link. If you scroll down those two webpages, you will find some examples (and even exactly the blackbody radiation problem). It seems that those examples didn't change the output type of FormulaData and did directly use numbers to designate the integration limit (not Quantity). They worked however. So what is the difference $\endgroup$
    – Juicyzzz
    Commented Feb 2, 2023 at 20:05
  • 1
    $\begingroup$ The examples you mention use a slightly different, but equivalent, method. Instead of changing QuantityVariable[...] by lambda and giving limits Quantity[1, "Micrometers"], etc, they change QuantityVariable[...] by Quantity[lambda, "Micrometers"] and then lambda has limits 1, etc. It doesn't matter where we give the units (either in the rule or in the integration limits), but those units must be given. A physical variable (the QuantityVariable[...] object returned by FormulaData) must be replaced by values (i.e. Quantity values) with units. $\endgroup$
    – jose
    Commented Feb 2, 2023 at 20:25
  • 1
    $\begingroup$ Sorry for the late reply because I have been busy these days...Yes, I think your answer is very helpful, where I learned that FormulaData returns a physical variable and requires both a unit and value. To prepare the returned formula for later use and manipulate the returned value, I need to somehow apply the desired quantity to the returned formula and "extract" the desired quantity for later use. Thanks for your illuminating advice! $\endgroup$
    – Juicyzzz
    Commented Feb 4, 2023 at 8:41

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.