简体   繁体   English

使用 sympy 求解方程,python

[英]Using sympy to solve an equation, python

I want to solve the below using Pythons sympy module instead of adapting what if have hand written.我想使用 Pythons sympy 模块来解决以下问题,而不是调整手写内容。 The result is x=26.8.结果是 x=26.8。

在此处输入图像描述

Any help appreciated.任何帮助表示赞赏。

Tks Tks

EDIT:编辑:

my equation without sympy:我没有同情的方程式:

def cal_equ(total_vel=1.23, vel_vent_mg=17.74, vel_vent_tg=28.45, const=105):
    a = (const / vel_vent_tg / const) + (1 / vel_vent_mg)
    b = (total_vel - const / vel_vent_tg)
    return b / a
from sympy import *
# create a symbol: it represents your unkown
x = symbols("x")
# create your constants
total_vel=1.23
vel_vent_mg=17.74
vel_vent_tg=28.45
const=105
# there are many ways to create an equation.
# here we create an equality, something that states that
# the left hand side is equal to the right hand side
eq = Eq((const - x) / vel_vent_tg - x / vel_vent_mg, total_vel)
# finally, we use the solve function to solve for the equation for x
sol = solve(eq, x)
sol[0].n()
# out: 26.8871034856029

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM