[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to find polynomial roots in OCTAVE?help...
From: |
Henry F. Mollet |
Subject: |
Re: how to find polynomial roots in OCTAVE?help... |
Date: |
Wed, 27 Jun 2007 13:50:04 -0700 |
User-agent: |
Microsoft-Entourage/11.1.0.040913 |
Sorry, I must have corrected to
y=x.^(4/3)-21.3*x.^(1/3)-4.53^(4/3);
because I had no problem with
plot (x, f(x))
but then copied the incorrect first y(x) used when posting.
Henry
on 6/27/07 12:52 PM, James Sherman Jr. at address@hidden wrote:
> The problem isn't with plot, I think. Its that you have
> x^(1/3) and x^(4/3)
> and you have x as a row vector, which will try to calculate the matrix
> exponential and thus fail since x isn't square (hence the error message).
>
> Just replace all ^ with .^ (elementwise exponential) and this should solve
> your problem.
>
> James
>
> On 6/27/07, John B. Thoo <address@hidden> wrote:
>>
>> 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
>> _______________________________________________
>> Help-octave mailing list
>> address@hidden
>> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave