Topic: Implementing the Babylonian approximation in Vedit (1 of 2), Read 36 times
Conf: Other, General, etc.
From: Peter Rejto
Date: Tuesday, July 20, 2010 11:58 PM

Hello.

Did anybody try to use Vedit to get an approximation to square root 2 ?

I have just learned on Wikipedia that there are numerous approximation methods for this problem. My favorite one is the Babylonian method and this is the one that I would like to see implemented in Vedit.

I have a hunch that this implementation problem is similar to one of the rosetta code implementations of Pauli Lindgren's, which says the following:


--------------------------------------------------
Iterative

Calculate fibonacci(#1). Negative values return 0.

:FIBONACCI:
#11 = 0
#12 = 1
Repeat(#1) {
#10 = #11 + #12
#11 = #12
#12 = #10
}
Return(#11)

---------------------------------------------------

My hunch is based on the fact that according to Wikipedia the Babylonian approximation method is also an iterative method.

I am looking forward to hearing your reactions, in particular I am looking forward to hearing Pauli's reactions.

-peter

 


Topic: Implementing the Babylonian approximation in Vedit (2 of 2), Read 7 times
Conf: Other, General, etc.
From: Pauli Lindgren
Date: Friday, August 06, 2010 04:04 AM

On 7/20/2010 11:58:04 PM, peter rejto wrote:
>Hello.
>
> Did anybody try to use Vedit
> to get an approximation to
> square root 2 ?
...
>
> I have a hunch that this
> implementation problem is
> similar to one of the rosetta
> code implementations of Pauli Lindgren's, which says the
> following:
>
> :FIBONACCI:
...

Vedit macro language only uses integer numbers.
Fibonacci numbers are integers.
Square root requires floating point numbers.

Of course you could do floating point calculations for example by implementing BCD-calculations yourself (using one character for each digit), but there is not much point doing that except if you want to practice programming.

--
Pauli