简体   繁体   中英

solving nonlinear equations in 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

Update:

w+x+y+1=3

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

w-x+y-1=4

thanks

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

This should work:

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

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

fsolve是一个不错的起点。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM