This should be easy, and hopefully doable in Sympy.

I have a function: Y = 0.05*X + 0.15, which I define using Sympy:

from sympy import *
Y = 0.05*X + 0.15

How do I get the inverse, where I express X as a function of Y:

X = (Y-0.15)/0.15

推荐答案

You can use the solve function, but first, put your equation in the form f(x,y)=0:

Y = 0.05*X + 0.15
==> 0.05*X + 0.15 - Y = 0

So, you can solve it using:

 solve( 0.05*X + 0.15 - Y, X)

Which will give the solution:

[20.0*Y - 3.0]

Alternatively, you can solve the equation directly using the Eq function (which is used to define a symbolic equality):

solve( Eq(Y, 0.05*X + 0.15), X)

which will give the same answer:

[20.0*Y - 3.0]

Python相关问答推荐

在Python中使用yaml渲染(多行字符串)

用fft计算指数复和代替求和来模拟衍射?

如何将返回引用的函数与pybind11绑定?

是否将Pandas 数据帧标题/标题以纯文本格式转换为字符串输出?

如何通过函数的强式路径动态导入函数?

S最大值除以最小值,然后减1的结果是什么?

在Python Polar中从一个函数调用添加多个列

是否在DataFrame中将所有列设置为大写?

如何在上一次迭代中跳过某些内容(&q;)?

更改我的NN中的隐藏层数会导致错误

自由空间里的激光...以及我如何才能检测到Line以进行进一步计算?

考虑线宽的两个并排条形图

ImportError:在安装过程中找不到InstructorEmbedding的配置文件

没有目标的验证数据

新进程不会在运行FastApi的Docker中启动

基于条件的Pandas 数据框背景 colored颜色

如何在子窗口中正确设置和获取tkinter旋转框的值?

允许在枚举中使用一组特定的未定义值

将DF转换为特定的对象 struct

用动态规划法计算斐波那契曲线的命中次数