正在加载图片...
11. The golden ratio format long p= eval(p) format short err =(1+sqrt(5))/2-p The statement oldfract(6) 1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1)))))) 21/13 1.61538461538462 e The three p's are all different representations of the same approximation to o The first p is the continued fraction truncated to six terms. There are six right parentheses. This p is a string generated by starting with a single ' 1'(tha goldfract(o) and repeatedly inserting the string 1+1/( in front and the string ') in back. No matter how long this string becomes, it is a valid MATLAB expression The second p is an"ordinary"fraction with a single integer numerator and denominator obtained by collapsing the first p. The basis for the reformulation is 1 So the iteration starts with and repeatedly replaces the fraction The statement p= sprintf('7d/7d',p, q)1.1. The Golden Ratio 7 format long p = eval(p) format short err = (1+sqrt(5))/2 - p The statement goldfract(6) produces p = 1+1/(1+1/(1+1/(1+1/(1+1/(1+1/(1)))))) p = 21/13 p = 1.61538461538462 err = 0.0026 The three p’s are all different representations of the same approximation to φ. The first p is the continued fraction truncated to six terms. There are six right parentheses. This p is a string generated by starting with a single ‘1’ (that’s goldfract(0)) and repeatedly inserting the string ‘1+1/(’ in front and the string ‘)’ in back. No matter how long this string becomes, it is a valid Matlab expression. The second p is an “ordinary” fraction with a single integer numerator and denominator obtained by collapsing the first p. The basis for the reformulation is 1 + 1 p q = p + q p . So the iteration starts with 1 1 and repeatedly replaces the fraction p q with p + q p . The statement p = sprintf(’%d/%d’,p,q)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有