Re: Exact (LISP-ish) calculations in Ruby?
- From: Gavin Sinclair <gsinclair@xxxxxxxxx>
- Date: Thu, 19 Nov 2009 01:21:38 -0800 (PST)
On Nov 19, 6:04 am, Aldric Giacomoni <ald...@xxxxxxxxxxx> wrote:
Aldric Giacomoni wrote:
In all fairness, I just fired up SLIME to check, and LISP's (sqrt 2)
does come out to be an approximation, so I guess I want something cool
like the HP-48 and HP-49's factoring power..
And I just read up on the process of 'continuing fractions' which can be
used find fractions / estimates of irrational numbers down to the nth
decimal. I wonder how we can know that, for instance, 1.41421 (etc) is
sqrt(2) ... ?
There's an algorithm for calculating square roots, similar (in
appearance, not in process) to the algorithm for long division. One
or more generations ago, school students would have done it with pen
and paper, I think.
Furthermore, there's a Calculus-based algorithm (Newton's method, it's
called in my syllabus, but I think it's properly called the Newton-
Raphson method) for calculating square/cube/fourth/... roots to any
desired accuracy.
Thirdly, you can estimate any root you like by trial multiplication!
(Exercise: write a Ruby program to do this; shouldn't take more than
10 lines.)
--
Gavin Sinclair
.
- Follow-Ups:
- Re: Exact (LISP-ish) calculations in Ruby?
- From: David Masover
- Re: Exact (LISP-ish) calculations in Ruby?
- From: Martin DeMello
- Re: Exact (LISP-ish) calculations in Ruby?
- References:
- Exact (LISP-ish) calculations in Ruby?
- From: Aldric Giacomoni
- Re: Exact (LISP-ish) calculations in Ruby?
- From: David Masover
- Re: Exact (LISP-ish) calculations in Ruby?
- From: Aldric Giacomoni
- Re: Exact (LISP-ish) calculations in Ruby?
- From: Aldric Giacomoni
- Exact (LISP-ish) calculations in Ruby?
- Prev by Date: Re: open a binary file-read bit-change bit-update same file
- Next by Date: Re: Exact (LISP-ish) calculations in Ruby?
- Previous by thread: Re: Exact (LISP-ish) calculations in Ruby?
- Next by thread: Re: Exact (LISP-ish) calculations in Ruby?
- Index(es):
Relevant Pages
|