English 中文(简体)
为什么穿透的ep是我的继续分 fraction不平?
原标题:Why the bleep isn t my continued fraction approximating properly?

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html 我的法典为第1/菲条相近做了适当的工作,但为近似的对应工作(e - 2)。

(define (cont-frac n d k)
  (define (frac n d k)
        (if (= k 0)
            1.0
            (+ (d k) (/ (n (+ k 1)) (frac n d (- k 1))))))
    (/ (n 1) (frac n d k)))

(define (eulers-e-2)
  (cont-frac (lambda (i) 1.0) 
             (lambda (i)
               (if (= (remainder (+ i 1) 3) 0)
                   (* 2.0 (/ (+ i 1) 3))
                   1.0))
             100))

(define (1-over-phi)
  (cont-frac (lambda (i) 1.0)
             (lambda (i) 1.0)
             100))

不要忘记7. blah blah blah blah for e-2, I m 带5 blah blah 东西。 我可以说明原因。 我确信,我“d”在“eulers-e-2”职能中作了适当界定。

Edit: Thanks guys, I was calculating it backwards. Here s the fixed code.

(define (cont-frac n d k)
  (define (frac n d i)
        (if (= k i)
            (d i)
            (+ (d i) (/ (n (+ i 1)) (frac n d (+ i 1))))))
    (/ (n 1) (frac n d 1)))
最佳回答

您似乎正在计算如下:

N1/(D100 + (N101/ D99 + N100/(D98 + N99/(..))))

N1/(D1 + N2/(D2 + ...))

由于N和D对1/phi的相同(均为1s),你得到了正确的回答。

问题回答

暂无回答




相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签