2
$\begingroup$

enter image description here

Can anyone help on this ?

I did this

c = 2.998 10^8;
h = 6.62607015 10^-34;
Kb = 1.380649 10^-23;


i[\[Lambda]_,
   T_] := ((2 Pi h c^2)/(\[Lambda]^5 (Exp[(h c)/(\[Lambda] Kb T)] -
      1)));


M = Plot[i[\[Lambda], 3000], {\[Lambda], 0, 2.5 10^-6},
   PlotRange -> Automatic,
   PlotStyle -> {Thickness [0.005], Green},
   Filling -> Axis, FillingStyle -> Green ];

N = [i[\[Lambda], 4000], {\[Lambda], 0, 2.5 10^-6},
   PlotRange -> Automatic ,
   PlotStyle -> {Thickness [0.005], Blue, Dashed},
    Filling -> Axis];

O =  [i[\[Lambda], 5000], {\[Lambda], 0, 2.5 10^-6},
   PlotRange -> Automatic ,
   PlotStyle -> {Thickness [0.005], Orange}];

Show[M , N , O, GridLines -> Automatic , PlotRange -> Automatic ,
  Frame -> True , AxesLabel -> {\[Lambda][m], (watts/m^3)},
  Epilog -> {Insert [
     Framed[Style["T=3000K", 10], Background -> White], {8.23 10^-7,
      5.42 10^13}],
    Insert [
     Framed[Style["T=4000K", 10], Background -> White], {8.23 10^-7,
      1.64 10^13}],
    Insert [
     Framed[Style["T=5000K", 10], Background -> White], {8.75 10^-7,
      3.90 10^13}]}] // Quiet

and I get this "is too small to represent as a normalized machine number; precision
may be lost". Can anyone help please

$\endgroup$
7
  • 1
    $\begingroup$ Looks like a homework question. Post the code you have tried. $\endgroup$ Feb 27, 2021 at 21:02
  • 2
    $\begingroup$ Have you already seen PlanckRadiationLaw[]? $\endgroup$ Feb 27, 2021 at 21:03
  • 2
    $\begingroup$ I would recommend not using capital letters to start your symbol names. N, for example, is a built-in which I would definitely not want to overwrite. $\endgroup$ Feb 28, 2021 at 15:28
  • $\begingroup$ Still not working :( $\endgroup$
    – user77551
    Feb 28, 2021 at 15:34
  • 1
    $\begingroup$ I guess I meant it should have been an edit. $\endgroup$
    – Michael E2
    Feb 28, 2021 at 23:45

2 Answers 2

6
$\begingroup$

This is a possibility for what you want:

c = 2.998  10^8 ;
h = 6.62607015 10^-34 ;
Kb = 1.380649 10^-23 ;


i[l_, T_] := (2 Pi h c^2)/(l^5 (Exp[(h c)/(l Kb T)] - 1));


Plot[{i[l, 3000], i[l, 4000],i[l, 5000]}, {l, 0, 2.5 10^-6}, PlotRange -> All]// Quiet

enter image description here

I added //Quiet in the end because it complained about having to deal with such small numbers.

For styling the plot (color, filling, labeling...) you should take a look at the options of the Plot function in the documentation. Ask if you need any help with that.

$\endgroup$
4
  • $\begingroup$ yes please, I did it first and kept getting failed and now I'm getting an empty graph, I'm sorry if it's to much but I'm new to this :( $\endgroup$
    – user77551
    Feb 27, 2021 at 22:34
  • $\begingroup$ @user77551 To get the exact graph you want, simply copy the code I wrote and add more options, like Filling-> Axis, Frame-> True and so on. You can find all the options of the Plot function very easily in the documentation. If your code isn't working, I think it's better if you post it here so people can point out what you're doing wrong. $\endgroup$ Feb 28, 2021 at 0:38
  • $\begingroup$ Also, pay attention to the fact that you defined your constants wrong, you can't use "x" as "times" because it will be interpreted as a variable. Same thing goes for the units. Notice how the constants are defined in the code I posted. $\endgroup$ Feb 28, 2021 at 2:10
  • $\begingroup$ I keep getting this massage " is too small to represent as a normalized machine number; precision" , Can I show my work and you tell me where is the mistake ? $\endgroup$
    – user77551
    Feb 28, 2021 at 8:24
3
$\begingroup$

You have a number of problems in your code.

Mathematica reserves uppercase N and O, you can't reassign them (well, at least not easily). You don't really need them.

Your code doesn't define 3 plots, so the Show can't show 3 curves. That said you can avoid the Show completely.

Also, you've used Insert instead of Inset in the Epilog assignments.

c = 2.998 10^8;
h = 6.62607015 10^-34;
Kb = 1.380649 10^-23;

i[\[Lambda]_,
   T_] := ((2 Pi h c^2)/(\[Lambda]^5 (Exp[(h c)/(\[Lambda] Kb T)] -
      1)));

Plot[{i[\[Lambda], 3000], i[\[Lambda], 4000], 
   i[\[Lambda], 5000]}, {\[Lambda], 0, 2.5*10^-6},
  PlotRange -> All,
  PlotStyle -> {
    {Thickness[0.005], Green},
    {Thickness[0.005], Blue, Dashed},
    {Thickness[0.005], Orange}},
  Frame -> True,
  FrameLabel -> {"\[Lambda][m]", "(watts/m^3)"},
  Filling -> {2 -> Axis, 3 -> 2},
  FillingStyle -> {1 -> None, 2 -> Automatic, 3 -> Orange},
  GridLines -> Automatic,
  
  Epilog -> {
    Inset[
     Framed[Style["T=3000K", 10], Background -> White], {8.23*10^-7, 
      0.75*10^13}], 
    Inset[Framed[Style["T=4000K", 10], 
      Background -> White], {8.23*10^-7, 1.64*10^13}], 
    Inset[Framed[Style["T=5000K", 10], 
      Background -> White], {8.75*10^-7, 3.90*10^13}]}
  ] // Quiet

enter image description here

You need to do some additional formatting of the Epilog style and the placement, but I'll leave that to you.

$\endgroup$

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.