这里的初学者程序员希望编写一个可以简单地推导数学函数的函数.
Beginner programmer here looking to write a function that can simply derive a mathematical function.
该函数应这样运行:
f(x)= x ** 2 + 2 * x< ---用户输入
f(x) = x ** 2 + 2 * x <--- user input
f'(x)= 2 * x + 2
f'(x) = 2 * x + 2
我知道这里有Wolfram和Maple,但是我想编写自己的实际派生程序.我想知道这是否可能.
I know there's Wolfram and Maple, but I want to write my own actual derivative program. I would like to know if this is possible.
推荐答案这很可能是可行的,因为有很多程序可以进行符号区分.话虽这么说,这是不平凡的.对于上面的简单示例,您需要编写一个解析器,该解析器将:
It's obviously possible, as there are plenty of programs out there that do symbolic differentiation. That being said, it's non trivial. For your simple example above, you'd need to write a parser that would:
那只能处理这种非常基本的派生类型-没有链规则,乘积规则等,并且您必须分别实现它们.
That would only handle this very basic type of derivative - no chain rule, product rule, etc, and you'd have to implement each of those separately.
是的,绝对可行,但也很重要.
So yes, definitely doable, but also non-trivial.
更多推荐
在python中导出数学函数
发布评论