How can I do if one Numbers is irrational?

조회 수: 4 (최근 30일)
yogan sganzerla
yogan sganzerla 2015년 6월 27일
댓글: Steven Lord 2015년 6월 29일
Hello Everybody,
I have one problem, I to do if one number is irrational or rational.
For exemplo:
I have 'pi' the answer is 'irrational'
But If I have '2345/1000' it's a 'rational'
Please Help me!
  댓글 수: 4
Walter Roberson
Walter Roberson 2015년 6월 28일
What is the input form?
Steven Lord
Steven Lord 2015년 6월 29일
Every finite double precision number you can represent in MATLAB is rational. [If you wanted to consider Inf as 1/0, -Inf as -1/0, and NaN as 0/0 and stretch the definition of rational not to exclude 0 denominators, then you could call them "rational" as well.] This includes the double precision number returned by the MATLAB function PI, which is an approximation to the ratio of a circle's circumference and its diameter.
If you had a symbolic object that you constructed WITHOUT first approximating the quantity to test as a double ... then it's still an unsolved problem, as the cyclist noted.

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

답변 (1개)

the cyclist
the cyclist 2015년 6월 28일
If you find such a program, enter pi * e and tell us if it is rational or irrational. You will be famous. (See, e.g., List of unsolved problems in mathematics.)
(I believe that determining whether a number is rational or irrational is an "NP-hard" problem.)
  댓글 수: 2
yogan sganzerla
yogan sganzerla 2015년 6월 28일
Ow!
But My teacher asked to me.....Because will fall in the text!
Walter Roberson
Walter Roberson 2015년 6월 28일
You need to answer the question about what the form of the input is. For example. For example do you need to be able to say that sqrt(4) is rational but sqrt(5) is irrational? How about
5^(1/2)
and
5^-.5
? And how about
sin(pi/6)
?

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by