addaptic

Reference Means

lz_agm

The arithmetic-geometric mean of two numbers that are not negative.

long lz_agm( CLZNumber* leftOperand, CLZNumber* rightOperand, CLZNumber* targetNumber = nullptr );

The arithmetic and geometric means of the two are taken again and again until they meet, which doubles the correct digits each time round. A negative operand is refused, kFailed, flagged not-a-number.

Examples

CallAnswerReturns
lz_agm( 1, 2 )1.456791031046906869186432383265081975kNoError
lz_agm( 1, 0.5 )0.728395515523453434593216191632540987kNoError
lz_agm( 24, 6 )13.458171481725615420766813156974399243kNoError
lz_agm( −1, 4 )not a numberkFailed

Each answer is what Addaptic printed for the call, at 36 places unless a setting is shown.

Returns

kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.

See also