help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to find polynomial roots in OCTAVE?help...


From: John B. Thoo
Subject: Re: how to find polynomial roots in OCTAVE?help...
Date: Wed, 27 Jun 2007 12:09:48 -0700

Hi, Henry. When I tried your example, the "plot" choked on me (see below). Any ideas? I'm using 2.1.73 on Mac OS X 10.4.9.

octave:1> function [y] = f(x)
> y=x^(4/3)-21.3*x^(1/3)-4.53^(4/3);
> end
octave:2> f(0)
ans = -7.4954
octave:3> x = linspace (-100, 100, 1000);
octave:4> plot (x, f(x))
error: for A^b, A must be square
error: evaluating binary operator `^' near line 2, column 4
error: evaluating binary operator `-' near line 2, column 10
error: evaluating binary operator `-' near line 2, column 23
error: evaluating assignment expression near line 2, column 2
error: called from `f'
error: evaluating argument list element number 2
octave:4> [X, INFO, MSG] = fsolve ('f', 10)
X = 23.902
INFO = 1
MSG = solution converged within specified tolerance

Thanks.
---John.


On Jun 15, 2007, at 6:39 PM, Henry F. Mollet wrote:

fsolve was suggested and it works.
octave:10> function [y]=f(x)
y=x^(4/3)-21.3*x^(1/3)-4.53^(4/3);
end
octave:11> f(0)
ans = -7.4954

octave:20> x=linspace(-100,100,1000);
octave:21> plot (x,f(x))
Shows that good initial value is important. x=0 won't do.

octave:22> [X, INFO, MSG] = fsolve ('f', 10)
X = 23.902
INFO = 1
MSG = solution converged within specified tolerance
Henry


on 6/14/07 7:57 PM, jub at address@hidden wrote:




James Sherman Jr.-2 wrote:

 then just have y^3 = x;


you mean y^(1/3)=x is it? yeah the 'h' is the 'x', sorry :-P


reply via email to

[Prev in Thread] Current Thread [Next in Thread]