# LogLogPlot errors

Posted 9 years ago
5374 Views
|
3 Replies
|
2 Total Likes
|
 I have been experiencing the following problems with Mathematica 9 and also Mathematica 10: ClearAll["Global*"]; (* obtain constants *) h = QuantityMagnitude[ UnitConvert[Quantity["PlanckConstant"], "SIBase"]]; kB = QuantityMagnitude[ UnitConvert[Quantity["BoltzmannConstant"], "SIBase"]]; c = QuantityMagnitude[UnitConvert[Quantity["SpeedOfLight"], "SIBase"]]; rIn = QuantityMagnitude[ UnitConvert[Quantity[0.1, "AstronomicalUnit"], "SIBase"]]; rOut = QuantityMagnitude[ UnitConvert[Quantity[10, "AstronomicalUnit"], "SIBase"]]; r0 = QuantityMagnitude[ UnitConvert[Quantity[0.1, "AstronomicalUnit"], "SIBase"]]; \[Lambda]Low = 1*10^-6;(* Meters *) \[Lambda]High = 10*10^-6;(* Meters *) T0 = 1000; \[Alpha] = -3/4; a = T0/r0^\[Alpha]; F\[Lambda][\[Lambda]_] := NIntegrate[ 4 \[Pi]*(h*c^2)/\[Lambda]^5*r/( Exp[(h*c)/(\[Lambda]*kB*a*r^\[Alpha])] - 1), {r, rIn, rOut}]; LogLogPlot[ F\[Lambda][\[Lambda]], {\[Lambda], \[Lambda]Low, \[Lambda]High}] Now this returns: NIntegrate::inumr: The integrand (7.483543*10^-16 r)/((-1+E^((3.36356*10^-13 r^(3<<1>><<1>>))/\[Lambda])) \[Lambda]^5) has evaluated to non-numerical values for all sampling points in the region with boundaries {{1.49598*10^10,1495978707000}}. >> NIntegrate::inumr: The integrand (7.483543*10^-16 r)/((-1+E^((3.36356*10^-13 r^(3<<1>><<1>>))/\[Lambda])) \[Lambda]^5) has evaluated to non-numerical values for all sampling points in the region with boundaries {{1.49598*10^10,1495978707000}}. >> NIntegrate::inumr: The integrand (7.483543*10^-16 r)/((-1+E^((3.36356*10^-13 r^(3<<1>><<1>>))/\[Lambda])) \[Lambda]^5) has evaluated to non-numerical values for all sampling points in the region with boundaries {{1.49598*10^10,1495978707000}}. >> General::stop: Further output of NIntegrate::inumr will be suppressed during this calculation. >> And then the plot. But if I use Plot instead of LogLogPlot, there are no errors.I could redefine the function: F\[Lambda][\[Lambda]_?NumericQ] := NIntegrate[ 4 \[Pi]*(h*c^2)/\[Lambda]^5*r/( Exp[(h*c)/(\[Lambda]*kB*a*r^\[Alpha])] - 1), {r, rIn, rOut}]; which really hides the errors but I am more interested why this problem happens. Because NumericQ is not always the good solution. What if I want to pass infinity which does not evaluate true as NumericQ or if I am using units!
3 Replies
Sort By:
Posted 9 years ago
 You need a "NumericQ" checkup here in the example. Here is an article in the Wolfram Knowledge Base.
Posted 9 years ago
 As I have mentioned at the end of the post, "NumericQ is not always the good solution. What if I want to pass infinity which does not evaluate true as NumericQ or if I am using units!"
Posted 9 years ago
 The solution is quite similar though. You just need to overload the definitions of the function under different inputs. F\[Lambda][Quantity[\[Lambda]_?NumericQ, _]] := NIntegrate[ 4 \[Pi]*(h*c^2)/\[Lambda]^5* r/(Exp[(h*c)/(\[Lambda]*kB*a*r^\[Alpha])] - 1), {r, rIn, rOut}]; `