求解Octave中的非线性方程组

Dot*_*Net 1 math matlab octave

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

x^4-16x^3+61x^2-22x-12=0
Run Code Online (Sandbox Code Playgroud)

更新:

w+x+y+1=3

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

w-x+y-1=4
Run Code Online (Sandbox Code Playgroud)

谢谢

Ste*_*fin 5

使用fzero最接近得到解决给定的x0(当然,不一定是最接近的,但第一个发现的):

这应该工作:

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

此外,您应该检查roots,以获得多项式的所有解.

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

好的,所以无论如何我都会回答第二个问题:

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
Run Code Online (Sandbox Code Playgroud)