如何在Python中求解方程式?

编程入门 行业动态 更新时间:2024-10-26 21:21:57
本文介绍了如何在Python中求解方程式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设我有一个方程:

2x + 6 = 12

借助代数,我们可以看到x = 3.如何使用Python编写可以解决x的程序?我是编程的新手,我看过eval()和exec(),但是我不知道如何使它们按我的意愿去做.我不想使用外部库(例如SAGE),我只想在纯Python中做到这一点.

With algebra we can see that x = 3. How can I make a program in Python that can solve for x? I'm new to programming, and I looked at eval() and exec() but I can't figure out how to make them do what I want. I do not want to use external libraries (e.g. SAGE), I want to do this in just plain Python.

推荐答案

SymPy 怎么样?他们的求解器看起来像您所需要的.如果您想自己构建库,请查看它们的源代码.

How about SymPy? Their solver looks like what you need. Have a look at their source code if you want to build the library yourself…

更多推荐

如何在Python中求解方程式?

本文发布于:2023-11-29 18:35:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647257.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方程式   如何在   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!