Unknown x: x+1=1 in machine numbers

How do I set unknown variable x to find the largest x for which x + 1 = 1 in Matlab?

댓글 수: 2

JIM
JIM 2012년 11월 2일
Yeah but if I want the smaller x for whick x=x+1? Is the same? And the largest x is the eps(y) for every y for which x+y=y?
Thank you for your answer!

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt Fig
Matt Fig 2012년 11월 2일

0 개 추천

x = eps(1)/2;
If x is larger than this, 1+x>1.

댓글 수: 11

JIM
JIM 2012년 11월 2일
편집: Matt Fig 2012년 11월 2일
So..
x=eps(1)
while x+1>1;
x=x/2;
end
And I found the x?
EDITED by Matt Fig.... simply highlight the code and press the {} Code button...
Oh, you didn't say you were trying to get to this number by calculation! Sure:
x = 1;
while x+1>1
x = x/2;
end
JIM
JIM 2012년 11월 2일
편집: JIM 2012년 11월 2일
OK..Therefore:
x=y;
while x+y>y;
x=x/2;
end
for every y?
And for the smaller x for which
x+9999=x
which x we put on original value? (
while x+9999<x;
x=x/2;?
)
Matt Fig
Matt Fig 2012년 11월 2일
Dude, please take the time to use the {} Code button!
JIM
JIM 2012년 11월 2일
Sorry..
Matt Fig
Matt Fig 2012년 11월 2일
편집: Matt Fig 2012년 11월 2일
Naw, that won't get it. You will have to zoom in on it once you find the x such that x/2+y is not greater than y.
JIM
JIM 2012년 11월 2일
편집: JIM 2012년 11월 2일
Do you mean:
x=y;
while x+y<y;
x=x/2;
end
This is not correct
I think that the correct code for the largest x is this:
x=5000;
while x+5000>5000;
x=x/2;
end
Right?
What do you mean "the largest x"? That code returns a number that is not the largest x one can add to 5000 such that: (x+5000)==5000
The largest number x one can add to any y such that
(x+y)==y % is x=eps(y)/2
So this is how you check your code..
JIM
JIM 2012년 11월 2일
I mean the largest number x that recognized by "my" computer for which x+5000=x (so the x is a very small number and I try to find this small number)
Matt Fig
Matt Fig 2012년 11월 3일
Like I said, you will get close with the code I gave you above, then you can zoom in by looking at smaller differences than x/2. Is this homework?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

JIM
2012년 11월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by