
python sumpy.diff()函数(求导数或偏导?)
发布日期:2021-05-10 09:13:18
浏览次数:22
分类:精选文章
本文共 2063 字,大约阅读时间需要 6 分钟。
from sympy/core/function.py
def diff(f, *symbols, **kwargs): """ Differentiate f with respect to symbols. This is just a wrapper to unify .diff() and the Derivative class; its interface is similar to that of integrate(). You can use the same shortcuts for multiple variables as with Derivative. For example, diff(f(x), x, x, x) and diff(f(x), x, 3) both return the third derivative of f(x). You can pass evaluate=False to get an unevaluated Derivative class. Note that if there are 0 symbols (such as diff(f(x), x, 0), then the result will be the function (the zeroth derivative), even if evaluate=False.将f用符号区分。 这只是统一.diff()和Derivative类的包装器; 它的接口类似于Integrated()的接口。 您可以对多个变量使用与“衍生”相同的快捷方式。 例如,diff(f(x),x,x,x)和diff(f(x),x,3)都返回f(x)的三阶导数。 您可以传递validate = False来获得未评估的派生类。 请注意,如果有0个符号(例如diff(f(x),x,0)),那么即使评估= False,结果也将是该函数(零导数)。 Examples ======== >>> from sympy import sin, cos, Function, diff >>> from sympy.abc import x, y >>> f = Function('f') >>> diff(sin(x), x) cos(x) >>> diff(f(x), x, x, x) Derivative(f(x), (x, 3)) >>> diff(f(x), x, 3) Derivative(f(x), (x, 3)) >>> diff(sin(x)*cos(y), x, 2, y, 2) sin(x)*cos(y) >>> type(diff(sin(x), x)) cos >>> type(diff(sin(x), x, evaluate=False))>>> type(diff(sin(x), x, 0)) sin >>> type(diff(sin(x), x, 0, evaluate=False)) sin >>> diff(sin(x)) cos(x) >>> diff(sin(x*y)) Traceback (most recent call last): ... ValueError: specify differentiation variables to differentiate sin(x*y) Note that ``diff(sin(x))`` syntax is meant only for convenience in interactive sessions and should be avoided in library code. References ========== http://reference.wolfram.com/legacy/v5_2/Built-inFunctions/AlgebraicComputation/Calculus/D.html See Also ======== Derivative idiff: computes the derivative implicitly """ if hasattr(f, 'diff'): return f.diff(*symbols, **kwargs) kwargs.setdefault('evaluate', True) return Derivative(f, *symbols, **kwargs)
发表评论
最新留言
关注你微信了!
[***.104.42.241]2025年04月06日 23时26分35秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
如何使用linux系统自带的led驱动
2021-05-10
泛知识类视频会改变短视频行业格局吗?
2021-05-10
IP-Guard回收客户端加密授权,已经加密的文档如何解密
2021-05-10
IP-GUARD支持的数据库版本
2021-05-10
IP-Guard文档权限管理,让核心数据使用更安全
2021-05-10
ip-guard加密在OFFICE文档里插入图片提示错误
2021-05-10
a*算法伪代码及实现
2021-05-10
第十一节 IO编程
2021-05-10
十八、flask之g对象
2021-05-10
GIT学习笔记
2021-05-10
Linux系统调用过程
2021-05-10
stm32 uv5打开uv4工程错误
2021-05-10
mysql怎么终止一个事务_MySql 中游标,事务,终止存储过程方法总结
2021-05-10
SmartRefreshLayout 上拉加载下拉刷新
2021-05-10
app:processDevDebugResources
2021-05-10
最基础的urllib.request.urlopen()基本使用
2021-05-10
C# 异常
2021-05-10
vs 设置静态库输出路径
2021-05-10
strlen sizeof 快
2021-05-10