在八度中求解非线性方程 [英] solving nonlinear equations in Octave

查看:73
本文介绍了在八度中求解非线性方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Octave的新手,想知道如何求解非线性方程.这是一个示例方程式

I am new to Octave and would like to know how to solve nonlinear equation. Here is an example equation

x^4-16x^3+61x^2-22x-12=0

更新:

w+x+y+1=3

2w+3x+4y+5=10

w-x+y-1=4

谢谢

推荐答案

使用 fzero 以获得最接近给定x0的解决方案(当然,不一定最接近,但找到的第一个):

Use fzero to get the solution closest to a given x0 (well, not necessarily closest, but the first one found):

这应该有效:

x0 = 0;
f = @(x) x^4 - 16*x^3 + 61*x^2 - 22*x - 12;
fzero(f,x0);
ans =  0.76393

此外,您还应签出 roots ,以获取多项式的所有解.

Also, you should check out roots, to get all the solutions of a polynomial.

x = [1 -16 61 -22 -12];  % The coefficients of your polynomial
y = roots(x)
y = 
   10.29150
    5.23607
    0.76393
   -0.29150

好,所以我还是要回答第二个问题:

Ok, so I'll answer the second question anyway:

x = [1 1 1; 2 3 4; 1 -1 1]; % Coefficients of w, x and y
y = [2; 5; 5];              % [3-1; 10-5; 4+1]

b = x\y
b =
   2.2500
  -1.5000
   1.2500

这篇关于在八度中求解非线性方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆