【问题标题】:Retrieve integral expression of a function检索函数的积分表达式
【发布时间】:2018-10-23 18:54:40
【问题描述】:

Base R 提供了一个函数D(),它输出给定函数的导数表达式。

例如:

f <- expression(x^3+2*x)
D(f, "x") # with respect to x
# 3 * x^2 + 2

是否有类似的函数可以产生函数积分的表达式?

我知道stats::integrate() 会计算给定区间内函数的积分,但据我所知,它不会输出积分的表达式。

【问题讨论】:

标签: r integral derivative


【解决方案1】:

正如cmets中提到的,包Ryacas可以做不定积分:

library(Ryacas)
x = Sym('x')
f = expression(x^3 + 2*x)
Integrate(f, x)
## expression(x^4/4 + x^2)

因为differentiation is mechanics, integration is art.

【讨论】:

    猜你喜欢
    • 2022-10-04
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多