在python中导出数学函数

在python中导出数学函数

本文介绍了在python中导出数学函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的初学者程序员希望编写一个可以简单地推导数学函数的函数.

Beginner programmer here looking to write a function that can simply derive a mathematical function.

该函数应这样运行:

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:

  1. 分解多项式的每个项
  2. 解析该术语并将其分解为系数,变量和指数
  3. 应用电源规则
  4. 将输出串在一起

那只能处理这种非常基本的派生类型-没有链规则,乘积规则等,并且您必须分别实现它们.

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中导出数学函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 00:50