在python中导出数学函数

编程入门 行业动态 更新时间:2024-10-27 22:26:16
本文介绍了在python中导出数学函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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中导出数学函数

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

    发布评论

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

    >www.elefans.com

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