溢出错误是格式不好的结果吗?

发布于 2025-02-01 09:06:26 字数 703 浏览 2 评论 0原文

函数我尝试复制:

”函数我试图复制“

为课程做一个项目,我需要在其中使黑体功能并以某种方式进行操作。 我正在尝试备用方程式,在做两个方程式中,我一直克服流量错误。

这是错误消息:

 alt2_2 = (1/((const_e**(freq/temp))-1))

OverflowError: (34, 'Result too large')

temp在kelvin中给出(im使用5800作为我的测试值,因为它大约是太阳的温度)

freq是光的速度由 在这种情况下输入的波长是什么波长,

freq = (3*(10**8))/wavelength

我都使用0.00000005作为波长的测试值。

和const e2.7182

首次使用堆栈。同样第一次自己做一个项目,任何帮助。

Function I tried to replicate:

Function I tried to replicate

doing a project for coursework in which I need to make the blackbody function and manipulate it in some ways.
I'm trying out alternate equations and in doing 2 of them i keep getting over flow error.

this is the error message:

 alt2_2 = (1/((const_e**(freq/temp))-1))

OverflowError: (34, 'Result too large')

temp is given in kelvin (im using 5800 as my test value as it is approximately the temp of the sun)

freq is speed of light divided by whatever wavelength is inputted

freq = (3*(10**8))/wavelength

in this case i am using 0.00000005 as the test value for wavelength.

and const e is 2.7182

first time using stack. also first time doing a project on my own, any help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱给你人给你 2025-02-08 09:06:26

这可以使用您的值进行黑体计算。

import math

# Planck constant
h = 6.6e-34
# Boltzmann constant
k = 1.38e-23
# Speed of light
c = 3e+8

# Wavelength
wl = 0.00000005
# Temp
T = 5800
# Frequency
f = c/wl

# This is the exponent for e (about 49).
k1 = h*f / (k*T)
# This computes the spectral radiance.
Bvh = 2*f*f*f*h / (math.exp(k1)-1)
print(Bvh)

输出:

9.293819741690355e-08

由于我们在进来时只使用了一个或两个数字,因此结果值仅对一两个数字有效,即9.3e-08。

This does the blackbody computation with your values.

import math

# Planck constant
h = 6.6e-34
# Boltzmann constant
k = 1.38e-23
# Speed of light
c = 3e+8

# Wavelength
wl = 0.00000005
# Temp
T = 5800
# Frequency
f = c/wl

# This is the exponent for e (about 49).
k1 = h*f / (k*T)
# This computes the spectral radiance.
Bvh = 2*f*f*f*h / (math.exp(k1)-1)
print(Bvh)

Output:

9.293819741690355e-08

Since we only used one or two digits on the way in, the resulting value is only good to one or two digits, 9.3E-08.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文