(/ (- z2) (+ (* (* z2 (/ z0 (* z1 z1))) z2) z3))

Percentage Accurate: 83.1% → 92.9%
Time: 2.2s
Alternatives: 9
Speedup: 0.9×

Specification

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

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

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

Alternative 1: 92.9% accurate, 0.9× speedup?

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

    \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
    2. lift-/.f64N/A

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

      \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
    5. associate-/r*N/A

      \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
    6. lower-/.f64N/A

      \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
    7. associate-*l/N/A

      \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
    8. lower-*.f64N/A

      \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
    9. lower-/.f6492.9%

      \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
  3. Applied rewrites92.9%

    \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
  4. Add Preprocessing

Alternative 2: 91.9% accurate, 0.9× speedup?

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

    \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
    2. lift-/.f64N/A

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

      \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
    5. times-fracN/A

      \[\leadsto \frac{-z2}{\color{blue}{\left(\frac{z2}{z1} \cdot \frac{z0}{z1}\right)} \cdot z2 + z3} \]
    6. lower-*.f64N/A

      \[\leadsto \frac{-z2}{\color{blue}{\left(\frac{z2}{z1} \cdot \frac{z0}{z1}\right)} \cdot z2 + z3} \]
    7. lower-/.f64N/A

      \[\leadsto \frac{-z2}{\left(\color{blue}{\frac{z2}{z1}} \cdot \frac{z0}{z1}\right) \cdot z2 + z3} \]
    8. lower-/.f6491.9%

      \[\leadsto \frac{-z2}{\left(\frac{z2}{z1} \cdot \color{blue}{\frac{z0}{z1}}\right) \cdot z2 + z3} \]
  3. Applied rewrites91.9%

    \[\leadsto \frac{-z2}{\color{blue}{\left(\frac{z2}{z1} \cdot \frac{z0}{z1}\right)} \cdot z2 + z3} \]
  4. Add Preprocessing

Alternative 3: 88.9% accurate, 0.7× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|z1\right| \leq 50000:\\ \;\;\;\;\frac{-z2}{z3 \cdot \left|z1\right| + \left(z0 \cdot \frac{z2}{\left|z1\right|}\right) \cdot z2} \cdot \left|z1\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{-z2}{\left(z2 \cdot \frac{z0}{\left|z1\right| \cdot \left|z1\right|}\right) \cdot z2 + z3}\\ \end{array} \]
(FPCore (z2 z0 z1 z3)
  :precision binary64
  (if (<= (fabs z1) 50000.0)
  (*
   (/ (- z2) (+ (* z3 (fabs z1)) (* (* z0 (/ z2 (fabs z1))) z2)))
   (fabs z1))
  (/ (- z2) (+ (* (* z2 (/ z0 (* (fabs z1) (fabs z1)))) z2) z3))))
double code(double z2, double z0, double z1, double z3) {
	double tmp;
	if (fabs(z1) <= 50000.0) {
		tmp = (-z2 / ((z3 * fabs(z1)) + ((z0 * (z2 / fabs(z1))) * z2))) * fabs(z1);
	} else {
		tmp = -z2 / (((z2 * (z0 / (fabs(z1) * fabs(z1)))) * z2) + z3);
	}
	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(z2, z0, z1, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z2
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8), intent (in) :: z3
    real(8) :: tmp
    if (abs(z1) <= 50000.0d0) then
        tmp = (-z2 / ((z3 * abs(z1)) + ((z0 * (z2 / abs(z1))) * z2))) * abs(z1)
    else
        tmp = -z2 / (((z2 * (z0 / (abs(z1) * abs(z1)))) * z2) + z3)
    end if
    code = tmp
end function
public static double code(double z2, double z0, double z1, double z3) {
	double tmp;
	if (Math.abs(z1) <= 50000.0) {
		tmp = (-z2 / ((z3 * Math.abs(z1)) + ((z0 * (z2 / Math.abs(z1))) * z2))) * Math.abs(z1);
	} else {
		tmp = -z2 / (((z2 * (z0 / (Math.abs(z1) * Math.abs(z1)))) * z2) + z3);
	}
	return tmp;
}
def code(z2, z0, z1, z3):
	tmp = 0
	if math.fabs(z1) <= 50000.0:
		tmp = (-z2 / ((z3 * math.fabs(z1)) + ((z0 * (z2 / math.fabs(z1))) * z2))) * math.fabs(z1)
	else:
		tmp = -z2 / (((z2 * (z0 / (math.fabs(z1) * math.fabs(z1)))) * z2) + z3)
	return tmp
function code(z2, z0, z1, z3)
	tmp = 0.0
	if (abs(z1) <= 50000.0)
		tmp = Float64(Float64(Float64(-z2) / Float64(Float64(z3 * abs(z1)) + Float64(Float64(z0 * Float64(z2 / abs(z1))) * z2))) * abs(z1));
	else
		tmp = Float64(Float64(-z2) / Float64(Float64(Float64(z2 * Float64(z0 / Float64(abs(z1) * abs(z1)))) * z2) + z3));
	end
	return tmp
end
function tmp_2 = code(z2, z0, z1, z3)
	tmp = 0.0;
	if (abs(z1) <= 50000.0)
		tmp = (-z2 / ((z3 * abs(z1)) + ((z0 * (z2 / abs(z1))) * z2))) * abs(z1);
	else
		tmp = -z2 / (((z2 * (z0 / (abs(z1) * abs(z1)))) * z2) + z3);
	end
	tmp_2 = tmp;
end
code[z2_, z0_, z1_, z3_] := If[LessEqual[N[Abs[z1], $MachinePrecision], 50000.0], N[(N[((-z2) / N[(N[(z3 * N[Abs[z1], $MachinePrecision]), $MachinePrecision] + N[(N[(z0 * N[(z2 / N[Abs[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[z1], $MachinePrecision]), $MachinePrecision], N[((-z2) / N[(N[(N[(z2 * N[(z0 / N[(N[Abs[z1], $MachinePrecision] * N[Abs[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z1\right| \leq 50000:\\
\;\;\;\;\frac{-z2}{z3 \cdot \left|z1\right| + \left(z0 \cdot \frac{z2}{\left|z1\right|}\right) \cdot z2} \cdot \left|z1\right|\\

\mathbf{else}:\\
\;\;\;\;\frac{-z2}{\left(z2 \cdot \frac{z0}{\left|z1\right| \cdot \left|z1\right|}\right) \cdot z2 + z3}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z1 < 5e4

    1. Initial program 83.1%

      \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
      5. associate-/r*N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
      7. associate-*l/N/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
      9. lower-/.f6492.9%

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
    3. Applied rewrites92.9%

      \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
    4. Applied rewrites80.1%

      \[\leadsto \color{blue}{\frac{-z2}{z3 \cdot z1 + \left(z0 \cdot \frac{z2}{z1}\right) \cdot z2} \cdot z1} \]

    if 5e4 < z1

    1. Initial program 83.1%

      \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 86.2% accurate, 0.3× speedup?

\[\mathsf{copysign}\left(1, z2\right) \cdot \begin{array}{l} \mathbf{if}\;\left|z2\right| \leq 1.15 \cdot 10^{+207}:\\ \;\;\;\;\frac{-\left|z2\right|}{\frac{z0 \cdot \left|z2\right|}{z1 \cdot z1} \cdot \left|z2\right| + z3}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-1}{\left|z2\right|} \cdot z1\right) \cdot \frac{z1}{z0}\\ \end{array} \]
(FPCore (z2 z0 z1 z3)
  :precision binary64
  (*
 (copysign 1.0 z2)
 (if (<= (fabs z2) 1.15e+207)
   (/
    (- (fabs z2))
    (+ (* (/ (* z0 (fabs z2)) (* z1 z1)) (fabs z2)) z3))
   (* (* (/ -1.0 (fabs z2)) z1) (/ z1 z0)))))
double code(double z2, double z0, double z1, double z3) {
	double tmp;
	if (fabs(z2) <= 1.15e+207) {
		tmp = -fabs(z2) / ((((z0 * fabs(z2)) / (z1 * z1)) * fabs(z2)) + z3);
	} else {
		tmp = ((-1.0 / fabs(z2)) * z1) * (z1 / z0);
	}
	return copysign(1.0, z2) * tmp;
}
public static double code(double z2, double z0, double z1, double z3) {
	double tmp;
	if (Math.abs(z2) <= 1.15e+207) {
		tmp = -Math.abs(z2) / ((((z0 * Math.abs(z2)) / (z1 * z1)) * Math.abs(z2)) + z3);
	} else {
		tmp = ((-1.0 / Math.abs(z2)) * z1) * (z1 / z0);
	}
	return Math.copySign(1.0, z2) * tmp;
}
def code(z2, z0, z1, z3):
	tmp = 0
	if math.fabs(z2) <= 1.15e+207:
		tmp = -math.fabs(z2) / ((((z0 * math.fabs(z2)) / (z1 * z1)) * math.fabs(z2)) + z3)
	else:
		tmp = ((-1.0 / math.fabs(z2)) * z1) * (z1 / z0)
	return math.copysign(1.0, z2) * tmp
function code(z2, z0, z1, z3)
	tmp = 0.0
	if (abs(z2) <= 1.15e+207)
		tmp = Float64(Float64(-abs(z2)) / Float64(Float64(Float64(Float64(z0 * abs(z2)) / Float64(z1 * z1)) * abs(z2)) + z3));
	else
		tmp = Float64(Float64(Float64(-1.0 / abs(z2)) * z1) * Float64(z1 / z0));
	end
	return Float64(copysign(1.0, z2) * tmp)
end
function tmp_2 = code(z2, z0, z1, z3)
	tmp = 0.0;
	if (abs(z2) <= 1.15e+207)
		tmp = -abs(z2) / ((((z0 * abs(z2)) / (z1 * z1)) * abs(z2)) + z3);
	else
		tmp = ((-1.0 / abs(z2)) * z1) * (z1 / z0);
	end
	tmp_2 = (sign(z2) * abs(1.0)) * tmp;
end
code[z2_, z0_, z1_, z3_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z2], $MachinePrecision], 1.15e+207], N[((-N[Abs[z2], $MachinePrecision]) / N[(N[(N[(N[(z0 * N[Abs[z2], $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 / N[Abs[z2], $MachinePrecision]), $MachinePrecision] * z1), $MachinePrecision] * N[(z1 / z0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, z2\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 1.15 \cdot 10^{+207}:\\
\;\;\;\;\frac{-\left|z2\right|}{\frac{z0 \cdot \left|z2\right|}{z1 \cdot z1} \cdot \left|z2\right| + z3}\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{-1}{\left|z2\right|} \cdot z1\right) \cdot \frac{z1}{z0}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z2 < 1.15e207

    1. Initial program 83.1%

      \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
      5. *-commutativeN/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{z0 \cdot z2}}{z1 \cdot z1} \cdot z2 + z3} \]
      6. lower-*.f6483.2%

        \[\leadsto \frac{-z2}{\frac{\color{blue}{z0 \cdot z2}}{z1 \cdot z1} \cdot z2 + z3} \]
    3. Applied rewrites83.2%

      \[\leadsto \frac{-z2}{\color{blue}{\frac{z0 \cdot z2}{z1 \cdot z1}} \cdot z2 + z3} \]

    if 1.15e207 < z2

    1. Initial program 83.1%

      \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
      5. associate-/r*N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
      7. associate-*l/N/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
      9. lower-/.f6492.9%

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
    3. Applied rewrites92.9%

      \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
    4. Taylor expanded in z2 around inf

      \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
      2. lower-/.f64N/A

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0 \cdot z2}} \]
      3. lower-pow.f64N/A

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0} \cdot z2} \]
      4. lower-*.f6443.6%

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{z0 \cdot \color{blue}{z2}} \]
    6. Applied rewrites43.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
      2. lift-/.f64N/A

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0 \cdot z2}} \]
      3. lift-pow.f64N/A

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0} \cdot z2} \]
      4. pow2N/A

        \[\leadsto -1 \cdot \frac{z1 \cdot z1}{\color{blue}{z0} \cdot z2} \]
      5. lift-*.f64N/A

        \[\leadsto -1 \cdot \frac{z1 \cdot z1}{\color{blue}{z0} \cdot z2} \]
      6. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot \left(z1 \cdot z1\right)}{\color{blue}{z0 \cdot z2}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{-1 \cdot \left(z1 \cdot z1\right)}{z0 \cdot \color{blue}{z2}} \]
      8. *-commutativeN/A

        \[\leadsto \frac{-1 \cdot \left(z1 \cdot z1\right)}{z2 \cdot \color{blue}{z0}} \]
      9. times-fracN/A

        \[\leadsto \frac{-1}{z2} \cdot \color{blue}{\frac{z1 \cdot z1}{z0}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{-1}{z2} \cdot \frac{z1 \cdot z1}{z0} \]
      11. associate-/l*N/A

        \[\leadsto \frac{-1}{z2} \cdot \left(z1 \cdot \color{blue}{\frac{z1}{z0}}\right) \]
      12. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{z2} \cdot z1\right) \cdot \color{blue}{\frac{z1}{z0}} \]
      13. lower-*.f64N/A

        \[\leadsto \left(\frac{-1}{z2} \cdot z1\right) \cdot \color{blue}{\frac{z1}{z0}} \]
      14. lower-*.f64N/A

        \[\leadsto \left(\frac{-1}{z2} \cdot z1\right) \cdot \frac{\color{blue}{z1}}{z0} \]
      15. lower-/.f64N/A

        \[\leadsto \left(\frac{-1}{z2} \cdot z1\right) \cdot \frac{z1}{z0} \]
      16. lower-/.f6451.0%

        \[\leadsto \left(\frac{-1}{z2} \cdot z1\right) \cdot \frac{z1}{\color{blue}{z0}} \]
    8. Applied rewrites51.0%

      \[\leadsto \left(\frac{-1}{z2} \cdot z1\right) \cdot \color{blue}{\frac{z1}{z0}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 85.2% accurate, 0.3× speedup?

\[\mathsf{copysign}\left(1, z2\right) \cdot \begin{array}{l} \mathbf{if}\;\left|z2\right| \leq 6 \cdot 10^{+242}:\\ \;\;\;\;\frac{-\left|z2\right|}{\left(\left|z2\right| \cdot \frac{z0}{z1 \cdot z1}\right) \cdot \left|z2\right| + z3}\\ \mathbf{else}:\\ \;\;\;\;z1 \cdot \left(\frac{z1}{z0} \cdot \frac{-1}{\left|z2\right|}\right)\\ \end{array} \]
(FPCore (z2 z0 z1 z3)
  :precision binary64
  (*
 (copysign 1.0 z2)
 (if (<= (fabs z2) 6e+242)
   (/
    (- (fabs z2))
    (+ (* (* (fabs z2) (/ z0 (* z1 z1))) (fabs z2)) z3))
   (* z1 (* (/ z1 z0) (/ -1.0 (fabs z2)))))))
double code(double z2, double z0, double z1, double z3) {
	double tmp;
	if (fabs(z2) <= 6e+242) {
		tmp = -fabs(z2) / (((fabs(z2) * (z0 / (z1 * z1))) * fabs(z2)) + z3);
	} else {
		tmp = z1 * ((z1 / z0) * (-1.0 / fabs(z2)));
	}
	return copysign(1.0, z2) * tmp;
}
public static double code(double z2, double z0, double z1, double z3) {
	double tmp;
	if (Math.abs(z2) <= 6e+242) {
		tmp = -Math.abs(z2) / (((Math.abs(z2) * (z0 / (z1 * z1))) * Math.abs(z2)) + z3);
	} else {
		tmp = z1 * ((z1 / z0) * (-1.0 / Math.abs(z2)));
	}
	return Math.copySign(1.0, z2) * tmp;
}
def code(z2, z0, z1, z3):
	tmp = 0
	if math.fabs(z2) <= 6e+242:
		tmp = -math.fabs(z2) / (((math.fabs(z2) * (z0 / (z1 * z1))) * math.fabs(z2)) + z3)
	else:
		tmp = z1 * ((z1 / z0) * (-1.0 / math.fabs(z2)))
	return math.copysign(1.0, z2) * tmp
function code(z2, z0, z1, z3)
	tmp = 0.0
	if (abs(z2) <= 6e+242)
		tmp = Float64(Float64(-abs(z2)) / Float64(Float64(Float64(abs(z2) * Float64(z0 / Float64(z1 * z1))) * abs(z2)) + z3));
	else
		tmp = Float64(z1 * Float64(Float64(z1 / z0) * Float64(-1.0 / abs(z2))));
	end
	return Float64(copysign(1.0, z2) * tmp)
end
function tmp_2 = code(z2, z0, z1, z3)
	tmp = 0.0;
	if (abs(z2) <= 6e+242)
		tmp = -abs(z2) / (((abs(z2) * (z0 / (z1 * z1))) * abs(z2)) + z3);
	else
		tmp = z1 * ((z1 / z0) * (-1.0 / abs(z2)));
	end
	tmp_2 = (sign(z2) * abs(1.0)) * tmp;
end
code[z2_, z0_, z1_, z3_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z2], $MachinePrecision], 6e+242], N[((-N[Abs[z2], $MachinePrecision]) / N[(N[(N[(N[Abs[z2], $MachinePrecision] * N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision], N[(z1 * N[(N[(z1 / z0), $MachinePrecision] * N[(-1.0 / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, z2\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 6 \cdot 10^{+242}:\\
\;\;\;\;\frac{-\left|z2\right|}{\left(\left|z2\right| \cdot \frac{z0}{z1 \cdot z1}\right) \cdot \left|z2\right| + z3}\\

\mathbf{else}:\\
\;\;\;\;z1 \cdot \left(\frac{z1}{z0} \cdot \frac{-1}{\left|z2\right|}\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z2 < 6.0000000000000001e242

    1. Initial program 83.1%

      \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]

    if 6.0000000000000001e242 < z2

    1. Initial program 83.1%

      \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
      5. associate-/r*N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
      7. associate-*l/N/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
      9. lower-/.f6492.9%

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
    3. Applied rewrites92.9%

      \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
    4. Taylor expanded in z2 around inf

      \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
      2. lower-/.f64N/A

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0 \cdot z2}} \]
      3. lower-pow.f64N/A

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0} \cdot z2} \]
      4. lower-*.f6443.6%

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{z0 \cdot \color{blue}{z2}} \]
    6. Applied rewrites43.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
      4. lift-pow.f64N/A

        \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
      5. pow2N/A

        \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
      7. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
      8. associate-/r*N/A

        \[\leadsto \mathsf{neg}\left(\frac{\frac{z1 \cdot z1}{z0}}{z2}\right) \]
      9. distribute-neg-frac2N/A

        \[\leadsto \frac{\frac{z1 \cdot z1}{z0}}{\color{blue}{\mathsf{neg}\left(z2\right)}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\frac{z1 \cdot z1}{z0}}{\mathsf{neg}\left(z2\right)} \]
      11. associate-/l*N/A

        \[\leadsto \frac{z1 \cdot \frac{z1}{z0}}{\mathsf{neg}\left(\color{blue}{z2}\right)} \]
      12. lift-neg.f64N/A

        \[\leadsto \frac{z1 \cdot \frac{z1}{z0}}{-z2} \]
      13. associate-/l*N/A

        \[\leadsto z1 \cdot \color{blue}{\frac{\frac{z1}{z0}}{-z2}} \]
      14. lower-*.f64N/A

        \[\leadsto z1 \cdot \color{blue}{\frac{\frac{z1}{z0}}{-z2}} \]
      15. lower-/.f64N/A

        \[\leadsto z1 \cdot \frac{\frac{z1}{z0}}{\color{blue}{-z2}} \]
      16. lower-/.f6450.8%

        \[\leadsto z1 \cdot \frac{\frac{z1}{z0}}{-\color{blue}{z2}} \]
    8. Applied rewrites50.8%

      \[\leadsto z1 \cdot \color{blue}{\frac{\frac{z1}{z0}}{-z2}} \]
    9. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto z1 \cdot \frac{\frac{z1}{z0}}{\mathsf{neg}\left(z2\right)} \]
      2. lift-/.f64N/A

        \[\leadsto z1 \cdot \frac{\frac{z1}{z0}}{\color{blue}{\mathsf{neg}\left(z2\right)}} \]
      3. mult-flipN/A

        \[\leadsto z1 \cdot \left(\frac{z1}{z0} \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(z2\right)}}\right) \]
      4. lower-*.f64N/A

        \[\leadsto z1 \cdot \left(\frac{z1}{z0} \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(z2\right)}}\right) \]
      5. metadata-evalN/A

        \[\leadsto z1 \cdot \left(\frac{z1}{z0} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\color{blue}{z2}\right)}\right) \]
      6. frac-2neg-revN/A

        \[\leadsto z1 \cdot \left(\frac{z1}{z0} \cdot \frac{-1}{\color{blue}{z2}}\right) \]
      7. lower-/.f6450.8%

        \[\leadsto z1 \cdot \left(\frac{z1}{z0} \cdot \frac{-1}{\color{blue}{z2}}\right) \]
    10. Applied rewrites50.8%

      \[\leadsto z1 \cdot \left(\frac{z1}{z0} \cdot \color{blue}{\frac{-1}{z2}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 74.6% accurate, 0.6× speedup?

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

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+15}:\\
\;\;\;\;\frac{-z2}{z3}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{-z1}{z0} \cdot z1}{z2}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 z0 (*.f64 z1 z1)) < -2.0000000000000001e57

    1. Initial program 83.1%

      \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
      5. associate-/r*N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
      7. associate-*l/N/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
      9. lower-/.f6492.9%

        \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
    3. Applied rewrites92.9%

      \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
    4. Taylor expanded in z2 around inf

      \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
      2. lower-/.f64N/A

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0 \cdot z2}} \]
      3. lower-pow.f64N/A

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0} \cdot z2} \]
      4. lower-*.f6443.6%

        \[\leadsto -1 \cdot \frac{{z1}^{2}}{z0 \cdot \color{blue}{z2}} \]
    6. Applied rewrites43.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
      4. lift-pow.f64N/A

        \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
      5. pow2N/A

        \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
      7. mult-flipN/A

        \[\leadsto \mathsf{neg}\left(\left(z1 \cdot z1\right) \cdot \frac{1}{z0 \cdot z2}\right) \]
      8. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\left(z1 \cdot z1\right) \cdot \frac{1}{z0 \cdot z2}\right) \]
      9. associate-*l*N/A

        \[\leadsto \mathsf{neg}\left(z1 \cdot \left(z1 \cdot \frac{1}{z0 \cdot z2}\right)\right) \]
      10. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(z1\right)\right) \cdot \color{blue}{\left(z1 \cdot \frac{1}{z0 \cdot z2}\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(z1\right)\right) \cdot \color{blue}{\left(z1 \cdot \frac{1}{z0 \cdot z2}\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \left(-z1\right) \cdot \left(\color{blue}{z1} \cdot \frac{1}{z0 \cdot z2}\right) \]
      13. mult-flip-revN/A

        \[\leadsto \left(-z1\right) \cdot \frac{z1}{\color{blue}{z0 \cdot z2}} \]
      14. lower-/.f6446.9%

        \[\leadsto \left(-z1\right) \cdot \frac{z1}{\color{blue}{z0 \cdot z2}} \]
    8. Applied rewrites46.9%

      \[\leadsto \left(-z1\right) \cdot \color{blue}{\frac{z1}{z0 \cdot z2}} \]

    if -2.0000000000000001e57 < (/.f64 z0 (*.f64 z1 z1)) < 2e15

    1. Initial program 83.1%

      \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
    2. Taylor expanded in z2 around 0

      \[\leadsto \frac{-z2}{\color{blue}{z3}} \]
    3. Step-by-step derivation
      1. Applied rewrites51.9%

        \[\leadsto \frac{-z2}{\color{blue}{z3}} \]

      if 2e15 < (/.f64 z0 (*.f64 z1 z1))

      1. Initial program 83.1%

        \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
        2. lift-/.f64N/A

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

          \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
        5. associate-/r*N/A

          \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
        6. lower-/.f64N/A

          \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
        7. associate-*l/N/A

          \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
        8. lower-*.f64N/A

          \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
        9. lower-/.f6492.9%

          \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
      3. Applied rewrites92.9%

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
      4. Taylor expanded in z2 around inf

        \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
      5. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
        2. lower-/.f64N/A

          \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0 \cdot z2}} \]
        3. lower-pow.f64N/A

          \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0} \cdot z2} \]
        4. lower-*.f6443.6%

          \[\leadsto -1 \cdot \frac{{z1}^{2}}{z0 \cdot \color{blue}{z2}} \]
      6. Applied rewrites43.6%

        \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
      7. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
        2. mul-1-negN/A

          \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
        3. lift-/.f64N/A

          \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
        4. lift-pow.f64N/A

          \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
        5. pow2N/A

          \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
        6. lift-*.f64N/A

          \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
        7. lift-*.f64N/A

          \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
        8. associate-/r*N/A

          \[\leadsto \mathsf{neg}\left(\frac{\frac{z1 \cdot z1}{z0}}{z2}\right) \]
        9. distribute-neg-frac2N/A

          \[\leadsto \frac{\frac{z1 \cdot z1}{z0}}{\color{blue}{\mathsf{neg}\left(z2\right)}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{\frac{z1 \cdot z1}{z0}}{\mathsf{neg}\left(z2\right)} \]
        11. associate-/l*N/A

          \[\leadsto \frac{z1 \cdot \frac{z1}{z0}}{\mathsf{neg}\left(\color{blue}{z2}\right)} \]
        12. lift-neg.f64N/A

          \[\leadsto \frac{z1 \cdot \frac{z1}{z0}}{-z2} \]
        13. associate-/l*N/A

          \[\leadsto z1 \cdot \color{blue}{\frac{\frac{z1}{z0}}{-z2}} \]
        14. lower-*.f64N/A

          \[\leadsto z1 \cdot \color{blue}{\frac{\frac{z1}{z0}}{-z2}} \]
        15. lower-/.f64N/A

          \[\leadsto z1 \cdot \frac{\frac{z1}{z0}}{\color{blue}{-z2}} \]
        16. lower-/.f6450.8%

          \[\leadsto z1 \cdot \frac{\frac{z1}{z0}}{-\color{blue}{z2}} \]
      8. Applied rewrites50.8%

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

          \[\leadsto z1 \cdot \color{blue}{\frac{\frac{z1}{z0}}{-z2}} \]
        2. lift-neg.f64N/A

          \[\leadsto z1 \cdot \frac{\frac{z1}{z0}}{\mathsf{neg}\left(z2\right)} \]
        3. lift-/.f64N/A

          \[\leadsto z1 \cdot \frac{\frac{z1}{z0}}{\color{blue}{\mathsf{neg}\left(z2\right)}} \]
        4. associate-*r/N/A

          \[\leadsto \frac{z1 \cdot \frac{z1}{z0}}{\color{blue}{\mathsf{neg}\left(z2\right)}} \]
        5. *-commutativeN/A

          \[\leadsto \frac{\frac{z1}{z0} \cdot z1}{\mathsf{neg}\left(\color{blue}{z2}\right)} \]
        6. lift-*.f64N/A

          \[\leadsto \frac{\frac{z1}{z0} \cdot z1}{\mathsf{neg}\left(\color{blue}{z2}\right)} \]
        7. distribute-neg-frac2N/A

          \[\leadsto \mathsf{neg}\left(\frac{\frac{z1}{z0} \cdot z1}{z2}\right) \]
        8. distribute-neg-fracN/A

          \[\leadsto \frac{\mathsf{neg}\left(\frac{z1}{z0} \cdot z1\right)}{\color{blue}{z2}} \]
        9. lower-/.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(\frac{z1}{z0} \cdot z1\right)}{\color{blue}{z2}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(\frac{z1}{z0} \cdot z1\right)}{z2} \]
        11. distribute-lft-neg-inN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{z1}{z0}\right)\right) \cdot z1}{z2} \]
        12. lower-*.f64N/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{z1}{z0}\right)\right) \cdot z1}{z2} \]
        13. lift-/.f64N/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{z1}{z0}\right)\right) \cdot z1}{z2} \]
        14. distribute-neg-fracN/A

          \[\leadsto \frac{\frac{\mathsf{neg}\left(z1\right)}{z0} \cdot z1}{z2} \]
        15. lift-neg.f64N/A

          \[\leadsto \frac{\frac{-z1}{z0} \cdot z1}{z2} \]
        16. lower-/.f6449.0%

          \[\leadsto \frac{\frac{-z1}{z0} \cdot z1}{z2} \]
      10. Applied rewrites49.0%

        \[\leadsto \frac{\frac{-z1}{z0} \cdot z1}{\color{blue}{z2}} \]
    4. Recombined 3 regimes into one program.
    5. Add Preprocessing

    Alternative 7: 73.9% accurate, 0.6× speedup?

    \[\begin{array}{l} t_0 := \frac{z0}{z1 \cdot z1}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+57}:\\ \;\;\;\;\left(-z1\right) \cdot \frac{z1}{z0 \cdot z2}\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+15}:\\ \;\;\;\;\frac{-z2}{z3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-z1\right) \cdot z1}{z0 \cdot z2}\\ \end{array} \]
    (FPCore (z2 z0 z1 z3)
      :precision binary64
      (let* ((t_0 (/ z0 (* z1 z1))))
      (if (<= t_0 -2e+57)
        (* (- z1) (/ z1 (* z0 z2)))
        (if (<= t_0 2e+15) (/ (- z2) z3) (/ (* (- z1) z1) (* z0 z2))))))
    double code(double z2, double z0, double z1, double z3) {
    	double t_0 = z0 / (z1 * z1);
    	double tmp;
    	if (t_0 <= -2e+57) {
    		tmp = -z1 * (z1 / (z0 * z2));
    	} else if (t_0 <= 2e+15) {
    		tmp = -z2 / z3;
    	} else {
    		tmp = (-z1 * z1) / (z0 * z2);
    	}
    	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(z2, z0, z1, z3)
    use fmin_fmax_functions
        real(8), intent (in) :: z2
        real(8), intent (in) :: z0
        real(8), intent (in) :: z1
        real(8), intent (in) :: z3
        real(8) :: t_0
        real(8) :: tmp
        t_0 = z0 / (z1 * z1)
        if (t_0 <= (-2d+57)) then
            tmp = -z1 * (z1 / (z0 * z2))
        else if (t_0 <= 2d+15) then
            tmp = -z2 / z3
        else
            tmp = (-z1 * z1) / (z0 * z2)
        end if
        code = tmp
    end function
    
    public static double code(double z2, double z0, double z1, double z3) {
    	double t_0 = z0 / (z1 * z1);
    	double tmp;
    	if (t_0 <= -2e+57) {
    		tmp = -z1 * (z1 / (z0 * z2));
    	} else if (t_0 <= 2e+15) {
    		tmp = -z2 / z3;
    	} else {
    		tmp = (-z1 * z1) / (z0 * z2);
    	}
    	return tmp;
    }
    
    def code(z2, z0, z1, z3):
    	t_0 = z0 / (z1 * z1)
    	tmp = 0
    	if t_0 <= -2e+57:
    		tmp = -z1 * (z1 / (z0 * z2))
    	elif t_0 <= 2e+15:
    		tmp = -z2 / z3
    	else:
    		tmp = (-z1 * z1) / (z0 * z2)
    	return tmp
    
    function code(z2, z0, z1, z3)
    	t_0 = Float64(z0 / Float64(z1 * z1))
    	tmp = 0.0
    	if (t_0 <= -2e+57)
    		tmp = Float64(Float64(-z1) * Float64(z1 / Float64(z0 * z2)));
    	elseif (t_0 <= 2e+15)
    		tmp = Float64(Float64(-z2) / z3);
    	else
    		tmp = Float64(Float64(Float64(-z1) * z1) / Float64(z0 * z2));
    	end
    	return tmp
    end
    
    function tmp_2 = code(z2, z0, z1, z3)
    	t_0 = z0 / (z1 * z1);
    	tmp = 0.0;
    	if (t_0 <= -2e+57)
    		tmp = -z1 * (z1 / (z0 * z2));
    	elseif (t_0 <= 2e+15)
    		tmp = -z2 / z3;
    	else
    		tmp = (-z1 * z1) / (z0 * z2);
    	end
    	tmp_2 = tmp;
    end
    
    code[z2_, z0_, z1_, z3_] := Block[{t$95$0 = N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+57], N[((-z1) * N[(z1 / N[(z0 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+15], N[((-z2) / z3), $MachinePrecision], N[(N[((-z1) * z1), $MachinePrecision] / N[(z0 * z2), $MachinePrecision]), $MachinePrecision]]]]
    
    \begin{array}{l}
    t_0 := \frac{z0}{z1 \cdot z1}\\
    \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+57}:\\
    \;\;\;\;\left(-z1\right) \cdot \frac{z1}{z0 \cdot z2}\\
    
    \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+15}:\\
    \;\;\;\;\frac{-z2}{z3}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\left(-z1\right) \cdot z1}{z0 \cdot z2}\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (/.f64 z0 (*.f64 z1 z1)) < -2.0000000000000001e57

      1. Initial program 83.1%

        \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
        2. lift-/.f64N/A

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

          \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
        5. associate-/r*N/A

          \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
        6. lower-/.f64N/A

          \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
        7. associate-*l/N/A

          \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
        8. lower-*.f64N/A

          \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
        9. lower-/.f6492.9%

          \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
      3. Applied rewrites92.9%

        \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
      4. Taylor expanded in z2 around inf

        \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
      5. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
        2. lower-/.f64N/A

          \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0 \cdot z2}} \]
        3. lower-pow.f64N/A

          \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0} \cdot z2} \]
        4. lower-*.f6443.6%

          \[\leadsto -1 \cdot \frac{{z1}^{2}}{z0 \cdot \color{blue}{z2}} \]
      6. Applied rewrites43.6%

        \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
      7. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
        2. mul-1-negN/A

          \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
        3. lift-/.f64N/A

          \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
        4. lift-pow.f64N/A

          \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
        5. pow2N/A

          \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
        6. lift-*.f64N/A

          \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
        7. mult-flipN/A

          \[\leadsto \mathsf{neg}\left(\left(z1 \cdot z1\right) \cdot \frac{1}{z0 \cdot z2}\right) \]
        8. lift-*.f64N/A

          \[\leadsto \mathsf{neg}\left(\left(z1 \cdot z1\right) \cdot \frac{1}{z0 \cdot z2}\right) \]
        9. associate-*l*N/A

          \[\leadsto \mathsf{neg}\left(z1 \cdot \left(z1 \cdot \frac{1}{z0 \cdot z2}\right)\right) \]
        10. distribute-lft-neg-inN/A

          \[\leadsto \left(\mathsf{neg}\left(z1\right)\right) \cdot \color{blue}{\left(z1 \cdot \frac{1}{z0 \cdot z2}\right)} \]
        11. lower-*.f64N/A

          \[\leadsto \left(\mathsf{neg}\left(z1\right)\right) \cdot \color{blue}{\left(z1 \cdot \frac{1}{z0 \cdot z2}\right)} \]
        12. lower-neg.f64N/A

          \[\leadsto \left(-z1\right) \cdot \left(\color{blue}{z1} \cdot \frac{1}{z0 \cdot z2}\right) \]
        13. mult-flip-revN/A

          \[\leadsto \left(-z1\right) \cdot \frac{z1}{\color{blue}{z0 \cdot z2}} \]
        14. lower-/.f6446.9%

          \[\leadsto \left(-z1\right) \cdot \frac{z1}{\color{blue}{z0 \cdot z2}} \]
      8. Applied rewrites46.9%

        \[\leadsto \left(-z1\right) \cdot \color{blue}{\frac{z1}{z0 \cdot z2}} \]

      if -2.0000000000000001e57 < (/.f64 z0 (*.f64 z1 z1)) < 2e15

      1. Initial program 83.1%

        \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
      2. Taylor expanded in z2 around 0

        \[\leadsto \frac{-z2}{\color{blue}{z3}} \]
      3. Step-by-step derivation
        1. Applied rewrites51.9%

          \[\leadsto \frac{-z2}{\color{blue}{z3}} \]

        if 2e15 < (/.f64 z0 (*.f64 z1 z1))

        1. Initial program 83.1%

          \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
          2. lift-/.f64N/A

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

            \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
          4. lift-*.f64N/A

            \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
          5. associate-/r*N/A

            \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
          6. lower-/.f64N/A

            \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
          7. associate-*l/N/A

            \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
          8. lower-*.f64N/A

            \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
          9. lower-/.f6492.9%

            \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
        3. Applied rewrites92.9%

          \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
        4. Taylor expanded in z2 around inf

          \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
        5. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
          2. lower-/.f64N/A

            \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0 \cdot z2}} \]
          3. lower-pow.f64N/A

            \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0} \cdot z2} \]
          4. lower-*.f6443.6%

            \[\leadsto -1 \cdot \frac{{z1}^{2}}{z0 \cdot \color{blue}{z2}} \]
        6. Applied rewrites43.6%

          \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
        7. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
          2. mul-1-negN/A

            \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
          3. lift-/.f64N/A

            \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
          4. lift-pow.f64N/A

            \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
          5. pow2N/A

            \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
          6. lift-*.f64N/A

            \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
          7. distribute-neg-fracN/A

            \[\leadsto \frac{\mathsf{neg}\left(z1 \cdot z1\right)}{\color{blue}{z0 \cdot z2}} \]
          8. lower-/.f64N/A

            \[\leadsto \frac{\mathsf{neg}\left(z1 \cdot z1\right)}{\color{blue}{z0 \cdot z2}} \]
          9. lift-*.f64N/A

            \[\leadsto \frac{\mathsf{neg}\left(z1 \cdot z1\right)}{z0 \cdot z2} \]
          10. distribute-lft-neg-inN/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(z1\right)\right) \cdot z1}{\color{blue}{z0} \cdot z2} \]
          11. lower-*.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(z1\right)\right) \cdot z1}{\color{blue}{z0} \cdot z2} \]
          12. lower-neg.f6443.6%

            \[\leadsto \frac{\left(-z1\right) \cdot z1}{z0 \cdot z2} \]
        8. Applied rewrites43.6%

          \[\leadsto \frac{\left(-z1\right) \cdot z1}{\color{blue}{z0 \cdot z2}} \]
      4. Recombined 3 regimes into one program.
      5. Add Preprocessing

      Alternative 8: 73.0% accurate, 0.6× speedup?

      \[\begin{array}{l} t_0 := \frac{z0}{z1 \cdot z1}\\ t_1 := \left(-z1\right) \cdot \frac{z1}{z0 \cdot z2}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+57}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+15}:\\ \;\;\;\;\frac{-z2}{z3}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
      (FPCore (z2 z0 z1 z3)
        :precision binary64
        (let* ((t_0 (/ z0 (* z1 z1))) (t_1 (* (- z1) (/ z1 (* z0 z2)))))
        (if (<= t_0 -2e+57) t_1 (if (<= t_0 2e+15) (/ (- z2) z3) t_1))))
      double code(double z2, double z0, double z1, double z3) {
      	double t_0 = z0 / (z1 * z1);
      	double t_1 = -z1 * (z1 / (z0 * z2));
      	double tmp;
      	if (t_0 <= -2e+57) {
      		tmp = t_1;
      	} else if (t_0 <= 2e+15) {
      		tmp = -z2 / z3;
      	} 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(z2, z0, z1, z3)
      use fmin_fmax_functions
          real(8), intent (in) :: z2
          real(8), intent (in) :: z0
          real(8), intent (in) :: z1
          real(8), intent (in) :: z3
          real(8) :: t_0
          real(8) :: t_1
          real(8) :: tmp
          t_0 = z0 / (z1 * z1)
          t_1 = -z1 * (z1 / (z0 * z2))
          if (t_0 <= (-2d+57)) then
              tmp = t_1
          else if (t_0 <= 2d+15) then
              tmp = -z2 / z3
          else
              tmp = t_1
          end if
          code = tmp
      end function
      
      public static double code(double z2, double z0, double z1, double z3) {
      	double t_0 = z0 / (z1 * z1);
      	double t_1 = -z1 * (z1 / (z0 * z2));
      	double tmp;
      	if (t_0 <= -2e+57) {
      		tmp = t_1;
      	} else if (t_0 <= 2e+15) {
      		tmp = -z2 / z3;
      	} else {
      		tmp = t_1;
      	}
      	return tmp;
      }
      
      def code(z2, z0, z1, z3):
      	t_0 = z0 / (z1 * z1)
      	t_1 = -z1 * (z1 / (z0 * z2))
      	tmp = 0
      	if t_0 <= -2e+57:
      		tmp = t_1
      	elif t_0 <= 2e+15:
      		tmp = -z2 / z3
      	else:
      		tmp = t_1
      	return tmp
      
      function code(z2, z0, z1, z3)
      	t_0 = Float64(z0 / Float64(z1 * z1))
      	t_1 = Float64(Float64(-z1) * Float64(z1 / Float64(z0 * z2)))
      	tmp = 0.0
      	if (t_0 <= -2e+57)
      		tmp = t_1;
      	elseif (t_0 <= 2e+15)
      		tmp = Float64(Float64(-z2) / z3);
      	else
      		tmp = t_1;
      	end
      	return tmp
      end
      
      function tmp_2 = code(z2, z0, z1, z3)
      	t_0 = z0 / (z1 * z1);
      	t_1 = -z1 * (z1 / (z0 * z2));
      	tmp = 0.0;
      	if (t_0 <= -2e+57)
      		tmp = t_1;
      	elseif (t_0 <= 2e+15)
      		tmp = -z2 / z3;
      	else
      		tmp = t_1;
      	end
      	tmp_2 = tmp;
      end
      
      code[z2_, z0_, z1_, z3_] := Block[{t$95$0 = N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-z1) * N[(z1 / N[(z0 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+57], t$95$1, If[LessEqual[t$95$0, 2e+15], N[((-z2) / z3), $MachinePrecision], t$95$1]]]]
      
      \begin{array}{l}
      t_0 := \frac{z0}{z1 \cdot z1}\\
      t_1 := \left(-z1\right) \cdot \frac{z1}{z0 \cdot z2}\\
      \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+57}:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+15}:\\
      \;\;\;\;\frac{-z2}{z3}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_1\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (/.f64 z0 (*.f64 z1 z1)) < -2.0000000000000001e57 or 2e15 < (/.f64 z0 (*.f64 z1 z1))

        1. Initial program 83.1%

          \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{-z2}{\color{blue}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right)} \cdot z2 + z3} \]
          2. lift-/.f64N/A

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

            \[\leadsto \frac{-z2}{\color{blue}{\frac{z2 \cdot z0}{z1 \cdot z1}} \cdot z2 + z3} \]
          4. lift-*.f64N/A

            \[\leadsto \frac{-z2}{\frac{z2 \cdot z0}{\color{blue}{z1 \cdot z1}} \cdot z2 + z3} \]
          5. associate-/r*N/A

            \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
          6. lower-/.f64N/A

            \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2 \cdot z0}{z1}}{z1}} \cdot z2 + z3} \]
          7. associate-*l/N/A

            \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
          8. lower-*.f64N/A

            \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1} \cdot z0}}{z1} \cdot z2 + z3} \]
          9. lower-/.f6492.9%

            \[\leadsto \frac{-z2}{\frac{\color{blue}{\frac{z2}{z1}} \cdot z0}{z1} \cdot z2 + z3} \]
        3. Applied rewrites92.9%

          \[\leadsto \frac{-z2}{\color{blue}{\frac{\frac{z2}{z1} \cdot z0}{z1}} \cdot z2 + z3} \]
        4. Taylor expanded in z2 around inf

          \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
        5. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
          2. lower-/.f64N/A

            \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0 \cdot z2}} \]
          3. lower-pow.f64N/A

            \[\leadsto -1 \cdot \frac{{z1}^{2}}{\color{blue}{z0} \cdot z2} \]
          4. lower-*.f6443.6%

            \[\leadsto -1 \cdot \frac{{z1}^{2}}{z0 \cdot \color{blue}{z2}} \]
        6. Applied rewrites43.6%

          \[\leadsto \color{blue}{-1 \cdot \frac{{z1}^{2}}{z0 \cdot z2}} \]
        7. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto -1 \cdot \color{blue}{\frac{{z1}^{2}}{z0 \cdot z2}} \]
          2. mul-1-negN/A

            \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
          3. lift-/.f64N/A

            \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
          4. lift-pow.f64N/A

            \[\leadsto \mathsf{neg}\left(\frac{{z1}^{2}}{z0 \cdot z2}\right) \]
          5. pow2N/A

            \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
          6. lift-*.f64N/A

            \[\leadsto \mathsf{neg}\left(\frac{z1 \cdot z1}{z0 \cdot z2}\right) \]
          7. mult-flipN/A

            \[\leadsto \mathsf{neg}\left(\left(z1 \cdot z1\right) \cdot \frac{1}{z0 \cdot z2}\right) \]
          8. lift-*.f64N/A

            \[\leadsto \mathsf{neg}\left(\left(z1 \cdot z1\right) \cdot \frac{1}{z0 \cdot z2}\right) \]
          9. associate-*l*N/A

            \[\leadsto \mathsf{neg}\left(z1 \cdot \left(z1 \cdot \frac{1}{z0 \cdot z2}\right)\right) \]
          10. distribute-lft-neg-inN/A

            \[\leadsto \left(\mathsf{neg}\left(z1\right)\right) \cdot \color{blue}{\left(z1 \cdot \frac{1}{z0 \cdot z2}\right)} \]
          11. lower-*.f64N/A

            \[\leadsto \left(\mathsf{neg}\left(z1\right)\right) \cdot \color{blue}{\left(z1 \cdot \frac{1}{z0 \cdot z2}\right)} \]
          12. lower-neg.f64N/A

            \[\leadsto \left(-z1\right) \cdot \left(\color{blue}{z1} \cdot \frac{1}{z0 \cdot z2}\right) \]
          13. mult-flip-revN/A

            \[\leadsto \left(-z1\right) \cdot \frac{z1}{\color{blue}{z0 \cdot z2}} \]
          14. lower-/.f6446.9%

            \[\leadsto \left(-z1\right) \cdot \frac{z1}{\color{blue}{z0 \cdot z2}} \]
        8. Applied rewrites46.9%

          \[\leadsto \left(-z1\right) \cdot \color{blue}{\frac{z1}{z0 \cdot z2}} \]

        if -2.0000000000000001e57 < (/.f64 z0 (*.f64 z1 z1)) < 2e15

        1. Initial program 83.1%

          \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
        2. Taylor expanded in z2 around 0

          \[\leadsto \frac{-z2}{\color{blue}{z3}} \]
        3. Step-by-step derivation
          1. Applied rewrites51.9%

            \[\leadsto \frac{-z2}{\color{blue}{z3}} \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 9: 51.9% accurate, 3.1× speedup?

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

          \[\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3} \]
        2. Taylor expanded in z2 around 0

          \[\leadsto \frac{-z2}{\color{blue}{z3}} \]
        3. Step-by-step derivation
          1. Applied rewrites51.9%

            \[\leadsto \frac{-z2}{\color{blue}{z3}} \]
          2. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025250 
          (FPCore (z2 z0 z1 z3)
            :name "(/ (- z2) (+ (* (* z2 (/ z0 (* z1 z1))) z2) z3))"
            :precision binary64
            (/ (- z2) (+ (* (* z2 (/ z0 (* z1 z1))) z2) z3)))