is_not_converged_real128 Function

private elemental function is_not_converged_real128(a, g) result(stat)

Check if the arithmetic-geometric mean iteration has not yet converged.

Note

Convergence criterion
Returns .true. if the absolute difference between the arithmetic mean a and geometric mean g exceeds the machine epsilon relative to the smaller value, as determined by spacing(min(a, g)).

Mathematically: |a - g| > spacing(min(a, g))

Appendix
This function is designed for internal use within the AGM iteration where both values are guaranteed to be positive and converging.

Arguments

Type IntentOptional Attributes Name
real(kind=real128), intent(in) :: a

arithmetic mean

real(kind=real128), intent(in) :: g

geometric mean

Return Value logical


Source Code

    elemental function is_not_converged_real128(a, g) result(stat)
        !! Check if the arithmetic-geometric mean iteration has not yet converged.
        !!
        !! @note
        !! **Convergence criterion**  
        !! Returns `.true.` if the absolute difference between the arithmetic mean `a`
        !! and geometric mean `g` exceeds the machine epsilon relative to the smaller value,
        !! as determined by `spacing(min(a, g))`.
        !!
        !! Mathematically: `|a - g| > spacing(min(a, g))`
        !!
        !! **Appendix**  
        !! This function is designed for internal use within the AGM iteration where
        !! both values are guaranteed to be positive and converging.
        !! @endnote

        real(real128), intent(in) :: a !! arithmetic mean

        real(real128), intent(in) :: g !! geometric mean



        logical :: stat



        stat = abs(a - g) .gt. spacing( min(a, g) )

    end function is_not_converged_real128