r - 在数学函数中插入数学函数
问题描述
我想要:
- 将(函数)参数插入到数学函数中
- 以代数方式简化结果表达式
例子
func1 <-function(x,y) {
return((x^3-3*x*y))
}
#input x=1/n and y=1/n
#the desired result should be
#1st: (1/n)^3-3*(1/n)*(1/n)
#2nd: 1/n^3 - 3/n^2 = 1/n^2*(1/n - 3)
有任何想法吗?
解决方案
尝试这个:
library(Ryacas)
n <- ysym("n")
x <- 1/n
y <- 1/n
simplify(x^3-3*x*y)
## y: ((-3)*n^3+n^2)/n^5
推荐阅读
- android - 自动单击警报对话框按钮
- python - 如何通过 API 从 DocuSign 提取新员工信息?
- android - 如何按日期删除表值以与 RoomData Base 中的当前日期进行比较?
- mysql - Wso2 与 azure 中的 Mysql 连接(SSL 连接)
- php - 查找数组中记录的唯一和重复
- java - 在main方法中,为什么可以调用同一个类的构造函数呢?
- javascript - 在组件重新加载时未调用 React componentDidMount
- php - 需要 MVC 的分页脚本
- automationanywhere - 使用 Automation Anywhere 的 RTC Jazz 服务器用户登录
- python - 每次我运行应用程序时都会出现“RuntimeError:生成器引发 StopIteration”。(没有任何作用)