(- 20670851120203963/500000000000000 (* (* z0 z0) 816052492761019/10000000000000))

Percentage Accurate: 99.9% → 99.9%
Time: 1.2s
Alternatives: 4
Speedup: N/A×

Specification

?
\[41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \]
(FPCore (z0)
  :precision binary64
  (- 41.341702240407926 (* (* z0 z0) 81.6052492761019)))
double code(double z0) {
	return 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z0)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    code = 41.341702240407926d0 - ((z0 * z0) * 81.6052492761019d0)
end function
public static double code(double z0) {
	return 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
}
def code(z0):
	return 41.341702240407926 - ((z0 * z0) * 81.6052492761019)
function code(z0)
	return Float64(41.341702240407926 - Float64(Float64(z0 * z0) * 81.6052492761019))
end
function tmp = code(z0)
	tmp = 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
end
code[z0_] := N[(41.341702240407926 - N[(N[(z0 * z0), $MachinePrecision] * 81.6052492761019), $MachinePrecision]), $MachinePrecision]
41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.9% accurate, 1.0× speedup?

\[41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \]
(FPCore (z0)
  :precision binary64
  (- 41.341702240407926 (* (* z0 z0) 81.6052492761019)))
double code(double z0) {
	return 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z0)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    code = 41.341702240407926d0 - ((z0 * z0) * 81.6052492761019d0)
end function
public static double code(double z0) {
	return 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
}
def code(z0):
	return 41.341702240407926 - ((z0 * z0) * 81.6052492761019)
function code(z0)
	return Float64(41.341702240407926 - Float64(Float64(z0 * z0) * 81.6052492761019))
end
function tmp = code(z0)
	tmp = 41.341702240407926 - ((z0 * z0) * 81.6052492761019);
end
code[z0_] := N[(41.341702240407926 - N[(N[(z0 * z0), $MachinePrecision] * 81.6052492761019), $MachinePrecision]), $MachinePrecision]
41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019

Alternative 1: 99.9% accurate, 1.0× speedup?

\[\left(z0 \cdot z0 - 0.5066059182116223\right) \cdot -81.6052492761019 \]
(FPCore (z0)
  :precision binary64
  (* (- (* z0 z0) 0.5066059182116223) -81.6052492761019))
double code(double z0) {
	return ((z0 * z0) - 0.5066059182116223) * -81.6052492761019;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z0)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    code = ((z0 * z0) - 0.5066059182116223d0) * (-81.6052492761019d0)
end function
public static double code(double z0) {
	return ((z0 * z0) - 0.5066059182116223) * -81.6052492761019;
}
def code(z0):
	return ((z0 * z0) - 0.5066059182116223) * -81.6052492761019
function code(z0)
	return Float64(Float64(Float64(z0 * z0) - 0.5066059182116223) * -81.6052492761019)
end
function tmp = code(z0)
	tmp = ((z0 * z0) - 0.5066059182116223) * -81.6052492761019;
end
code[z0_] := N[(N[(N[(z0 * z0), $MachinePrecision] - 0.5066059182116223), $MachinePrecision] * -81.6052492761019), $MachinePrecision]
\left(z0 \cdot z0 - 0.5066059182116223\right) \cdot -81.6052492761019
Derivation
  1. Initial program 99.9%

    \[41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(z0 \cdot z0\right) \cdot \frac{816052492761019}{10000000000000}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\frac{816052492761019}{10000000000000} \cdot \left(z0 \cdot z0\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \frac{816052492761019}{10000000000000} \cdot \color{blue}{\left(z0 \cdot z0\right)} \]
    4. sqr-neg-revN/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \frac{816052492761019}{10000000000000} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(z0\right)\right) \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)} \]
    5. associate-*r*N/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right) \cdot \left(\mathsf{neg}\left(z0\right)\right)} \]
    6. distribute-rgt-neg-outN/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right) \cdot z0\right)\right)} \]
    7. distribute-lft-neg-inN/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)\right) \cdot z0} \]
    8. lower-*.f64N/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)\right) \cdot z0} \]
    9. distribute-rgt-neg-outN/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z0\right)\right)\right)\right)\right)} \cdot z0 \]
    10. remove-double-negN/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \left(\frac{816052492761019}{10000000000000} \cdot \color{blue}{z0}\right) \cdot z0 \]
    11. lower-*.f6499.9%

      \[\leadsto 41.341702240407926 - \color{blue}{\left(81.6052492761019 \cdot z0\right)} \cdot z0 \]
  3. Applied rewrites99.9%

    \[\leadsto 41.341702240407926 - \color{blue}{\left(81.6052492761019 \cdot z0\right) \cdot z0} \]
  4. Applied rewrites74.6%

    \[\leadsto \color{blue}{\left(\frac{41.341702240407926}{z0 \cdot z0} - 81.6052492761019\right) \cdot \left(z0 \cdot z0\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{\frac{20670851120203963}{500000000000000}}{z0 \cdot z0} - \frac{816052492761019}{10000000000000}\right) \cdot \left(z0 \cdot z0\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \left(\frac{\frac{20670851120203963}{500000000000000}}{z0 \cdot z0} - \frac{816052492761019}{10000000000000}\right) \cdot \color{blue}{\left(z0 \cdot z0\right)} \]
    3. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\left(\frac{\frac{20670851120203963}{500000000000000}}{z0 \cdot z0} - \frac{816052492761019}{10000000000000}\right) \cdot z0\right) \cdot z0} \]
    4. *-commutativeN/A

      \[\leadsto \color{blue}{z0 \cdot \left(\left(\frac{\frac{20670851120203963}{500000000000000}}{z0 \cdot z0} - \frac{816052492761019}{10000000000000}\right) \cdot z0\right)} \]
    5. associate-*l*N/A

      \[\leadsto \color{blue}{\left(z0 \cdot \left(\frac{\frac{20670851120203963}{500000000000000}}{z0 \cdot z0} - \frac{816052492761019}{10000000000000}\right)\right) \cdot z0} \]
  6. Applied rewrites99.7%

    \[\leadsto \color{blue}{\left(\frac{41.341702240407926}{z0} - 81.6052492761019 \cdot z0\right) \cdot z0} \]
  7. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{\frac{20670851120203963}{500000000000000}}{z0} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0} \]
    2. lift--.f64N/A

      \[\leadsto \color{blue}{\left(\frac{\frac{20670851120203963}{500000000000000}}{z0} - \frac{816052492761019}{10000000000000} \cdot z0\right)} \cdot z0 \]
    3. lift-/.f64N/A

      \[\leadsto \left(\color{blue}{\frac{\frac{20670851120203963}{500000000000000}}{z0}} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0 \]
    4. mult-flipN/A

      \[\leadsto \left(\color{blue}{\frac{20670851120203963}{500000000000000} \cdot \frac{1}{z0}} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0 \]
    5. metadata-evalN/A

      \[\leadsto \left(\color{blue}{\frac{\frac{20670851120203963}{40802624638050950}}{\frac{10000000000000}{816052492761019}}} \cdot \frac{1}{z0} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0 \]
    6. associate-*l/N/A

      \[\leadsto \left(\color{blue}{\frac{\frac{20670851120203963}{40802624638050950} \cdot \frac{1}{z0}}{\frac{10000000000000}{816052492761019}}} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0 \]
    7. metadata-evalN/A

      \[\leadsto \left(\frac{\color{blue}{\left(\frac{20670851120203963}{500000000000000} \cdot \frac{10000000000000}{816052492761019}\right)} \cdot \frac{1}{z0}}{\frac{10000000000000}{816052492761019}} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0 \]
    8. associate-*r*N/A

      \[\leadsto \left(\frac{\color{blue}{\frac{20670851120203963}{500000000000000} \cdot \left(\frac{10000000000000}{816052492761019} \cdot \frac{1}{z0}\right)}}{\frac{10000000000000}{816052492761019}} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0 \]
    9. mult-flipN/A

      \[\leadsto \left(\frac{\frac{20670851120203963}{500000000000000} \cdot \color{blue}{\frac{\frac{10000000000000}{816052492761019}}{z0}}}{\frac{10000000000000}{816052492761019}} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0 \]
    10. lift-/.f64N/A

      \[\leadsto \left(\frac{\frac{20670851120203963}{500000000000000} \cdot \color{blue}{\frac{\frac{10000000000000}{816052492761019}}{z0}}}{\frac{10000000000000}{816052492761019}} - \frac{816052492761019}{10000000000000} \cdot z0\right) \cdot z0 \]
    11. lift-*.f64N/A

      \[\leadsto \left(\frac{\frac{20670851120203963}{500000000000000} \cdot \frac{\frac{10000000000000}{816052492761019}}{z0}}{\frac{10000000000000}{816052492761019}} - \color{blue}{\frac{816052492761019}{10000000000000} \cdot z0}\right) \cdot z0 \]
    12. *-commutativeN/A

      \[\leadsto \left(\frac{\frac{20670851120203963}{500000000000000} \cdot \frac{\frac{10000000000000}{816052492761019}}{z0}}{\frac{10000000000000}{816052492761019}} - \color{blue}{z0 \cdot \frac{816052492761019}{10000000000000}}\right) \cdot z0 \]
    13. metadata-evalN/A

      \[\leadsto \left(\frac{\frac{20670851120203963}{500000000000000} \cdot \frac{\frac{10000000000000}{816052492761019}}{z0}}{\frac{10000000000000}{816052492761019}} - z0 \cdot \color{blue}{\frac{1}{\frac{10000000000000}{816052492761019}}}\right) \cdot z0 \]
    14. mult-flip-revN/A

      \[\leadsto \left(\frac{\frac{20670851120203963}{500000000000000} \cdot \frac{\frac{10000000000000}{816052492761019}}{z0}}{\frac{10000000000000}{816052492761019}} - \color{blue}{\frac{z0}{\frac{10000000000000}{816052492761019}}}\right) \cdot z0 \]
    15. sub-divN/A

      \[\leadsto \color{blue}{\frac{\frac{20670851120203963}{500000000000000} \cdot \frac{\frac{10000000000000}{816052492761019}}{z0} - z0}{\frac{10000000000000}{816052492761019}}} \cdot z0 \]
    16. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{\frac{20670851120203963}{500000000000000} \cdot \frac{\frac{10000000000000}{816052492761019}}{z0} - z0}{\frac{\frac{10000000000000}{816052492761019}}{z0}}} \]
    17. lift-/.f64N/A

      \[\leadsto \frac{\frac{20670851120203963}{500000000000000} \cdot \frac{\frac{10000000000000}{816052492761019}}{z0} - z0}{\color{blue}{\frac{\frac{10000000000000}{816052492761019}}{z0}}} \]
    18. sub-to-fractionN/A

      \[\leadsto \color{blue}{\frac{20670851120203963}{500000000000000} - \frac{z0}{\frac{\frac{10000000000000}{816052492761019}}{z0}}} \]
    19. lift-/.f64N/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \frac{z0}{\color{blue}{\frac{\frac{10000000000000}{816052492761019}}{z0}}} \]
    20. associate-/r/N/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\frac{z0}{\frac{10000000000000}{816052492761019}} \cdot z0} \]
    21. associate-*l/N/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\frac{z0 \cdot z0}{\frac{10000000000000}{816052492761019}}} \]
    22. lift-*.f64N/A

      \[\leadsto \frac{20670851120203963}{500000000000000} - \frac{\color{blue}{z0 \cdot z0}}{\frac{10000000000000}{816052492761019}} \]
    23. sub-to-fractionN/A

      \[\leadsto \color{blue}{\frac{\frac{20670851120203963}{500000000000000} \cdot \frac{10000000000000}{816052492761019} - z0 \cdot z0}{\frac{10000000000000}{816052492761019}}} \]
    24. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{20670851120203963}{40802624638050950}} - z0 \cdot z0}{\frac{10000000000000}{816052492761019}} \]
  8. Applied rewrites99.9%

    \[\leadsto \color{blue}{\left(z0 \cdot z0 - 0.5066059182116223\right) \cdot -81.6052492761019} \]
  9. Add Preprocessing

Alternative 2: 98.7% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \leq -200000:\\ \;\;\;\;\left(-81.6052492761019 \cdot z0\right) \cdot z0\\ \mathbf{else}:\\ \;\;\;\;41.341702240407926\\ \end{array} \]
(FPCore (z0)
  :precision binary64
  (if (<=
     (- 41.341702240407926 (* (* z0 z0) 81.6052492761019))
     -200000.0)
  (* (* -81.6052492761019 z0) z0)
  41.341702240407926))
double code(double z0) {
	double tmp;
	if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) {
		tmp = (-81.6052492761019 * z0) * z0;
	} else {
		tmp = 41.341702240407926;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z0)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8) :: tmp
    if ((41.341702240407926d0 - ((z0 * z0) * 81.6052492761019d0)) <= (-200000.0d0)) then
        tmp = ((-81.6052492761019d0) * z0) * z0
    else
        tmp = 41.341702240407926d0
    end if
    code = tmp
end function
public static double code(double z0) {
	double tmp;
	if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) {
		tmp = (-81.6052492761019 * z0) * z0;
	} else {
		tmp = 41.341702240407926;
	}
	return tmp;
}
def code(z0):
	tmp = 0
	if (41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0:
		tmp = (-81.6052492761019 * z0) * z0
	else:
		tmp = 41.341702240407926
	return tmp
function code(z0)
	tmp = 0.0
	if (Float64(41.341702240407926 - Float64(Float64(z0 * z0) * 81.6052492761019)) <= -200000.0)
		tmp = Float64(Float64(-81.6052492761019 * z0) * z0);
	else
		tmp = 41.341702240407926;
	end
	return tmp
end
function tmp_2 = code(z0)
	tmp = 0.0;
	if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0)
		tmp = (-81.6052492761019 * z0) * z0;
	else
		tmp = 41.341702240407926;
	end
	tmp_2 = tmp;
end
code[z0_] := If[LessEqual[N[(41.341702240407926 - N[(N[(z0 * z0), $MachinePrecision] * 81.6052492761019), $MachinePrecision]), $MachinePrecision], -200000.0], N[(N[(-81.6052492761019 * z0), $MachinePrecision] * z0), $MachinePrecision], 41.341702240407926]
\begin{array}{l}
\mathbf{if}\;41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \leq -200000:\\
\;\;\;\;\left(-81.6052492761019 \cdot z0\right) \cdot z0\\

\mathbf{else}:\\
\;\;\;\;41.341702240407926\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 #s(literal 20670851120203963/500000000000000 binary64) (*.f64 (*.f64 z0 z0) #s(literal 816052492761019/10000000000000 binary64))) < -2e5

    1. Initial program 99.9%

      \[41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(z0 \cdot z0\right) \cdot \frac{816052492761019}{10000000000000}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\frac{816052492761019}{10000000000000} \cdot \left(z0 \cdot z0\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \frac{816052492761019}{10000000000000} \cdot \color{blue}{\left(z0 \cdot z0\right)} \]
      4. sqr-neg-revN/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \frac{816052492761019}{10000000000000} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(z0\right)\right) \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)} \]
      5. associate-*r*N/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right) \cdot \left(\mathsf{neg}\left(z0\right)\right)} \]
      6. distribute-rgt-neg-outN/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right) \cdot z0\right)\right)} \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)\right) \cdot z0} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)\right) \cdot z0} \]
      9. distribute-rgt-neg-outN/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z0\right)\right)\right)\right)\right)} \cdot z0 \]
      10. remove-double-negN/A

        \[\leadsto \frac{20670851120203963}{500000000000000} - \left(\frac{816052492761019}{10000000000000} \cdot \color{blue}{z0}\right) \cdot z0 \]
      11. lower-*.f6499.9%

        \[\leadsto 41.341702240407926 - \color{blue}{\left(81.6052492761019 \cdot z0\right)} \cdot z0 \]
    3. Applied rewrites99.9%

      \[\leadsto 41.341702240407926 - \color{blue}{\left(81.6052492761019 \cdot z0\right) \cdot z0} \]
    4. Applied rewrites74.6%

      \[\leadsto \color{blue}{\left(\frac{41.341702240407926}{z0 \cdot z0} - 81.6052492761019\right) \cdot \left(z0 \cdot z0\right)} \]
    5. Taylor expanded in z0 around inf

      \[\leadsto \color{blue}{\frac{-816052492761019}{10000000000000}} \cdot \left(z0 \cdot z0\right) \]
    6. Step-by-step derivation
      1. Applied rewrites50.0%

        \[\leadsto \color{blue}{-81.6052492761019} \cdot \left(z0 \cdot z0\right) \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{-816052492761019}{10000000000000} \cdot \left(z0 \cdot z0\right)} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{-816052492761019}{10000000000000} \cdot \color{blue}{\left(z0 \cdot z0\right)} \]
        3. associate-*r*N/A

          \[\leadsto \color{blue}{\left(\frac{-816052492761019}{10000000000000} \cdot z0\right) \cdot z0} \]
        4. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\frac{-816052492761019}{10000000000000} \cdot z0\right) \cdot z0} \]
        5. lower-*.f6450.0%

          \[\leadsto \color{blue}{\left(-81.6052492761019 \cdot z0\right)} \cdot z0 \]
      3. Applied rewrites50.0%

        \[\leadsto \color{blue}{\left(-81.6052492761019 \cdot z0\right) \cdot z0} \]

      if -2e5 < (-.f64 #s(literal 20670851120203963/500000000000000 binary64) (*.f64 (*.f64 z0 z0) #s(literal 816052492761019/10000000000000 binary64)))

      1. Initial program 99.9%

        \[41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \]
      2. Taylor expanded in z0 around 0

        \[\leadsto \color{blue}{\frac{20670851120203963}{500000000000000}} \]
      3. Step-by-step derivation
        1. Applied rewrites50.6%

          \[\leadsto \color{blue}{41.341702240407926} \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 3: 98.7% accurate, 0.5× speedup?

      \[\begin{array}{l} \mathbf{if}\;41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \leq -200000:\\ \;\;\;\;-81.6052492761019 \cdot \left(z0 \cdot z0\right)\\ \mathbf{else}:\\ \;\;\;\;41.341702240407926\\ \end{array} \]
      (FPCore (z0)
        :precision binary64
        (if (<=
           (- 41.341702240407926 (* (* z0 z0) 81.6052492761019))
           -200000.0)
        (* -81.6052492761019 (* z0 z0))
        41.341702240407926))
      double code(double z0) {
      	double tmp;
      	if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) {
      		tmp = -81.6052492761019 * (z0 * z0);
      	} else {
      		tmp = 41.341702240407926;
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(z0)
      use fmin_fmax_functions
          real(8), intent (in) :: z0
          real(8) :: tmp
          if ((41.341702240407926d0 - ((z0 * z0) * 81.6052492761019d0)) <= (-200000.0d0)) then
              tmp = (-81.6052492761019d0) * (z0 * z0)
          else
              tmp = 41.341702240407926d0
          end if
          code = tmp
      end function
      
      public static double code(double z0) {
      	double tmp;
      	if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0) {
      		tmp = -81.6052492761019 * (z0 * z0);
      	} else {
      		tmp = 41.341702240407926;
      	}
      	return tmp;
      }
      
      def code(z0):
      	tmp = 0
      	if (41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0:
      		tmp = -81.6052492761019 * (z0 * z0)
      	else:
      		tmp = 41.341702240407926
      	return tmp
      
      function code(z0)
      	tmp = 0.0
      	if (Float64(41.341702240407926 - Float64(Float64(z0 * z0) * 81.6052492761019)) <= -200000.0)
      		tmp = Float64(-81.6052492761019 * Float64(z0 * z0));
      	else
      		tmp = 41.341702240407926;
      	end
      	return tmp
      end
      
      function tmp_2 = code(z0)
      	tmp = 0.0;
      	if ((41.341702240407926 - ((z0 * z0) * 81.6052492761019)) <= -200000.0)
      		tmp = -81.6052492761019 * (z0 * z0);
      	else
      		tmp = 41.341702240407926;
      	end
      	tmp_2 = tmp;
      end
      
      code[z0_] := If[LessEqual[N[(41.341702240407926 - N[(N[(z0 * z0), $MachinePrecision] * 81.6052492761019), $MachinePrecision]), $MachinePrecision], -200000.0], N[(-81.6052492761019 * N[(z0 * z0), $MachinePrecision]), $MachinePrecision], 41.341702240407926]
      
      \begin{array}{l}
      \mathbf{if}\;41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \leq -200000:\\
      \;\;\;\;-81.6052492761019 \cdot \left(z0 \cdot z0\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;41.341702240407926\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (-.f64 #s(literal 20670851120203963/500000000000000 binary64) (*.f64 (*.f64 z0 z0) #s(literal 816052492761019/10000000000000 binary64))) < -2e5

        1. Initial program 99.9%

          \[41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(z0 \cdot z0\right) \cdot \frac{816052492761019}{10000000000000}} \]
          2. *-commutativeN/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\frac{816052492761019}{10000000000000} \cdot \left(z0 \cdot z0\right)} \]
          3. lift-*.f64N/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \frac{816052492761019}{10000000000000} \cdot \color{blue}{\left(z0 \cdot z0\right)} \]
          4. sqr-neg-revN/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \frac{816052492761019}{10000000000000} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(z0\right)\right) \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)} \]
          5. associate-*r*N/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right) \cdot \left(\mathsf{neg}\left(z0\right)\right)} \]
          6. distribute-rgt-neg-outN/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right) \cdot z0\right)\right)} \]
          7. distribute-lft-neg-inN/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)\right) \cdot z0} \]
          8. lower-*.f64N/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\mathsf{neg}\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(z0\right)\right)\right)\right) \cdot z0} \]
          9. distribute-rgt-neg-outN/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \color{blue}{\left(\frac{816052492761019}{10000000000000} \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z0\right)\right)\right)\right)\right)} \cdot z0 \]
          10. remove-double-negN/A

            \[\leadsto \frac{20670851120203963}{500000000000000} - \left(\frac{816052492761019}{10000000000000} \cdot \color{blue}{z0}\right) \cdot z0 \]
          11. lower-*.f6499.9%

            \[\leadsto 41.341702240407926 - \color{blue}{\left(81.6052492761019 \cdot z0\right)} \cdot z0 \]
        3. Applied rewrites99.9%

          \[\leadsto 41.341702240407926 - \color{blue}{\left(81.6052492761019 \cdot z0\right) \cdot z0} \]
        4. Applied rewrites74.6%

          \[\leadsto \color{blue}{\left(\frac{41.341702240407926}{z0 \cdot z0} - 81.6052492761019\right) \cdot \left(z0 \cdot z0\right)} \]
        5. Taylor expanded in z0 around inf

          \[\leadsto \color{blue}{\frac{-816052492761019}{10000000000000}} \cdot \left(z0 \cdot z0\right) \]
        6. Step-by-step derivation
          1. Applied rewrites50.0%

            \[\leadsto \color{blue}{-81.6052492761019} \cdot \left(z0 \cdot z0\right) \]

          if -2e5 < (-.f64 #s(literal 20670851120203963/500000000000000 binary64) (*.f64 (*.f64 z0 z0) #s(literal 816052492761019/10000000000000 binary64)))

          1. Initial program 99.9%

            \[41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \]
          2. Taylor expanded in z0 around 0

            \[\leadsto \color{blue}{\frac{20670851120203963}{500000000000000}} \]
          3. Step-by-step derivation
            1. Applied rewrites50.6%

              \[\leadsto \color{blue}{41.341702240407926} \]
          4. Recombined 2 regimes into one program.
          5. Add Preprocessing

          Alternative 4: 50.6% accurate, 14.0× speedup?

          \[41.341702240407926 \]
          (FPCore (z0)
            :precision binary64
            41.341702240407926)
          double code(double z0) {
          	return 41.341702240407926;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(z0)
          use fmin_fmax_functions
              real(8), intent (in) :: z0
              code = 41.341702240407926d0
          end function
          
          public static double code(double z0) {
          	return 41.341702240407926;
          }
          
          def code(z0):
          	return 41.341702240407926
          
          function code(z0)
          	return 41.341702240407926
          end
          
          function tmp = code(z0)
          	tmp = 41.341702240407926;
          end
          
          code[z0_] := 41.341702240407926
          
          41.341702240407926
          
          Derivation
          1. Initial program 99.9%

            \[41.341702240407926 - \left(z0 \cdot z0\right) \cdot 81.6052492761019 \]
          2. Taylor expanded in z0 around 0

            \[\leadsto \color{blue}{\frac{20670851120203963}{500000000000000}} \]
          3. Step-by-step derivation
            1. Applied rewrites50.6%

              \[\leadsto \color{blue}{41.341702240407926} \]
            2. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2025250 
            (FPCore (z0)
              :name "(- 20670851120203963/500000000000000 (* (* z0 z0) 816052492761019/10000000000000))"
              :precision binary64
              (- 41.341702240407926 (* (* z0 z0) 81.6052492761019)))