How to resolve the algorithm Arithmetic-geometric mean step by step in the Klingphix programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Arithmetic-geometric mean step by step in the Klingphix 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 Klingphix programming language
Source code in the klingphix programming language
include ..\Utilitys.tlhy
:agm [ over over + 2 / rot rot * sqrt ] [ over over tostr swap tostr # ] while drop ;
1 1 2 sqrt / agm
pstack
" " input
include ..\Utilitys.tlhy
:agm %a %g %p !p !g !a
$p $a $g - abs > ( [$a] [.5 $a $g + * $a $g * sqrt $p agm] ) if ;
1 .5 sqrt 1e-15 agm
pstack
" " input
You may also check:How to resolve the algorithm Comments step by step in the Dylan programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Loops/For with a specified step step by step in the Ceylon programming language
You may also check:How to resolve the algorithm Monte Carlo methods step by step in the ERRE programming language
You may also check:How to resolve the algorithm Spiral matrix step by step in the PARI/GP programming language