one equation with one unknown variable

Hello,
I want to solve equation with one unknown variable (x).
Matlab code: Editor: function y = f(x)
y=(18/5)*((1-x)^(-1/6))-(162/29)*((1-x)^(-1/9));
Command window: x=fzero(@f,[0,1])
(x should be between 0 and 1)
And the error is: ??? Error using ==> fzero at 283 The function values at the interval endpoints must differ in sign.
What should I do to solve that equation correctly?
And help will be appreciated.

 Akzeptierte Antwort

Konstantinos Sofos
Konstantinos Sofos am 15 Mär. 2015
Bearbeitet: Konstantinos Sofos am 15 Mär. 2015

0 Stimmen

Hi,
fzero checks that fun(x0(1)) and fun(x0(2)) have opposite signs, and errors if they do not. In you example the upper bound gives NaN
>> y=@(x)(18/5)*((1-x)^(-1/6))-(162/29)*((1-x)^(-1/9))
y =
@(x)(18/5)*((1-x)^(-1/6))-(162/29)*((1-x)^(-1/9))
>> y(0)
ans =
-1.9862
>> y(1)
ans =
NaN
Regards

Weitere Antworten (1)

Roger Stafford
Roger Stafford am 15 Mär. 2015

2 Stimmen

I would recommend that you alter the interval:
x=fzero(@f,[0,.999999]);
There is an easier way of solving it. Substitute t = (1-x)^(-1/18) and get an equation in t, which can be easily solved. From that you can get back to a solution for x.

4 Kommentare

John D'Errico
John D'Errico am 15 Mär. 2015
As Roger points out, the transformation is the correct way to do it - a slam dunk solution.
Lojzika
Lojzika am 15 Mär. 2015
Thank you for your answer
John D'Errico
John D'Errico am 15 Mär. 2015
I am confused as to why you would accept the other answer as this is so clearly the correct one. Oh well, Roger's answer got my vote.
Konstantinos Sofos
Konstantinos Sofos am 15 Mär. 2015
@John D'Errico could you explain us also why my answer is not valid or the correct one? Do we have any competition here or shall we try to provide our view? I am sorry for your comment...

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Computational Geometry finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by