[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: Exact (LISP-ish) calculations in Ruby?
From: David Masover <ninja () slaphack ! com>
Date: 2009-11-20 6:11:34
Message-ID: 200911200011.23775.ninja () slaphack ! com
[Download RAW message or body]
On Thursday 19 November 2009 03:25:09 am Gavin Sinclair wrote:
> 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.
Newton's Method, according to at least one Calculus textbook, is a way of
finding roots (zeros) for any function for which you can calculate function
values and derivatives. The example given is taking the cube root of seven, by
rewriting the problem as:
x^3 - 7 = 0
The derivative of which is easy to calculate as 3x^2.
I wrote a program to do Newton's Method. It's one of the few times I wished I
was using Lisp instead of Ruby, as I had no easy way of taking apart a block
as source code to find its derivative. Instead, whenever I apply it, I have to
take the derivative manually, or feed it through Maxima.
But I guess if what you wanted was something that knows how to do algebraic
manipulation, without losing accuracy until you tell it to give you a float,
there's always Maxima.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic