0
$\begingroup$

This should be straightforward, but I'm getting errors hereClearAll["Global`*"]

ClearAll["Global`*"]

h = QuantityMagnitude[UnitConvert[Quantity["PlanckConstant"], "SIBase"]];
c = QuantityMagnitude[UnitConvert[Quantity["SpeedOfLight"], "SIBase"]];
k = QuantityMagnitude[UnitConvert[Quantity["BoltzmannConstant"], "SIBase"]];

(*B and V filters*)
Bmin = (440 - 50)*10^-9;
Bmax = (440 + 50)*10^-9;
Vmin = (550 - 50)*10^-9;
Vmax = (50 + 50)*10^-9;

B[λ_, T_] := (2 h c^2)/λ^5 1/(E^((h c)/(λ k T)) - 1)
fb[T_] = NIntegrate[B[λ, T], {λ, Bmin, Bmax}]
fv[T_] = NIntegrate[B[λ, T], {λ, Vmin, Vmax}]

(*NIntegrate produces errors here*)

bvu = -2.5 Log10[fb[T]/fv[T]]

bv[T_] = bvu[T] - bvu[10^4]

FindRoot[bv[t] == 0.8, {t, 5000}]
$\endgroup$

closed as off-topic by J. M. will be back soon Mar 10 at 6:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – J. M. will be back soon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ You define fb with = (called Set). When doing that the right hand side is evaluated as part of the assignment. If you use := (called SetDelayed), the right hand side is evaluated only when the function is called (hopefully with a numerical value passed for T). You should write fb[T_?NumericQ] := NIntegrate[...] $\endgroup$ – Coolwater Feb 7 at 18:59
1
$\begingroup$
ClearAll["Global`*"]

h = QuantityMagnitude[
   UnitConvert[Quantity["PlanckConstant"], "SIBase"]];
c = QuantityMagnitude[UnitConvert[Quantity["SpeedOfLight"], "SIBase"]];
k = QuantityMagnitude[
   UnitConvert[Quantity["BoltzmannConstant"], "SIBase"]];

(*B and V filters*)
Bmin = (440 - 50)*10^-9;
Bmax = (440 + 50)*10^-9;
Vmin = (550 - 50)*10^-9;
Vmax = (50 + 50)*10^-9;



B[λ_, T_] := (2 h c^2)/λ^5 1/(E^((h c)/(λ k T)) - 1)
fb[T_?NumericQ] := NIntegrate[B[λ, T], {λ, Bmin, Bmax}]
fv[T_?NumericQ] := NIntegrate[B[λ, T], {λ, Vmin, Vmax}]
bvu[T_] := -2.5 Log10[fb[T]/fv[T]]
bv[T_] := bvu[T] - bvu[10^4]


Plot[bv[t] - 0.8, {t, 0, 16000}] // Quiet

enter image description here

 FindRoot[bv[t] == 0.8, {t, 15000}] // Quiet

{t -> 15321.8 - 1.35*10^-11 I}

FindRoot[bv[t] == 0.8, {t, 100}] // Quiet

{t -> 269.09 + 1.58244*10^-13 I}

$\endgroup$

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