如何使用R编程进行代数除法?

huangapple go评论98阅读模式
英文:

How to do algebraic division with R programming?

问题

I've looked everywhere here and here, but none of the answers match what I want. My question is like this.

what I want. My question is like this.

3xy : 2y

The answer I want is 3x/2

My attempt code is like this:

x <- 2/3
y <- x
cat("mark x:", x, "\n")
cat("mark y:", y, "\n")

Thank you, any answer would be appreciated.

英文:

I've looked everywhere here and here, but none of the answers match what I want. My question is like this.

what I want. My question is like this.

3xy : 2y

The answer I want is 3x/2

My attempt code is like this:

x &lt;- 2/3
y &lt;- x
cat(&quot;mark x:&quot;, x, &quot;\n&quot;)
cat(&quot;mark y:&quot;, y, &quot;\n&quot;)

Thank you, any answer would be appreciated.

答案1

得分: 3

使用 Ryacas,您可以执行以下操作:

library(Ryacas)

yac_str("Simplify(3*x*y/(2*y))")
# "(3*x)/2"
英文:

With Ryacas you can do:

library(Ryacas)

yac_str(&quot;Simplify(3*x*y/(2*y))&quot;)
# &quot;(3*x)/2&quot;

huangapple
  • 本文由 发表于 2023年6月26日 07:53:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552846.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定