![]() Its decimal representation isĪnd so it agrees with pi to seven significant figures. This approximation was known in Euclid's time. The value printed for pi with format rat, or with rats(pi), is However, this is not a simple rational number. pi is the ratio of a large integer and 2 52 : The mathematical quantity is certainly not a rational number, but the MATLAB quantity pi that approximates it is a rational number. To see how the rational approximation is generated, the statement rat(s) Even though the quantity s is stored internally as a binary floating-point number, the desired rational form can be reconstructed. Its denominator is 420, the least common multiple of the denominators of the terms involved in the original expression. Returns the same results as those printed by MATLAB with format rat. The default is strlen = 13, which allows 6 elements in 78 spaces. strlen is the length of each string element returned by the rats function. ![]() Asterisks are used for elements that cannot be printed in the allotted space, but are not negligible compared to the other elements in X. Returns a string containing simple rational approximations to the elements of X. ![]() With no output arguments, simply displays the continued fraction. Returns N./D approximating X to within tol. Returns arrays N and D so that N./D approximates X to within the default tolerance, 1.e-6*norm(X(:),1). The rats function calls rat, and returns strings. Rational approximations are generated by truncating continued fraction expansions. Rat, rats (MATLAB Functions) MATLAB Function ReferenceĮven though all floating-point numbers are rational numbers, it is sometimes desirable to approximate them by simple rational numbers, which are fractions whose numerator and denominator are small integers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |