(/ (- (* 2122065862260549/40000000000000000 z1) (* 552621316200069/25000000000000000 z0)) (* z1 z1))

Percentage Accurate: 71.8% → 99.8%
Time: 1.6s
Alternatives: 5
Speedup: 1.0×

Specification

?
\[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]
(FPCore (z1 z0)
  :precision binary64
  (/
 (- (* 0.053051646556513725 z1) (* 0.02210485264800276 z0))
 (* z1 z1)))
double code(double z1, double z0) {
	return ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
}
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(z1, z0)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    code = ((0.053051646556513725d0 * z1) - (0.02210485264800276d0 * z0)) / (z1 * z1)
end function
public static double code(double z1, double z0) {
	return ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
}
def code(z1, z0):
	return ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1)
function code(z1, z0)
	return Float64(Float64(Float64(0.053051646556513725 * z1) - Float64(0.02210485264800276 * z0)) / Float64(z1 * z1))
end
function tmp = code(z1, z0)
	tmp = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
end
code[z1_, z0_] := N[(N[(N[(0.053051646556513725 * z1), $MachinePrecision] - N[(0.02210485264800276 * z0), $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]
\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1}

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 5 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: 71.8% accurate, 1.0× speedup?

\[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]
(FPCore (z1 z0)
  :precision binary64
  (/
 (- (* 0.053051646556513725 z1) (* 0.02210485264800276 z0))
 (* z1 z1)))
double code(double z1, double z0) {
	return ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
}
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(z1, z0)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    code = ((0.053051646556513725d0 * z1) - (0.02210485264800276d0 * z0)) / (z1 * z1)
end function
public static double code(double z1, double z0) {
	return ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
}
def code(z1, z0):
	return ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1)
function code(z1, z0)
	return Float64(Float64(Float64(0.053051646556513725 * z1) - Float64(0.02210485264800276 * z0)) / Float64(z1 * z1))
end
function tmp = code(z1, z0)
	tmp = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
end
code[z1_, z0_] := N[(N[(N[(0.053051646556513725 * z1), $MachinePrecision] - N[(0.02210485264800276 * z0), $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]
\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1}

Alternative 1: 99.8% accurate, 0.7× speedup?

\[\frac{0.053051646556513725}{z1} - \frac{z0}{z1} \cdot \frac{0.02210485264800276}{z1} \]
(FPCore (z1 z0)
  :precision binary64
  (-
 (/ 0.053051646556513725 z1)
 (* (/ z0 z1) (/ 0.02210485264800276 z1))))
double code(double z1, double z0) {
	return (0.053051646556513725 / z1) - ((z0 / z1) * (0.02210485264800276 / z1));
}
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(z1, z0)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    code = (0.053051646556513725d0 / z1) - ((z0 / z1) * (0.02210485264800276d0 / z1))
end function
public static double code(double z1, double z0) {
	return (0.053051646556513725 / z1) - ((z0 / z1) * (0.02210485264800276 / z1));
}
def code(z1, z0):
	return (0.053051646556513725 / z1) - ((z0 / z1) * (0.02210485264800276 / z1))
function code(z1, z0)
	return Float64(Float64(0.053051646556513725 / z1) - Float64(Float64(z0 / z1) * Float64(0.02210485264800276 / z1)))
end
function tmp = code(z1, z0)
	tmp = (0.053051646556513725 / z1) - ((z0 / z1) * (0.02210485264800276 / z1));
end
code[z1_, z0_] := N[(N[(0.053051646556513725 / z1), $MachinePrecision] - N[(N[(z0 / z1), $MachinePrecision] * N[(0.02210485264800276 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{0.053051646556513725}{z1} - \frac{z0}{z1} \cdot \frac{0.02210485264800276}{z1}
Derivation
  1. Initial program 71.8%

    \[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000} \cdot z1 - \frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1}} \]
    2. lift--.f64N/A

      \[\leadsto \frac{\color{blue}{\frac{2122065862260549}{40000000000000000} \cdot z1 - \frac{552621316200069}{25000000000000000} \cdot z0}}{z1 \cdot z1} \]
    3. div-subN/A

      \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000} \cdot z1}{z1 \cdot z1} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1}} \]
    4. lower--.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000} \cdot z1}{z1 \cdot z1} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1}} \]
    5. mult-flipN/A

      \[\leadsto \color{blue}{\left(\frac{2122065862260549}{40000000000000000} \cdot z1\right) \cdot \frac{1}{z1 \cdot z1}} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    6. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{2122065862260549}{40000000000000000} \cdot z1\right)} \cdot \frac{1}{z1 \cdot z1} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    7. associate-*l*N/A

      \[\leadsto \color{blue}{\frac{2122065862260549}{40000000000000000} \cdot \left(z1 \cdot \frac{1}{z1 \cdot z1}\right)} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    8. mult-flipN/A

      \[\leadsto \frac{2122065862260549}{40000000000000000} \cdot \color{blue}{\frac{z1}{z1 \cdot z1}} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{2122065862260549}{40000000000000000} \cdot \frac{z1}{\color{blue}{z1 \cdot z1}} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    10. associate-/r*N/A

      \[\leadsto \frac{2122065862260549}{40000000000000000} \cdot \color{blue}{\frac{\frac{z1}{z1}}{z1}} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    11. *-inversesN/A

      \[\leadsto \frac{2122065862260549}{40000000000000000} \cdot \frac{\color{blue}{1}}{z1} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    12. mult-flipN/A

      \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000}}{z1}} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    13. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000}}{z1}} - \frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1} \]
    14. lift-*.f64N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \frac{\color{blue}{\frac{552621316200069}{25000000000000000} \cdot z0}}{z1 \cdot z1} \]
    15. *-commutativeN/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \frac{\color{blue}{z0 \cdot \frac{552621316200069}{25000000000000000}}}{z1 \cdot z1} \]
    16. associate-/l*N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \color{blue}{z0 \cdot \frac{\frac{552621316200069}{25000000000000000}}{z1 \cdot z1}} \]
    17. *-commutativeN/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \color{blue}{\frac{\frac{552621316200069}{25000000000000000}}{z1 \cdot z1} \cdot z0} \]
    18. lower-*.f64N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \color{blue}{\frac{\frac{552621316200069}{25000000000000000}}{z1 \cdot z1} \cdot z0} \]
    19. lower-/.f6491.5%

      \[\leadsto \frac{0.053051646556513725}{z1} - \color{blue}{\frac{0.02210485264800276}{z1 \cdot z1}} \cdot z0 \]
  3. Applied rewrites91.5%

    \[\leadsto \color{blue}{\frac{0.053051646556513725}{z1} - \frac{0.02210485264800276}{z1 \cdot z1} \cdot z0} \]
  4. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \color{blue}{\frac{\frac{552621316200069}{25000000000000000}}{z1 \cdot z1} \cdot z0} \]
    2. lift-/.f64N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \color{blue}{\frac{\frac{552621316200069}{25000000000000000}}{z1 \cdot z1}} \cdot z0 \]
    3. associate-*l/N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \color{blue}{\frac{\frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1}} \]
    4. *-commutativeN/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \frac{\color{blue}{z0 \cdot \frac{552621316200069}{25000000000000000}}}{z1 \cdot z1} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \frac{z0 \cdot \frac{552621316200069}{25000000000000000}}{\color{blue}{z1 \cdot z1}} \]
    6. times-fracN/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \color{blue}{\frac{z0}{z1} \cdot \frac{\frac{552621316200069}{25000000000000000}}{z1}} \]
    7. lift-/.f64N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \color{blue}{\frac{z0}{z1}} \cdot \frac{\frac{552621316200069}{25000000000000000}}{z1} \]
    8. lift-/.f64N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000}}{z1} - \frac{z0}{z1} \cdot \color{blue}{\frac{\frac{552621316200069}{25000000000000000}}{z1}} \]
    9. lower-*.f6499.8%

      \[\leadsto \frac{0.053051646556513725}{z1} - \color{blue}{\frac{z0}{z1} \cdot \frac{0.02210485264800276}{z1}} \]
  5. Applied rewrites99.8%

    \[\leadsto \frac{0.053051646556513725}{z1} - \color{blue}{\frac{z0}{z1} \cdot \frac{0.02210485264800276}{z1}} \]
  6. Add Preprocessing

Alternative 2: 99.8% accurate, 1.0× speedup?

\[\frac{-0.02210485264800276 \cdot \frac{z0}{z1} - -0.053051646556513725}{z1} \]
(FPCore (z1 z0)
  :precision binary64
  (/ (- (* -0.02210485264800276 (/ z0 z1)) -0.053051646556513725) z1))
double code(double z1, double z0) {
	return ((-0.02210485264800276 * (z0 / z1)) - -0.053051646556513725) / z1;
}
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(z1, z0)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    code = (((-0.02210485264800276d0) * (z0 / z1)) - (-0.053051646556513725d0)) / z1
end function
public static double code(double z1, double z0) {
	return ((-0.02210485264800276 * (z0 / z1)) - -0.053051646556513725) / z1;
}
def code(z1, z0):
	return ((-0.02210485264800276 * (z0 / z1)) - -0.053051646556513725) / z1
function code(z1, z0)
	return Float64(Float64(Float64(-0.02210485264800276 * Float64(z0 / z1)) - -0.053051646556513725) / z1)
end
function tmp = code(z1, z0)
	tmp = ((-0.02210485264800276 * (z0 / z1)) - -0.053051646556513725) / z1;
end
code[z1_, z0_] := N[(N[(N[(-0.02210485264800276 * N[(z0 / z1), $MachinePrecision]), $MachinePrecision] - -0.053051646556513725), $MachinePrecision] / z1), $MachinePrecision]
\frac{-0.02210485264800276 \cdot \frac{z0}{z1} - -0.053051646556513725}{z1}
Derivation
  1. Initial program 71.8%

    \[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000} \cdot z1 - \frac{552621316200069}{25000000000000000} \cdot z0}{z1 \cdot z1}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\frac{2122065862260549}{40000000000000000} \cdot z1 - \frac{552621316200069}{25000000000000000} \cdot z0}{\color{blue}{z1 \cdot z1}} \]
    3. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{\frac{2122065862260549}{40000000000000000} \cdot z1 - \frac{552621316200069}{25000000000000000} \cdot z0}{z1}}{z1}} \]
    4. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{\frac{2122065862260549}{40000000000000000} \cdot z1 - \frac{552621316200069}{25000000000000000} \cdot z0}{z1}}{z1}} \]
  3. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{-0.02210485264800276 \cdot \frac{z0}{z1} - -0.053051646556513725}{z1}} \]
  4. Add Preprocessing

Alternative 3: 90.9% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1}\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-82}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-68}:\\ \;\;\;\;\frac{0.053051646556513725}{z1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (z1 z0)
  :precision binary64
  (let* ((t_0
        (/
         (- (* 0.053051646556513725 z1) (* 0.02210485264800276 z0))
         (* z1 z1))))
  (if (<= t_0 -5e-82)
    t_0
    (if (<= t_0 2e-68) (/ 0.053051646556513725 z1) t_0))))
double code(double z1, double z0) {
	double t_0 = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
	double tmp;
	if (t_0 <= -5e-82) {
		tmp = t_0;
	} else if (t_0 <= 2e-68) {
		tmp = 0.053051646556513725 / z1;
	} else {
		tmp = t_0;
	}
	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(z1, z0)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((0.053051646556513725d0 * z1) - (0.02210485264800276d0 * z0)) / (z1 * z1)
    if (t_0 <= (-5d-82)) then
        tmp = t_0
    else if (t_0 <= 2d-68) then
        tmp = 0.053051646556513725d0 / z1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double z1, double z0) {
	double t_0 = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
	double tmp;
	if (t_0 <= -5e-82) {
		tmp = t_0;
	} else if (t_0 <= 2e-68) {
		tmp = 0.053051646556513725 / z1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(z1, z0):
	t_0 = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1)
	tmp = 0
	if t_0 <= -5e-82:
		tmp = t_0
	elif t_0 <= 2e-68:
		tmp = 0.053051646556513725 / z1
	else:
		tmp = t_0
	return tmp
function code(z1, z0)
	t_0 = Float64(Float64(Float64(0.053051646556513725 * z1) - Float64(0.02210485264800276 * z0)) / Float64(z1 * z1))
	tmp = 0.0
	if (t_0 <= -5e-82)
		tmp = t_0;
	elseif (t_0 <= 2e-68)
		tmp = Float64(0.053051646556513725 / z1);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(z1, z0)
	t_0 = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
	tmp = 0.0;
	if (t_0 <= -5e-82)
		tmp = t_0;
	elseif (t_0 <= 2e-68)
		tmp = 0.053051646556513725 / z1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[z1_, z0_] := Block[{t$95$0 = N[(N[(N[(0.053051646556513725 * z1), $MachinePrecision] - N[(0.02210485264800276 * z0), $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-82], t$95$0, If[LessEqual[t$95$0, 2e-68], N[(0.053051646556513725 / z1), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-82}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-68}:\\
\;\;\;\;\frac{0.053051646556513725}{z1}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 #s(literal 2122065862260549/40000000000000000 binary64) z1) (*.f64 #s(literal 552621316200069/25000000000000000 binary64) z0)) (*.f64 z1 z1)) < -4.9999999999999998e-82 or 2.0000000000000001e-68 < (/.f64 (-.f64 (*.f64 #s(literal 2122065862260549/40000000000000000 binary64) z1) (*.f64 #s(literal 552621316200069/25000000000000000 binary64) z0)) (*.f64 z1 z1))

    1. Initial program 71.8%

      \[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]

    if -4.9999999999999998e-82 < (/.f64 (-.f64 (*.f64 #s(literal 2122065862260549/40000000000000000 binary64) z1) (*.f64 #s(literal 552621316200069/25000000000000000 binary64) z0)) (*.f64 z1 z1)) < 2.0000000000000001e-68

    1. Initial program 71.8%

      \[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]
    2. Taylor expanded in z1 around inf

      \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000}}{z1}} \]
    3. Step-by-step derivation
      1. lower-/.f6451.3%

        \[\leadsto \frac{0.053051646556513725}{\color{blue}{z1}} \]
    4. Applied rewrites51.3%

      \[\leadsto \color{blue}{\frac{0.053051646556513725}{z1}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 79.6% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1}\\ t_1 := \frac{-0.02210485264800276 \cdot z0}{z1 \cdot z1}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+186}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+78}:\\ \;\;\;\;\frac{0.053051646556513725}{z1}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (z1 z0)
  :precision binary64
  (let* ((t_0
        (/
         (- (* 0.053051646556513725 z1) (* 0.02210485264800276 z0))
         (* z1 z1)))
       (t_1 (/ (* -0.02210485264800276 z0) (* z1 z1))))
  (if (<= t_0 -1e+186)
    t_1
    (if (<= t_0 2e+78) (/ 0.053051646556513725 z1) t_1))))
double code(double z1, double z0) {
	double t_0 = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
	double t_1 = (-0.02210485264800276 * z0) / (z1 * z1);
	double tmp;
	if (t_0 <= -1e+186) {
		tmp = t_1;
	} else if (t_0 <= 2e+78) {
		tmp = 0.053051646556513725 / z1;
	} else {
		tmp = t_1;
	}
	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(z1, z0)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((0.053051646556513725d0 * z1) - (0.02210485264800276d0 * z0)) / (z1 * z1)
    t_1 = ((-0.02210485264800276d0) * z0) / (z1 * z1)
    if (t_0 <= (-1d+186)) then
        tmp = t_1
    else if (t_0 <= 2d+78) then
        tmp = 0.053051646556513725d0 / z1
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double z1, double z0) {
	double t_0 = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
	double t_1 = (-0.02210485264800276 * z0) / (z1 * z1);
	double tmp;
	if (t_0 <= -1e+186) {
		tmp = t_1;
	} else if (t_0 <= 2e+78) {
		tmp = 0.053051646556513725 / z1;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(z1, z0):
	t_0 = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1)
	t_1 = (-0.02210485264800276 * z0) / (z1 * z1)
	tmp = 0
	if t_0 <= -1e+186:
		tmp = t_1
	elif t_0 <= 2e+78:
		tmp = 0.053051646556513725 / z1
	else:
		tmp = t_1
	return tmp
function code(z1, z0)
	t_0 = Float64(Float64(Float64(0.053051646556513725 * z1) - Float64(0.02210485264800276 * z0)) / Float64(z1 * z1))
	t_1 = Float64(Float64(-0.02210485264800276 * z0) / Float64(z1 * z1))
	tmp = 0.0
	if (t_0 <= -1e+186)
		tmp = t_1;
	elseif (t_0 <= 2e+78)
		tmp = Float64(0.053051646556513725 / z1);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(z1, z0)
	t_0 = ((0.053051646556513725 * z1) - (0.02210485264800276 * z0)) / (z1 * z1);
	t_1 = (-0.02210485264800276 * z0) / (z1 * z1);
	tmp = 0.0;
	if (t_0 <= -1e+186)
		tmp = t_1;
	elseif (t_0 <= 2e+78)
		tmp = 0.053051646556513725 / z1;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[z1_, z0_] := Block[{t$95$0 = N[(N[(N[(0.053051646556513725 * z1), $MachinePrecision] - N[(0.02210485264800276 * z0), $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-0.02210485264800276 * z0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+186], t$95$1, If[LessEqual[t$95$0, 2e+78], N[(0.053051646556513725 / z1), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1}\\
t_1 := \frac{-0.02210485264800276 \cdot z0}{z1 \cdot z1}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+186}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+78}:\\
\;\;\;\;\frac{0.053051646556513725}{z1}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 #s(literal 2122065862260549/40000000000000000 binary64) z1) (*.f64 #s(literal 552621316200069/25000000000000000 binary64) z0)) (*.f64 z1 z1)) < -9.9999999999999998e185 or 2e78 < (/.f64 (-.f64 (*.f64 #s(literal 2122065862260549/40000000000000000 binary64) z1) (*.f64 #s(literal 552621316200069/25000000000000000 binary64) z0)) (*.f64 z1 z1))

    1. Initial program 71.8%

      \[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]
    2. Taylor expanded in z1 around 0

      \[\leadsto \frac{\color{blue}{\frac{-552621316200069}{25000000000000000} \cdot z0}}{z1 \cdot z1} \]
    3. Step-by-step derivation
      1. lower-*.f6446.3%

        \[\leadsto \frac{-0.02210485264800276 \cdot \color{blue}{z0}}{z1 \cdot z1} \]
    4. Applied rewrites46.3%

      \[\leadsto \frac{\color{blue}{-0.02210485264800276 \cdot z0}}{z1 \cdot z1} \]

    if -9.9999999999999998e185 < (/.f64 (-.f64 (*.f64 #s(literal 2122065862260549/40000000000000000 binary64) z1) (*.f64 #s(literal 552621316200069/25000000000000000 binary64) z0)) (*.f64 z1 z1)) < 2e78

    1. Initial program 71.8%

      \[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]
    2. Taylor expanded in z1 around inf

      \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000}}{z1}} \]
    3. Step-by-step derivation
      1. lower-/.f6451.3%

        \[\leadsto \frac{0.053051646556513725}{\color{blue}{z1}} \]
    4. Applied rewrites51.3%

      \[\leadsto \color{blue}{\frac{0.053051646556513725}{z1}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 51.3% accurate, 2.5× speedup?

\[\frac{0.053051646556513725}{z1} \]
(FPCore (z1 z0)
  :precision binary64
  (/ 0.053051646556513725 z1))
double code(double z1, double z0) {
	return 0.053051646556513725 / z1;
}
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(z1, z0)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    code = 0.053051646556513725d0 / z1
end function
public static double code(double z1, double z0) {
	return 0.053051646556513725 / z1;
}
def code(z1, z0):
	return 0.053051646556513725 / z1
function code(z1, z0)
	return Float64(0.053051646556513725 / z1)
end
function tmp = code(z1, z0)
	tmp = 0.053051646556513725 / z1;
end
code[z1_, z0_] := N[(0.053051646556513725 / z1), $MachinePrecision]
\frac{0.053051646556513725}{z1}
Derivation
  1. Initial program 71.8%

    \[\frac{0.053051646556513725 \cdot z1 - 0.02210485264800276 \cdot z0}{z1 \cdot z1} \]
  2. Taylor expanded in z1 around inf

    \[\leadsto \color{blue}{\frac{\frac{2122065862260549}{40000000000000000}}{z1}} \]
  3. Step-by-step derivation
    1. lower-/.f6451.3%

      \[\leadsto \frac{0.053051646556513725}{\color{blue}{z1}} \]
  4. Applied rewrites51.3%

    \[\leadsto \color{blue}{\frac{0.053051646556513725}{z1}} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025250 
(FPCore (z1 z0)
  :name "(/ (- (* 2122065862260549/40000000000000000 z1) (* 552621316200069/25000000000000000 z0)) (* z1 z1))"
  :precision binary64
  (/ (- (* 0.053051646556513725 z1) (* 0.02210485264800276 z0)) (* z1 z1)))