How to resolve the algorithm Arithmetic-geometric mean step by step in the Oforth programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Arithmetic-geometric mean step by step in the Oforth programming language

Table of Contents

Problem Statement

Write a function to compute the arithmetic-geometric mean of two numbers.

The arithmetic-geometric mean of two numbers can be (usefully) denoted as

a g m

( a , g )

{\displaystyle \mathrm {agm} (a,g)}

, and is equal to the limit of the sequence: Since the limit of

a

n

g

n

{\displaystyle a_{n}-g_{n}}

tends (rapidly) to zero with iterations, this is an efficient method. Demonstrate the function by calculating:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Arithmetic-geometric mean step by step in the Oforth programming language

Source code in the oforth programming language

: agm   \ a b -- m
   while( 2dup <> ) [ 2dup + 2 / -rot * sqrt ] drop ;

1 2 sqrt inv agm

  

You may also check:How to resolve the algorithm Parsing/Shunting-yard algorithm step by step in the 11l programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the Perl programming language
You may also check:How to resolve the algorithm Show ASCII table step by step in the COBOL programming language
You may also check:How to resolve the algorithm Power set step by step in the OCaml programming language
You may also check:How to resolve the algorithm Test a function step by step in the Factor programming language