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

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Arithmetic-geometric mean step by step in the Potion 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 Potion programming language

Source code in the potion programming language

sqrt = (x) :
   xi = 1
   7 times :
      xi = (xi + x / xi) / 2
   .
   xi
.

agm = (x, y) :
   7 times :
      a = (x + y) / 2
      g = sqrt(x * y)
      x = a
      y = g
   .
   x
.

  

You may also check:How to resolve the algorithm Display an outline as a nested table step by step in the zkl programming language
You may also check:How to resolve the algorithm Iterated digits squaring step by step in the Scala programming language
You may also check:How to resolve the algorithm Ludic numbers step by step in the Java programming language
You may also check:How to resolve the algorithm Sorting algorithms/Radix sort step by step in the QB64 programming language
You may also check:How to resolve the algorithm Variadic function step by step in the Aime programming language