R中方程组的求解

编程入门 行业动态 更新时间:2024-10-10 23:18:35
本文介绍了R中方程组的求解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可以使用Ryacas库在R中以符号方式求解方程式. 例如

Solving an equation symbolically can be achieved in R using the Ryacas library. For example

library(Ryacas) yacas("Solve(x/(1+x) == a, x)")

给予

expression(list(x == a/(1 - a)))

有人知道如何(象征性地)求解方程组吗?

Does anybody know how to (symbolically) solve a system of equations?

谢谢.

推荐答案

好吧,我使用出色的python库 sympy 进行符号计算.

Well, i use the excellent python library, sympy, for symbolic computation.

使用符号,直接求解方程组:

Using sympy, solving systems of equations straightforward:

>>> from sympy import * >>> x,y = symbols('x y') >>> solve([Eq(x + 5*y, 2), Eq(-3*x + 6*y, 15)], [x, y]) {y: 1, x: -3}

因此,除了通过python程序包外,这就是使用符号代数求解方程组的方法.

So that's how to solve a system of equations using symbolic algebra, except through a python package.

好消息是,有一个指向sympy的R端口,称为 rsympy ,可在CRAN或Google Code,此处.

The good news is that there's an R port to sympy, called rsympy, which is available on CRAN, or Google Code, here.

除了下载/安装rsympy并通过rsympy手册中的几个最简单的示例进行工作外,我从未使用过rsympy.在过去的三年中,我已经大量使用了原始的python库,因此我强烈推荐它.

I have never used rsympy, other than downloading/installing it and working through a couple of the simplest examples in the rsympy Manual. I have used the original python library a lot during the past three years and i can recommend it highly.

更多推荐

R中方程组的求解

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

发布评论

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

>www.elefans.com

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