指数函数中是否有固定字符?

发布于 2025-01-30 18:59:45 字数 412 浏览 4 评论 0原文

我想使用sympy解决这个问题。

[将加热至100度的铜球以30度放入水中,3分钟后,铜球的温度下降至70度。找到铜球温度降至31度所需的时间。根据实验,铜球的温度变化速率与温度和环境温度之间的差异成正比。]

因此,我构建了该方程式和条件。

[t:球的温度// t:时间[m] // a:比例常数] [dt/dt = -a(t -30),t(0)= 100,t(3)= 70]

,我的代码如下...

T = symbols('T', cls=Function)
t = symbols('t')
a = symbols('a')
deqn = Eq(T(t).diff(t), -a*(T(t)-30))
dsolve(deqn) # general solution

以上的一般解决方案是:

I want to solve this problem using the sympy.

[a copper ball heated to 100 degrees was placed in water at 30 degrees, and after 3 minute, the temperature of the copper ball dropped to 70 degrees. Find the time it takes for the temperature of the copper ball to drop to 31 degrees. According to the experiment, the temperature change rate of the copper ball is proportional to the difference between the temperature and the ambient temperature.]

So, I built this equation and conditions.

[T : the temperature of the ball // t : time [m] // a : proportional constant]
[dT/dt = -a(T-30), T(0)=100, T(3)=70]

And my code is as follows...

T = symbols('T', cls=Function)
t = symbols('t')
a = symbols('a')
deqn = Eq(T(t).diff(t), -a*(T(t)-30))
dsolve(deqn) # general solution

The general solution of the above is : ????(????)=????1????−????????+30

dsolve(deqn, ics={T(0):100}) #particular solution by boundary condition

And the particular solution is : ????(????)=30+70????−????????

Now, I think I need to using this equation to find the value of 'a' due to T(3)=70.

C = Eq(30+70*exp(-a*t),30)
solve(C)

But, the error occurs...

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [122], in <cell line: 1>()
----> 1 C = Eq(30+70*exp(-a*t),30)
      2 solve(C)

TypeError: bad operand type for unary -: 'list'

I don't know what the problem is...

is there a set character when using 'exp'?

please..help...me....

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

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

发布评论

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

评论(1

呆萌少年 2025-02-06 18:59:45

您可能有一个旧版本的sympy版本,该版本曾经在列表中返回符号。检查类型(a)是列表。如果是正确的,请使用Sympy的较新版本,或使用符号创建单个符号,或解开列表a = A =符号('a')[0]

如果不是问题,请确保将31放置为第二个arg c(每个问题描述,否则eq将是false)。然后使用solve(c,t),否则它可能会尝试解决a的求解。

You might have an old version of sympy that used to return symbols in a list. Check type(a) is list. If it is True, then use a newer version of SymPy, or use Symbol to create a single symbol, or unpack the list a = symbols('a')[0].

If that is not the issue, make sure to put 31 as the 2nd arg for C (per problem description, else the Eq will be False). And then use solve(C, t) or else it might try solve for a.

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