企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
本文最初写于 2010-07-21于 sohu 博客,这次博客搬家一起搬到这里来。 版权所有,转载请注明出处。 # 一般的代数方程 solve (expr, x) solve (expr) solve ([eqn_1, ..., eqn_n], [x_1, ..., x_n]) 几个例子: solve (asin (cos (3*x))*(f(x) - 1), x); ![](https://box.kancloud.cn/2016-01-24_56a4233db2117.PNG) [4*x^2 - y^2 = 12, x*y - x = 2]; solve (%, [x, y]); ![](https://box.kancloud.cn/2016-01-24_56a4233dc1c87.PNG) # 多项式方程 realroots 计算多项式方程的数值解. realroots (expr, bound) realroots (eqn, bound) realroots (expr) realroots (eqn) 几个例子: realroots (-1 - x + x^5, 5e-6); realroots (expand ((1 - x)^5 * (2 - x)^3 * (3 - x)), 1e-20); ![](https://box.kancloud.cn/2016-01-24_56a4233dd08c5.PNG) allroots 计算多项式方程的全部解. allroots (expr) allroots (eqn) 几个例子: eqn: (1 + 2*x)^3 = 13.5*(1 + x^5); soln: allroots (eqn); ![](https://box.kancloud.cn/2016-01-24_56a4233ddc4c1.PNG) # 二分法求数值解 find_root (expr, x, a, b) find_root (f, a, b) 几个例子: find_root (sin(x) - x/2, x, 0.1, %pi); find_root (sin(x) = x/2, x, 0.1, %pi); ![](https://box.kancloud.cn/2016-01-24_56a4233de9c78.PNG) f(x) := sin(x) - x/2; find_root (f(x), x, 0.1, %pi); ![](https://box.kancloud.cn/2016-01-24_56a4233e0297d.PNG) # 牛顿迭代法 newton (expr, x, x_0, eps) mnewton (FuncList,VarList,GuessList) newton 用来解方程,mnewton 用来解方程组 几个例子: load (newton1)$ newton (cos (u), u, 1, 1/100); ![](https://box.kancloud.cn/2016-01-24_56a4233e16ed8.PNG) assume (a > 0); newton (x^2 - a^2, x, a/2, a^2/100); ![](https://box.kancloud.cn/2016-01-24_56a4233e24037.PNG) load("mnewton")$ mnewton([x1+3*log(x1)-x2^2, 2*x1^2-x1*x2-5*x1+1], [x1, x2], [5, 5]); ![](https://box.kancloud.cn/2016-01-24_56a4233e2fba8.PNG)   # 线性代数方程组 linsolve ([expr_1, ..., expr_m], [x_1, ..., x_n]) 几个例子: e1: x + z = y; e2: 2*a*x - y = 2*a^2; e3: y - 2*z = 2; linsolve ([e1, e2, e3], [x, y, z]); ![](https://box.kancloud.cn/2016-01-24_56a4233e3c9d1.PNG) # 多项式方程组 algsys ([expr_1, ..., expr_m], [x_1, ..., x_n]) algsys ([eqn_1, ..., eqn_m], [x_1, ..., x_n]) 几个例子: e1: 2*x*(1 - a1) - 2*(x - 1)*a2; e2: a2 - a1; ![](https://box.kancloud.cn/2016-01-24_56a4233e494f4.PNG) e3: a1*(-y - x^2 + 1); e4: a2*(y - (x - 1)^2); algsys ([e1, e2, e3, e4], [x, y, a1, a2]); ![](https://box.kancloud.cn/2016-01-24_56a4233e576cc.PNG)