(/ (- (log (- 1 z0))) (+ (/ z3 (* z4 z4)) (/ z1 (* z2 z2))))

Percentage Accurate: 65.5% → 88.8%
Time: 4.8s
Alternatives: 13
Speedup: 2.4×

Specification

?
\[\frac{-\log \left(1 - z0\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (/ (- (log (- 1.0 z0))) (+ (/ z3 (* z4 z4)) (/ z1 (* z2 z2)))))
double code(double z0, double z3, double z4, double z1, double z2) {
	return -log((1.0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    code = -log((1.0d0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)))
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	return -Math.log((1.0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)));
}
def code(z0, z3, z4, z1, z2):
	return -math.log((1.0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)))
function code(z0, z3, z4, z1, z2)
	return Float64(Float64(-log(Float64(1.0 - z0))) / Float64(Float64(z3 / Float64(z4 * z4)) + Float64(z1 / Float64(z2 * z2))))
end
function tmp = code(z0, z3, z4, z1, z2)
	tmp = -log((1.0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)));
end
code[z0_, z3_, z4_, z1_, z2_] := N[((-N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision]) / N[(N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision] + N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{-\log \left(1 - z0\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}}

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

\[\frac{-\log \left(1 - z0\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (/ (- (log (- 1.0 z0))) (+ (/ z3 (* z4 z4)) (/ z1 (* z2 z2)))))
double code(double z0, double z3, double z4, double z1, double z2) {
	return -log((1.0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    code = -log((1.0d0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)))
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	return -Math.log((1.0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)));
}
def code(z0, z3, z4, z1, z2):
	return -math.log((1.0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)))
function code(z0, z3, z4, z1, z2)
	return Float64(Float64(-log(Float64(1.0 - z0))) / Float64(Float64(z3 / Float64(z4 * z4)) + Float64(z1 / Float64(z2 * z2))))
end
function tmp = code(z0, z3, z4, z1, z2)
	tmp = -log((1.0 - z0)) / ((z3 / (z4 * z4)) + (z1 / (z2 * z2)));
end
code[z0_, z3_, z4_, z1_, z2_] := N[((-N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision]) / N[(N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision] + N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{-\log \left(1 - z0\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}}

Alternative 1: 88.8% accurate, 0.8× speedup?

\[\begin{array}{l} t_0 := \frac{z1}{\left|z2\right|}\\ t_1 := -\log \left(1 - z0\right)\\ \mathbf{if}\;z0 \leq -5.3 \cdot 10^{+150}:\\ \;\;\;\;\frac{t\_1}{\frac{\frac{z3}{z4}}{z4} + \frac{z1}{\left|z2\right| \cdot \left|z2\right|}}\\ \mathbf{elif}\;z0 \leq -1.15 \cdot 10^{-7}:\\ \;\;\;\;\frac{t\_1}{\frac{\frac{z3}{z4} \cdot \left|z2\right| + t\_0 \cdot z4}{z4 \cdot \left|z2\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\left(-z0\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot \left|z2\right| + t\_0}{\left|z2\right|}}\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (let* ((t_0 (/ z1 (fabs z2))) (t_1 (- (log (- 1.0 z0)))))
  (if (<= z0 -5.3e+150)
    (/ t_1 (+ (/ (/ z3 z4) z4) (/ z1 (* (fabs z2) (fabs z2)))))
    (if (<= z0 -1.15e-7)
      (/
       t_1
       (/ (+ (* (/ z3 z4) (fabs z2)) (* t_0 z4)) (* z4 (fabs z2))))
      (/
       (- (- z0))
       (/ (+ (* (/ z3 (* z4 z4)) (fabs z2)) t_0) (fabs z2)))))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z1 / fabs(z2);
	double t_1 = -log((1.0 - z0));
	double tmp;
	if (z0 <= -5.3e+150) {
		tmp = t_1 / (((z3 / z4) / z4) + (z1 / (fabs(z2) * fabs(z2))));
	} else if (z0 <= -1.15e-7) {
		tmp = t_1 / ((((z3 / z4) * fabs(z2)) + (t_0 * z4)) / (z4 * fabs(z2)));
	} else {
		tmp = -(-z0) / ((((z3 / (z4 * z4)) * fabs(z2)) + t_0) / fabs(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(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = z1 / abs(z2)
    t_1 = -log((1.0d0 - z0))
    if (z0 <= (-5.3d+150)) then
        tmp = t_1 / (((z3 / z4) / z4) + (z1 / (abs(z2) * abs(z2))))
    else if (z0 <= (-1.15d-7)) then
        tmp = t_1 / ((((z3 / z4) * abs(z2)) + (t_0 * z4)) / (z4 * abs(z2)))
    else
        tmp = -(-z0) / ((((z3 / (z4 * z4)) * abs(z2)) + t_0) / abs(z2))
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z1 / Math.abs(z2);
	double t_1 = -Math.log((1.0 - z0));
	double tmp;
	if (z0 <= -5.3e+150) {
		tmp = t_1 / (((z3 / z4) / z4) + (z1 / (Math.abs(z2) * Math.abs(z2))));
	} else if (z0 <= -1.15e-7) {
		tmp = t_1 / ((((z3 / z4) * Math.abs(z2)) + (t_0 * z4)) / (z4 * Math.abs(z2)));
	} else {
		tmp = -(-z0) / ((((z3 / (z4 * z4)) * Math.abs(z2)) + t_0) / Math.abs(z2));
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	t_0 = z1 / math.fabs(z2)
	t_1 = -math.log((1.0 - z0))
	tmp = 0
	if z0 <= -5.3e+150:
		tmp = t_1 / (((z3 / z4) / z4) + (z1 / (math.fabs(z2) * math.fabs(z2))))
	elif z0 <= -1.15e-7:
		tmp = t_1 / ((((z3 / z4) * math.fabs(z2)) + (t_0 * z4)) / (z4 * math.fabs(z2)))
	else:
		tmp = -(-z0) / ((((z3 / (z4 * z4)) * math.fabs(z2)) + t_0) / math.fabs(z2))
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z1 / abs(z2))
	t_1 = Float64(-log(Float64(1.0 - z0)))
	tmp = 0.0
	if (z0 <= -5.3e+150)
		tmp = Float64(t_1 / Float64(Float64(Float64(z3 / z4) / z4) + Float64(z1 / Float64(abs(z2) * abs(z2)))));
	elseif (z0 <= -1.15e-7)
		tmp = Float64(t_1 / Float64(Float64(Float64(Float64(z3 / z4) * abs(z2)) + Float64(t_0 * z4)) / Float64(z4 * abs(z2))));
	else
		tmp = Float64(Float64(-Float64(-z0)) / Float64(Float64(Float64(Float64(z3 / Float64(z4 * z4)) * abs(z2)) + t_0) / abs(z2)));
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	t_0 = z1 / abs(z2);
	t_1 = -log((1.0 - z0));
	tmp = 0.0;
	if (z0 <= -5.3e+150)
		tmp = t_1 / (((z3 / z4) / z4) + (z1 / (abs(z2) * abs(z2))));
	elseif (z0 <= -1.15e-7)
		tmp = t_1 / ((((z3 / z4) * abs(z2)) + (t_0 * z4)) / (z4 * abs(z2)));
	else
		tmp = -(-z0) / ((((z3 / (z4 * z4)) * abs(z2)) + t_0) / abs(z2));
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := Block[{t$95$0 = N[(z1 / N[Abs[z2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision])}, If[LessEqual[z0, -5.3e+150], N[(t$95$1 / N[(N[(N[(z3 / z4), $MachinePrecision] / z4), $MachinePrecision] + N[(z1 / N[(N[Abs[z2], $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z0, -1.15e-7], N[(t$95$1 / N[(N[(N[(N[(z3 / z4), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * z4), $MachinePrecision]), $MachinePrecision] / N[(z4 * N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-(-z0)) / N[(N[(N[(N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \frac{z1}{\left|z2\right|}\\
t_1 := -\log \left(1 - z0\right)\\
\mathbf{if}\;z0 \leq -5.3 \cdot 10^{+150}:\\
\;\;\;\;\frac{t\_1}{\frac{\frac{z3}{z4}}{z4} + \frac{z1}{\left|z2\right| \cdot \left|z2\right|}}\\

\mathbf{elif}\;z0 \leq -1.15 \cdot 10^{-7}:\\
\;\;\;\;\frac{t\_1}{\frac{\frac{z3}{z4} \cdot \left|z2\right| + t\_0 \cdot z4}{z4 \cdot \left|z2\right|}}\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z0 < -5.3000000000000001e150

    1. Initial program 65.5%

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

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

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

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

        \[\leadsto \frac{-\log \left(1 - z0\right)}{\color{blue}{\frac{\frac{z3}{z4}}{z4}} + \frac{z1}{z2 \cdot z2}} \]
      5. lower-/.f6468.3%

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

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

    if -5.3000000000000001e150 < z0 < -1.15e-7

    1. Initial program 65.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{-\log \left(1 - z0\right)}{\frac{\frac{z3}{z4}}{z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      8. common-denominatorN/A

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

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

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

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

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

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

        \[\leadsto \frac{-\log \left(1 - z0\right)}{\frac{\frac{z3}{z4} \cdot z2 + \color{blue}{\frac{z1}{z2}} \cdot z4}{z4 \cdot z2}} \]
      15. lower-*.f6468.9%

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

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

    if -1.15e-7 < z0

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(z0\right)\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}} \]
      3. lift-neg.f6475.6%

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

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

Alternative 2: 88.7% accurate, 0.2× speedup?

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

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-283}:\\
\;\;\;\;\frac{-z0}{\frac{1}{\frac{z2}{\frac{-z1}{z2}}} - t\_1}\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;\frac{t\_0}{t\_1 + \frac{\frac{z1}{z2}}{z2}}\\

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


\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < -2.0000000000000001e-253

    1. Initial program 65.5%

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

    if -2.0000000000000001e-253 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < 5.0000000000000001e-283

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

      \[\leadsto \color{blue}{\frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{z3}{z4 \cdot z4}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{-z0}{\color{blue}{\frac{\frac{z1}{-z2}}{z2}} - \frac{z3}{z4 \cdot z4}} \]
      4. div-flipN/A

        \[\leadsto \frac{-z0}{\color{blue}{\frac{1}{\frac{z2}{\frac{z1}{-z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      5. lower-unsound-/.f64N/A

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

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

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

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

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

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\color{blue}{\frac{\mathsf{neg}\left(z1\right)}{z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      11. lower-neg.f6474.7%

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\frac{\color{blue}{-z1}}{z2}}} - \frac{z3}{z4 \cdot z4}} \]
    8. Applied rewrites74.7%

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

    if 5.0000000000000001e-283 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < 2.0000000000000002e302

    1. Initial program 65.5%

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

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

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

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

        \[\leadsto \frac{-\log \left(1 - z0\right)}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. lower-/.f6468.6%

        \[\leadsto \frac{-\log \left(1 - z0\right)}{\frac{z3}{z4 \cdot z4} + \frac{\color{blue}{\frac{z1}{z2}}}{z2}} \]
    3. Applied rewrites68.6%

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

    if 2.0000000000000002e302 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2))))

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(z0\right)\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}} \]
      3. lift-neg.f6475.6%

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

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \color{blue}{\frac{z1}{z2}}}{z2}} \]
      3. add-to-fractionN/A

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\color{blue}{\frac{\left(\frac{z3}{z4 \cdot z4} \cdot z2\right) \cdot z2 + z1}{z2}}}{z2}} \]
      4. div-flipN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(\frac{z3}{z4 \cdot z4} \cdot z2\right) \cdot z2 + z1}}}}{z2}} \]
      14. lower-*.f6474.4%

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(z2 \cdot \frac{z3}{z4 \cdot z4}\right)} \cdot z2 + z1}}}{z2}} \]
      17. lift-*.f6474.4%

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(z2 \cdot \frac{z3}{z4 \cdot z4}\right)} \cdot z2 + z1}}}{z2}} \]
    10. Applied rewrites74.4%

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

Alternative 3: 87.7% accurate, 0.2× speedup?

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

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-283}:\\
\;\;\;\;\frac{-z0}{\frac{1}{\frac{z2}{\frac{-z1}{z2}}} - t\_0}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < -2.0000000000000001e-253 or 5.0000000000000001e-283 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < 2.0000000000000002e302

    1. Initial program 65.5%

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

    if -2.0000000000000001e-253 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < 5.0000000000000001e-283

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

      \[\leadsto \color{blue}{\frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{z3}{z4 \cdot z4}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{-z0}{\color{blue}{\frac{\frac{z1}{-z2}}{z2}} - \frac{z3}{z4 \cdot z4}} \]
      4. div-flipN/A

        \[\leadsto \frac{-z0}{\color{blue}{\frac{1}{\frac{z2}{\frac{z1}{-z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      5. lower-unsound-/.f64N/A

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

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

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

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

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

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\color{blue}{\frac{\mathsf{neg}\left(z1\right)}{z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      11. lower-neg.f6474.7%

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\frac{\color{blue}{-z1}}{z2}}} - \frac{z3}{z4 \cdot z4}} \]
    8. Applied rewrites74.7%

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

    if 2.0000000000000002e302 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2))))

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(z0\right)\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}} \]
      3. lift-neg.f6475.6%

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

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \color{blue}{\frac{z1}{z2}}}{z2}} \]
      3. add-to-fractionN/A

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\color{blue}{\frac{\left(\frac{z3}{z4 \cdot z4} \cdot z2\right) \cdot z2 + z1}{z2}}}{z2}} \]
      4. div-flipN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(\frac{z3}{z4 \cdot z4} \cdot z2\right) \cdot z2 + z1}}}}{z2}} \]
      14. lower-*.f6474.4%

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(z2 \cdot \frac{z3}{z4 \cdot z4}\right)} \cdot z2 + z1}}}{z2}} \]
      17. lift-*.f6474.4%

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(z2 \cdot \frac{z3}{z4 \cdot z4}\right)} \cdot z2 + z1}}}{z2}} \]
    10. Applied rewrites74.4%

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

Alternative 4: 85.7% accurate, 0.9× speedup?

\[\begin{array}{l} \mathbf{if}\;z0 \leq -4.2 \cdot 10^{+50}:\\ \;\;\;\;\frac{-\log \left(1 - z0\right)}{\frac{\frac{z3}{z4}}{z4} + \frac{z1}{z2 \cdot z2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-z0}{\frac{1}{\frac{z2}{\frac{-z1}{z2}}} - \frac{z3}{z4 \cdot z4}}\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (if (<= z0 -4.2e+50)
  (/ (- (log (- 1.0 z0))) (+ (/ (/ z3 z4) z4) (/ z1 (* z2 z2))))
  (/ (- z0) (- (/ 1.0 (/ z2 (/ (- z1) z2))) (/ z3 (* z4 z4))))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (z0 <= -4.2e+50) {
		tmp = -log((1.0 - z0)) / (((z3 / z4) / z4) + (z1 / (z2 * z2)));
	} else {
		tmp = -z0 / ((1.0 / (z2 / (-z1 / z2))) - (z3 / (z4 * z4)));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8) :: tmp
    if (z0 <= (-4.2d+50)) then
        tmp = -log((1.0d0 - z0)) / (((z3 / z4) / z4) + (z1 / (z2 * z2)))
    else
        tmp = -z0 / ((1.0d0 / (z2 / (-z1 / z2))) - (z3 / (z4 * z4)))
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (z0 <= -4.2e+50) {
		tmp = -Math.log((1.0 - z0)) / (((z3 / z4) / z4) + (z1 / (z2 * z2)));
	} else {
		tmp = -z0 / ((1.0 / (z2 / (-z1 / z2))) - (z3 / (z4 * z4)));
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	tmp = 0
	if z0 <= -4.2e+50:
		tmp = -math.log((1.0 - z0)) / (((z3 / z4) / z4) + (z1 / (z2 * z2)))
	else:
		tmp = -z0 / ((1.0 / (z2 / (-z1 / z2))) - (z3 / (z4 * z4)))
	return tmp
function code(z0, z3, z4, z1, z2)
	tmp = 0.0
	if (z0 <= -4.2e+50)
		tmp = Float64(Float64(-log(Float64(1.0 - z0))) / Float64(Float64(Float64(z3 / z4) / z4) + Float64(z1 / Float64(z2 * z2))));
	else
		tmp = Float64(Float64(-z0) / Float64(Float64(1.0 / Float64(z2 / Float64(Float64(-z1) / z2))) - Float64(z3 / Float64(z4 * z4))));
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	tmp = 0.0;
	if (z0 <= -4.2e+50)
		tmp = -log((1.0 - z0)) / (((z3 / z4) / z4) + (z1 / (z2 * z2)));
	else
		tmp = -z0 / ((1.0 / (z2 / (-z1 / z2))) - (z3 / (z4 * z4)));
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := If[LessEqual[z0, -4.2e+50], N[((-N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision]) / N[(N[(N[(z3 / z4), $MachinePrecision] / z4), $MachinePrecision] + N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-z0) / N[(N[(1.0 / N[(z2 / N[((-z1) / z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z0 \leq -4.2 \cdot 10^{+50}:\\
\;\;\;\;\frac{-\log \left(1 - z0\right)}{\frac{\frac{z3}{z4}}{z4} + \frac{z1}{z2 \cdot z2}}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < -4.1999999999999999e50

    1. Initial program 65.5%

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

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

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

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

        \[\leadsto \frac{-\log \left(1 - z0\right)}{\color{blue}{\frac{\frac{z3}{z4}}{z4}} + \frac{z1}{z2 \cdot z2}} \]
      5. lower-/.f6468.3%

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

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

    if -4.1999999999999999e50 < z0

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

      \[\leadsto \color{blue}{\frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{z3}{z4 \cdot z4}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{-z0}{\color{blue}{\frac{\frac{z1}{-z2}}{z2}} - \frac{z3}{z4 \cdot z4}} \]
      4. div-flipN/A

        \[\leadsto \frac{-z0}{\color{blue}{\frac{1}{\frac{z2}{\frac{z1}{-z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      5. lower-unsound-/.f64N/A

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

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

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

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

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

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\color{blue}{\frac{\mathsf{neg}\left(z1\right)}{z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      11. lower-neg.f6474.7%

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\frac{\color{blue}{-z1}}{z2}}} - \frac{z3}{z4 \cdot z4}} \]
    8. Applied rewrites74.7%

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

Alternative 5: 83.9% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{-z0}{\frac{1}{\frac{z2}{\frac{-z1}{z2}}} - t\_0}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < -1.55e50

    1. Initial program 65.5%

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{-1}{z0}\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-log.f64N/A

        \[\leadsto \frac{\log \left(\frac{-1}{z0}\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      2. lower-/.f6442.3%

        \[\leadsto \frac{\log \left(\frac{-1}{z0}\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    4. Applied rewrites42.3%

      \[\leadsto \frac{\color{blue}{\log \left(\frac{-1}{z0}\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    5. Step-by-step derivation
      1. lift-log.f64N/A

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

        \[\leadsto \frac{\log \left(\frac{-1}{z0}\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. frac-2negN/A

        \[\leadsto \frac{\log \left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(z0\right)}\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      4. metadata-evalN/A

        \[\leadsto \frac{\log \left(\frac{1}{\mathsf{neg}\left(z0\right)}\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      5. log-recN/A

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(\mathsf{neg}\left(z0\right)\right)\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      6. lower-log.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(\mathsf{neg}\left(z0\right)\right)\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      7. lower-unsound-log.f64N/A

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

        \[\leadsto \frac{-\log \left(\mathsf{neg}\left(z0\right)\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      9. lower-unsound-log.f64N/A

        \[\leadsto \frac{-\log \left(\mathsf{neg}\left(z0\right)\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      10. lower-neg.f6442.3%

        \[\leadsto \frac{-\log \left(-z0\right)}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    6. Applied rewrites42.3%

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

    if -1.55e50 < z0

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

      \[\leadsto \color{blue}{\frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{z3}{z4 \cdot z4}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{-z0}{\color{blue}{\frac{\frac{z1}{-z2}}{z2}} - \frac{z3}{z4 \cdot z4}} \]
      4. div-flipN/A

        \[\leadsto \frac{-z0}{\color{blue}{\frac{1}{\frac{z2}{\frac{z1}{-z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      5. lower-unsound-/.f64N/A

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

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

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

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

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

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\color{blue}{\frac{\mathsf{neg}\left(z1\right)}{z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      11. lower-neg.f6474.7%

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\frac{\color{blue}{-z1}}{z2}}} - \frac{z3}{z4 \cdot z4}} \]
    8. Applied rewrites74.7%

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

Alternative 6: 81.7% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \log \left(1 - z0\right)\\ t_1 := \frac{z3}{z4 \cdot z4}\\ t_2 := \frac{-t\_0}{t\_1 + \frac{z1}{z2 \cdot z2}}\\ t_3 := \frac{z2 \cdot t\_0}{z1} \cdot \left(-z2\right)\\ \mathbf{if}\;t\_2 \leq -1 \cdot 10^{-78}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-283}:\\ \;\;\;\;\frac{-z0}{\frac{1}{\frac{z2}{\frac{-z1}{z2}}} - t\_1}\\ \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+92}:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;\frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\left(z2 \cdot t\_1\right) \cdot z2 + z1}}}{z2}}\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (let* ((t_0 (log (- 1.0 z0)))
       (t_1 (/ z3 (* z4 z4)))
       (t_2 (/ (- t_0) (+ t_1 (/ z1 (* z2 z2)))))
       (t_3 (* (/ (* z2 t_0) z1) (- z2))))
  (if (<= t_2 -1e-78)
    t_3
    (if (<= t_2 5e-283)
      (/ (- z0) (- (/ 1.0 (/ z2 (/ (- z1) z2))) t_1))
      (if (<= t_2 4e+92)
        t_3
        (/
         (- (- z0))
         (/ (/ 1.0 (/ z2 (+ (* (* z2 t_1) z2) z1))) z2)))))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = log((1.0 - z0));
	double t_1 = z3 / (z4 * z4);
	double t_2 = -t_0 / (t_1 + (z1 / (z2 * z2)));
	double t_3 = ((z2 * t_0) / z1) * -z2;
	double tmp;
	if (t_2 <= -1e-78) {
		tmp = t_3;
	} else if (t_2 <= 5e-283) {
		tmp = -z0 / ((1.0 / (z2 / (-z1 / z2))) - t_1);
	} else if (t_2 <= 4e+92) {
		tmp = t_3;
	} else {
		tmp = -(-z0) / ((1.0 / (z2 / (((z2 * t_1) * z2) + 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(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = log((1.0d0 - z0))
    t_1 = z3 / (z4 * z4)
    t_2 = -t_0 / (t_1 + (z1 / (z2 * z2)))
    t_3 = ((z2 * t_0) / z1) * -z2
    if (t_2 <= (-1d-78)) then
        tmp = t_3
    else if (t_2 <= 5d-283) then
        tmp = -z0 / ((1.0d0 / (z2 / (-z1 / z2))) - t_1)
    else if (t_2 <= 4d+92) then
        tmp = t_3
    else
        tmp = -(-z0) / ((1.0d0 / (z2 / (((z2 * t_1) * z2) + z1))) / z2)
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = Math.log((1.0 - z0));
	double t_1 = z3 / (z4 * z4);
	double t_2 = -t_0 / (t_1 + (z1 / (z2 * z2)));
	double t_3 = ((z2 * t_0) / z1) * -z2;
	double tmp;
	if (t_2 <= -1e-78) {
		tmp = t_3;
	} else if (t_2 <= 5e-283) {
		tmp = -z0 / ((1.0 / (z2 / (-z1 / z2))) - t_1);
	} else if (t_2 <= 4e+92) {
		tmp = t_3;
	} else {
		tmp = -(-z0) / ((1.0 / (z2 / (((z2 * t_1) * z2) + z1))) / z2);
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	t_0 = math.log((1.0 - z0))
	t_1 = z3 / (z4 * z4)
	t_2 = -t_0 / (t_1 + (z1 / (z2 * z2)))
	t_3 = ((z2 * t_0) / z1) * -z2
	tmp = 0
	if t_2 <= -1e-78:
		tmp = t_3
	elif t_2 <= 5e-283:
		tmp = -z0 / ((1.0 / (z2 / (-z1 / z2))) - t_1)
	elif t_2 <= 4e+92:
		tmp = t_3
	else:
		tmp = -(-z0) / ((1.0 / (z2 / (((z2 * t_1) * z2) + z1))) / z2)
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = log(Float64(1.0 - z0))
	t_1 = Float64(z3 / Float64(z4 * z4))
	t_2 = Float64(Float64(-t_0) / Float64(t_1 + Float64(z1 / Float64(z2 * z2))))
	t_3 = Float64(Float64(Float64(z2 * t_0) / z1) * Float64(-z2))
	tmp = 0.0
	if (t_2 <= -1e-78)
		tmp = t_3;
	elseif (t_2 <= 5e-283)
		tmp = Float64(Float64(-z0) / Float64(Float64(1.0 / Float64(z2 / Float64(Float64(-z1) / z2))) - t_1));
	elseif (t_2 <= 4e+92)
		tmp = t_3;
	else
		tmp = Float64(Float64(-Float64(-z0)) / Float64(Float64(1.0 / Float64(z2 / Float64(Float64(Float64(z2 * t_1) * z2) + z1))) / z2));
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	t_0 = log((1.0 - z0));
	t_1 = z3 / (z4 * z4);
	t_2 = -t_0 / (t_1 + (z1 / (z2 * z2)));
	t_3 = ((z2 * t_0) / z1) * -z2;
	tmp = 0.0;
	if (t_2 <= -1e-78)
		tmp = t_3;
	elseif (t_2 <= 5e-283)
		tmp = -z0 / ((1.0 / (z2 / (-z1 / z2))) - t_1);
	elseif (t_2 <= 4e+92)
		tmp = t_3;
	else
		tmp = -(-z0) / ((1.0 / (z2 / (((z2 * t_1) * z2) + z1))) / z2);
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := Block[{t$95$0 = N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-t$95$0) / N[(t$95$1 + N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(z2 * t$95$0), $MachinePrecision] / z1), $MachinePrecision] * (-z2)), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-78], t$95$3, If[LessEqual[t$95$2, 5e-283], N[((-z0) / N[(N[(1.0 / N[(z2 / N[((-z1) / z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e+92], t$95$3, N[((-(-z0)) / N[(N[(1.0 / N[(z2 / N[(N[(N[(z2 * t$95$1), $MachinePrecision] * z2), $MachinePrecision] + z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \log \left(1 - z0\right)\\
t_1 := \frac{z3}{z4 \cdot z4}\\
t_2 := \frac{-t\_0}{t\_1 + \frac{z1}{z2 \cdot z2}}\\
t_3 := \frac{z2 \cdot t\_0}{z1} \cdot \left(-z2\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-78}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-283}:\\
\;\;\;\;\frac{-z0}{\frac{1}{\frac{z2}{\frac{-z1}{z2}}} - t\_1}\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+92}:\\
\;\;\;\;t\_3\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < -1e-78 or 5.0000000000000001e-283 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < 4.0000000000000002e92

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\color{blue}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}}} \]
      3. frac-2negN/A

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}\right)\right)}{\color{blue}{-z2}}} \]
      5. associate-/r/N/A

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

        \[\leadsto \color{blue}{\frac{--1 \cdot z0}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}\right)\right)} \cdot \left(-z2\right)} \]
    8. Applied rewrites72.0%

      \[\leadsto \color{blue}{\frac{-\left(-z0\right)}{\frac{-z1}{z2} - z2 \cdot \frac{z3}{z4 \cdot z4}} \cdot \left(-z2\right)} \]
    9. Taylor expanded in z3 around 0

      \[\leadsto \color{blue}{\frac{z2 \cdot \log \left(1 - z0\right)}{z1}} \cdot \left(-z2\right) \]
    10. Step-by-step derivation
      1. lower-/.f64N/A

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

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

        \[\leadsto \frac{z2 \cdot \log \left(1 - z0\right)}{z1} \cdot \left(-z2\right) \]
      4. lower--.f6458.8%

        \[\leadsto \frac{z2 \cdot \log \left(1 - z0\right)}{z1} \cdot \left(-z2\right) \]
    11. Applied rewrites58.8%

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

    if -1e-78 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))) < 5.0000000000000001e-283

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

      \[\leadsto \color{blue}{\frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{z3}{z4 \cdot z4}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{-z0}{\color{blue}{\frac{\frac{z1}{-z2}}{z2}} - \frac{z3}{z4 \cdot z4}} \]
      4. div-flipN/A

        \[\leadsto \frac{-z0}{\color{blue}{\frac{1}{\frac{z2}{\frac{z1}{-z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      5. lower-unsound-/.f64N/A

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

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

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

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

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

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\color{blue}{\frac{\mathsf{neg}\left(z1\right)}{z2}}}} - \frac{z3}{z4 \cdot z4}} \]
      11. lower-neg.f6474.7%

        \[\leadsto \frac{-z0}{\frac{1}{\frac{z2}{\frac{\color{blue}{-z1}}{z2}}} - \frac{z3}{z4 \cdot z4}} \]
    8. Applied rewrites74.7%

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

    if 4.0000000000000002e92 < (/.f64 (neg.f64 (log.f64 (-.f64 #s(literal 1 binary64) z0))) (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2))))

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(z0\right)\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}} \]
      3. lift-neg.f6475.6%

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

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \color{blue}{\frac{z1}{z2}}}{z2}} \]
      3. add-to-fractionN/A

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\color{blue}{\frac{\left(\frac{z3}{z4 \cdot z4} \cdot z2\right) \cdot z2 + z1}{z2}}}{z2}} \]
      4. div-flipN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(\frac{z3}{z4 \cdot z4} \cdot z2\right) \cdot z2 + z1}}}}{z2}} \]
      14. lower-*.f6474.4%

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(z2 \cdot \frac{z3}{z4 \cdot z4}\right)} \cdot z2 + z1}}}{z2}} \]
      17. lift-*.f6474.4%

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(z2 \cdot \frac{z3}{z4 \cdot z4}\right)} \cdot z2 + z1}}}{z2}} \]
    10. Applied rewrites74.4%

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

Alternative 7: 78.2% accurate, 1.6× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|z2\right| \leq 3.95 \cdot 10^{+208}:\\ \;\;\;\;\frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{\left|z2\right|}{\left(\left|z2\right| \cdot \frac{z3}{z4 \cdot z4}\right) \cdot \left|z2\right| + z1}}}{\left|z2\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-z0}{\frac{z1}{\left(-\left|z2\right|\right) \cdot \left|z2\right|} - \frac{z3}{z4} \cdot \frac{1}{z4}}\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (if (<= (fabs z2) 3.95e+208)
  (/
   (- (- z0))
   (/
    (/
     1.0
     (/
      (fabs z2)
      (+ (* (* (fabs z2) (/ z3 (* z4 z4))) (fabs z2)) z1)))
    (fabs z2)))
  (/
   (- z0)
   (- (/ z1 (* (- (fabs z2)) (fabs z2))) (* (/ z3 z4) (/ 1.0 z4))))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (fabs(z2) <= 3.95e+208) {
		tmp = -(-z0) / ((1.0 / (fabs(z2) / (((fabs(z2) * (z3 / (z4 * z4))) * fabs(z2)) + z1))) / fabs(z2));
	} else {
		tmp = -z0 / ((z1 / (-fabs(z2) * fabs(z2))) - ((z3 / z4) * (1.0 / z4)));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8) :: tmp
    if (abs(z2) <= 3.95d+208) then
        tmp = -(-z0) / ((1.0d0 / (abs(z2) / (((abs(z2) * (z3 / (z4 * z4))) * abs(z2)) + z1))) / abs(z2))
    else
        tmp = -z0 / ((z1 / (-abs(z2) * abs(z2))) - ((z3 / z4) * (1.0d0 / z4)))
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (Math.abs(z2) <= 3.95e+208) {
		tmp = -(-z0) / ((1.0 / (Math.abs(z2) / (((Math.abs(z2) * (z3 / (z4 * z4))) * Math.abs(z2)) + z1))) / Math.abs(z2));
	} else {
		tmp = -z0 / ((z1 / (-Math.abs(z2) * Math.abs(z2))) - ((z3 / z4) * (1.0 / z4)));
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	tmp = 0
	if math.fabs(z2) <= 3.95e+208:
		tmp = -(-z0) / ((1.0 / (math.fabs(z2) / (((math.fabs(z2) * (z3 / (z4 * z4))) * math.fabs(z2)) + z1))) / math.fabs(z2))
	else:
		tmp = -z0 / ((z1 / (-math.fabs(z2) * math.fabs(z2))) - ((z3 / z4) * (1.0 / z4)))
	return tmp
function code(z0, z3, z4, z1, z2)
	tmp = 0.0
	if (abs(z2) <= 3.95e+208)
		tmp = Float64(Float64(-Float64(-z0)) / Float64(Float64(1.0 / Float64(abs(z2) / Float64(Float64(Float64(abs(z2) * Float64(z3 / Float64(z4 * z4))) * abs(z2)) + z1))) / abs(z2)));
	else
		tmp = Float64(Float64(-z0) / Float64(Float64(z1 / Float64(Float64(-abs(z2)) * abs(z2))) - Float64(Float64(z3 / z4) * Float64(1.0 / z4))));
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	tmp = 0.0;
	if (abs(z2) <= 3.95e+208)
		tmp = -(-z0) / ((1.0 / (abs(z2) / (((abs(z2) * (z3 / (z4 * z4))) * abs(z2)) + z1))) / abs(z2));
	else
		tmp = -z0 / ((z1 / (-abs(z2) * abs(z2))) - ((z3 / z4) * (1.0 / z4)));
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := If[LessEqual[N[Abs[z2], $MachinePrecision], 3.95e+208], N[((-(-z0)) / N[(N[(1.0 / N[(N[Abs[z2], $MachinePrecision] / N[(N[(N[(N[Abs[z2], $MachinePrecision] * N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-z0) / N[(N[(z1 / N[((-N[Abs[z2], $MachinePrecision]) * N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(z3 / z4), $MachinePrecision] * N[(1.0 / z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 3.95 \cdot 10^{+208}:\\
\;\;\;\;\frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{\left|z2\right|}{\left(\left|z2\right| \cdot \frac{z3}{z4 \cdot z4}\right) \cdot \left|z2\right| + z1}}}{\left|z2\right|}}\\

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


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

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(z0\right)\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}} \]
      3. lift-neg.f6475.6%

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

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \color{blue}{\frac{z1}{z2}}}{z2}} \]
      3. add-to-fractionN/A

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\color{blue}{\frac{\left(\frac{z3}{z4 \cdot z4} \cdot z2\right) \cdot z2 + z1}{z2}}}{z2}} \]
      4. div-flipN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(\frac{z3}{z4 \cdot z4} \cdot z2\right) \cdot z2 + z1}}}}{z2}} \]
      14. lower-*.f6474.4%

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

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

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(z2 \cdot \frac{z3}{z4 \cdot z4}\right)} \cdot z2 + z1}}}{z2}} \]
      17. lift-*.f6474.4%

        \[\leadsto \frac{-\left(-z0\right)}{\frac{\frac{1}{\frac{z2}{\color{blue}{\left(z2 \cdot \frac{z3}{z4 \cdot z4}\right)} \cdot z2 + z1}}}{z2}} \]
    10. Applied rewrites74.4%

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

    if 3.95e208 < z2

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

      \[\leadsto \color{blue}{\frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{z3}{z4 \cdot z4}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

        \[\leadsto \frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{\color{blue}{\frac{z3}{z4}}}{z4}} \]
      5. mult-flipN/A

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

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

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

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

Alternative 8: 77.5% accurate, 1.5× speedup?

\[\begin{array}{l} t_0 := \frac{z3}{z4 \cdot z4}\\ \mathbf{if}\;t\_0 + \frac{z1}{z2 \cdot z2} \leq \infty:\\ \;\;\;\;\frac{--1 \cdot z0}{t\_0 + \frac{\frac{z1}{z2}}{z2}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-\left(-z0\right)}{\left(z2 \cdot t\_0\right) \cdot z2 + z1} \cdot z2\right) \cdot z2\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (let* ((t_0 (/ z3 (* z4 z4))))
  (if (<= (+ t_0 (/ z1 (* z2 z2))) INFINITY)
    (/ (- (* -1.0 z0)) (+ t_0 (/ (/ z1 z2) z2)))
    (* (* (/ (- (- z0)) (+ (* (* z2 t_0) z2) z1)) z2) z2))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z3 / (z4 * z4);
	double tmp;
	if ((t_0 + (z1 / (z2 * z2))) <= ((double) INFINITY)) {
		tmp = -(-1.0 * z0) / (t_0 + ((z1 / z2) / z2));
	} else {
		tmp = ((-(-z0) / (((z2 * t_0) * z2) + z1)) * z2) * z2;
	}
	return tmp;
}
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z3 / (z4 * z4);
	double tmp;
	if ((t_0 + (z1 / (z2 * z2))) <= Double.POSITIVE_INFINITY) {
		tmp = -(-1.0 * z0) / (t_0 + ((z1 / z2) / z2));
	} else {
		tmp = ((-(-z0) / (((z2 * t_0) * z2) + z1)) * z2) * z2;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	t_0 = z3 / (z4 * z4)
	tmp = 0
	if (t_0 + (z1 / (z2 * z2))) <= math.inf:
		tmp = -(-1.0 * z0) / (t_0 + ((z1 / z2) / z2))
	else:
		tmp = ((-(-z0) / (((z2 * t_0) * z2) + z1)) * z2) * z2
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z3 / Float64(z4 * z4))
	tmp = 0.0
	if (Float64(t_0 + Float64(z1 / Float64(z2 * z2))) <= Inf)
		tmp = Float64(Float64(-Float64(-1.0 * z0)) / Float64(t_0 + Float64(Float64(z1 / z2) / z2)));
	else
		tmp = Float64(Float64(Float64(Float64(-Float64(-z0)) / Float64(Float64(Float64(z2 * t_0) * z2) + z1)) * z2) * z2);
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	t_0 = z3 / (z4 * z4);
	tmp = 0.0;
	if ((t_0 + (z1 / (z2 * z2))) <= Inf)
		tmp = -(-1.0 * z0) / (t_0 + ((z1 / z2) / z2));
	else
		tmp = ((-(-z0) / (((z2 * t_0) * z2) + z1)) * z2) * z2;
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := Block[{t$95$0 = N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 + N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[((-N[(-1.0 * z0), $MachinePrecision]) / N[(t$95$0 + N[(N[(z1 / z2), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[((-(-z0)) / N[(N[(N[(z2 * t$95$0), $MachinePrecision] * z2), $MachinePrecision] + z1), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision] * z2), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{z3}{z4 \cdot z4}\\
\mathbf{if}\;t\_0 + \frac{z1}{z2 \cdot z2} \leq \infty:\\
\;\;\;\;\frac{--1 \cdot z0}{t\_0 + \frac{\frac{z1}{z2}}{z2}}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2))) < +inf.0

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. lower-/.f6474.8%

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \frac{\color{blue}{\frac{z1}{z2}}}{z2}} \]
    6. Applied rewrites74.8%

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

    if +inf.0 < (+.f64 (/.f64 z3 (*.f64 z4 z4)) (/.f64 z1 (*.f64 z2 z2)))

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

Alternative 9: 77.4% accurate, 2.1× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|z2\right| \leq 3.6 \cdot 10^{-118}:\\ \;\;\;\;\left(\frac{-\left(-z0\right)}{\left(\left|z2\right| \cdot \frac{z3}{z4 \cdot z4}\right) \cdot \left|z2\right| + z1} \cdot \left|z2\right|\right) \cdot \left|z2\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{-z0}{\frac{z1}{\left(-\left|z2\right|\right) \cdot \left|z2\right|} - \frac{\frac{z3}{z4}}{z4}}\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (if (<= (fabs z2) 3.6e-118)
  (*
   (*
    (/ (- (- z0)) (+ (* (* (fabs z2) (/ z3 (* z4 z4))) (fabs z2)) z1))
    (fabs z2))
   (fabs z2))
  (/ (- z0) (- (/ z1 (* (- (fabs z2)) (fabs z2))) (/ (/ z3 z4) z4)))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (fabs(z2) <= 3.6e-118) {
		tmp = ((-(-z0) / (((fabs(z2) * (z3 / (z4 * z4))) * fabs(z2)) + z1)) * fabs(z2)) * fabs(z2);
	} else {
		tmp = -z0 / ((z1 / (-fabs(z2) * fabs(z2))) - ((z3 / z4) / z4));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8) :: tmp
    if (abs(z2) <= 3.6d-118) then
        tmp = ((-(-z0) / (((abs(z2) * (z3 / (z4 * z4))) * abs(z2)) + z1)) * abs(z2)) * abs(z2)
    else
        tmp = -z0 / ((z1 / (-abs(z2) * abs(z2))) - ((z3 / z4) / z4))
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (Math.abs(z2) <= 3.6e-118) {
		tmp = ((-(-z0) / (((Math.abs(z2) * (z3 / (z4 * z4))) * Math.abs(z2)) + z1)) * Math.abs(z2)) * Math.abs(z2);
	} else {
		tmp = -z0 / ((z1 / (-Math.abs(z2) * Math.abs(z2))) - ((z3 / z4) / z4));
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	tmp = 0
	if math.fabs(z2) <= 3.6e-118:
		tmp = ((-(-z0) / (((math.fabs(z2) * (z3 / (z4 * z4))) * math.fabs(z2)) + z1)) * math.fabs(z2)) * math.fabs(z2)
	else:
		tmp = -z0 / ((z1 / (-math.fabs(z2) * math.fabs(z2))) - ((z3 / z4) / z4))
	return tmp
function code(z0, z3, z4, z1, z2)
	tmp = 0.0
	if (abs(z2) <= 3.6e-118)
		tmp = Float64(Float64(Float64(Float64(-Float64(-z0)) / Float64(Float64(Float64(abs(z2) * Float64(z3 / Float64(z4 * z4))) * abs(z2)) + z1)) * abs(z2)) * abs(z2));
	else
		tmp = Float64(Float64(-z0) / Float64(Float64(z1 / Float64(Float64(-abs(z2)) * abs(z2))) - Float64(Float64(z3 / z4) / z4)));
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	tmp = 0.0;
	if (abs(z2) <= 3.6e-118)
		tmp = ((-(-z0) / (((abs(z2) * (z3 / (z4 * z4))) * abs(z2)) + z1)) * abs(z2)) * abs(z2);
	else
		tmp = -z0 / ((z1 / (-abs(z2) * abs(z2))) - ((z3 / z4) / z4));
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := If[LessEqual[N[Abs[z2], $MachinePrecision], 3.6e-118], N[(N[(N[((-(-z0)) / N[(N[(N[(N[Abs[z2], $MachinePrecision] * N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + z1), $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision], N[((-z0) / N[(N[(z1 / N[((-N[Abs[z2], $MachinePrecision]) * N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(z3 / z4), $MachinePrecision] / z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 3.6 \cdot 10^{-118}:\\
\;\;\;\;\left(\frac{-\left(-z0\right)}{\left(\left|z2\right| \cdot \frac{z3}{z4 \cdot z4}\right) \cdot \left|z2\right| + z1} \cdot \left|z2\right|\right) \cdot \left|z2\right|\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z2 < 3.6000000000000002e-118

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

    if 3.6000000000000002e-118 < z2

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

      \[\leadsto \color{blue}{\frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{z3}{z4 \cdot z4}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

        \[\leadsto \frac{-z0}{\frac{z1}{\left(-z2\right) \cdot z2} - \frac{\color{blue}{\frac{z3}{z4}}}{z4}} \]
      5. lower-/.f6475.1%

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

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

Alternative 10: 75.0% accurate, 2.1× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z2 < 3.9999999999999999e-118

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

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

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

    if 3.9999999999999999e-118 < z2

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

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

Alternative 11: 74.6% accurate, 2.4× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|z2\right| \leq 4.1 \cdot 10^{-118}:\\ \;\;\;\;\left(-z0\right) \cdot \frac{-1}{\frac{\frac{z1}{\left|z2\right|}}{\left|z2\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-z0}{\frac{z1}{\left(-\left|z2\right|\right) \cdot \left|z2\right|} - \frac{z3}{z4 \cdot z4}}\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (if (<= (fabs z2) 4.1e-118)
  (* (- z0) (/ -1.0 (/ (/ z1 (fabs z2)) (fabs z2))))
  (/ (- z0) (- (/ z1 (* (- (fabs z2)) (fabs z2))) (/ z3 (* z4 z4))))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (fabs(z2) <= 4.1e-118) {
		tmp = -z0 * (-1.0 / ((z1 / fabs(z2)) / fabs(z2)));
	} else {
		tmp = -z0 / ((z1 / (-fabs(z2) * fabs(z2))) - (z3 / (z4 * z4)));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8) :: tmp
    if (abs(z2) <= 4.1d-118) then
        tmp = -z0 * ((-1.0d0) / ((z1 / abs(z2)) / abs(z2)))
    else
        tmp = -z0 / ((z1 / (-abs(z2) * abs(z2))) - (z3 / (z4 * z4)))
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (Math.abs(z2) <= 4.1e-118) {
		tmp = -z0 * (-1.0 / ((z1 / Math.abs(z2)) / Math.abs(z2)));
	} else {
		tmp = -z0 / ((z1 / (-Math.abs(z2) * Math.abs(z2))) - (z3 / (z4 * z4)));
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	tmp = 0
	if math.fabs(z2) <= 4.1e-118:
		tmp = -z0 * (-1.0 / ((z1 / math.fabs(z2)) / math.fabs(z2)))
	else:
		tmp = -z0 / ((z1 / (-math.fabs(z2) * math.fabs(z2))) - (z3 / (z4 * z4)))
	return tmp
function code(z0, z3, z4, z1, z2)
	tmp = 0.0
	if (abs(z2) <= 4.1e-118)
		tmp = Float64(Float64(-z0) * Float64(-1.0 / Float64(Float64(z1 / abs(z2)) / abs(z2))));
	else
		tmp = Float64(Float64(-z0) / Float64(Float64(z1 / Float64(Float64(-abs(z2)) * abs(z2))) - Float64(z3 / Float64(z4 * z4))));
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	tmp = 0.0;
	if (abs(z2) <= 4.1e-118)
		tmp = -z0 * (-1.0 / ((z1 / abs(z2)) / abs(z2)));
	else
		tmp = -z0 / ((z1 / (-abs(z2) * abs(z2))) - (z3 / (z4 * z4)));
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := If[LessEqual[N[Abs[z2], $MachinePrecision], 4.1e-118], N[((-z0) * N[(-1.0 / N[(N[(z1 / N[Abs[z2], $MachinePrecision]), $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-z0) / N[(N[(z1 / N[((-N[Abs[z2], $MachinePrecision]) * N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z3 / N[(z4 * z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 4.1 \cdot 10^{-118}:\\
\;\;\;\;\left(-z0\right) \cdot \frac{-1}{\frac{\frac{z1}{\left|z2\right|}}{\left|z2\right|}}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z2 < 4.1000000000000003e-118

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

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

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

        \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
      5. add-to-fractionN/A

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

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

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

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

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

      \[\leadsto \frac{--1 \cdot z0}{\color{blue}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}}} \]
    7. Taylor expanded in z3 around 0

      \[\leadsto \frac{--1 \cdot z0}{\frac{\color{blue}{\frac{z1}{z2}}}{z2}} \]
    8. Step-by-step derivation
      1. lower-/.f6447.7%

        \[\leadsto \frac{--1 \cdot z0}{\frac{\frac{z1}{\color{blue}{z2}}}{z2}} \]
    9. Applied rewrites47.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(-z0\right)\right)\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\frac{\frac{z1}{z2}}{z2}\right)} \]
      10. remove-double-negN/A

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

        \[\leadsto \color{blue}{\left(-z0\right) \cdot \frac{1}{\mathsf{neg}\left(\frac{\frac{z1}{z2}}{z2}\right)}} \]
    11. Applied rewrites47.5%

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

    if 4.1000000000000003e-118 < z2

    1. Initial program 65.5%

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

      \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1 \cdot z0\right)}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
      3. distribute-frac-negN/A

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

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{z0}}{\mathsf{neg}\left(\left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)} \]
      7. mul-1-negN/A

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

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

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(lift-+.f64, \left(\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}\right)\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{neg}\left(\mathsf{Rewrite=>}\left(add-flip, \left(\frac{z3}{z4 \cdot z4} - \left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right)\right)\right)\right)} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(sub-negate, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \frac{-z0}{\mathsf{Rewrite=>}\left(lower--.f64, \left(\left(\mathsf{neg}\left(\frac{z1}{z2 \cdot z2}\right)\right) - \frac{z3}{z4 \cdot z4}\right)\right)} \]
    6. Applied rewrites71.9%

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

Alternative 12: 47.7% accurate, 4.0× speedup?

\[\frac{-\left(-z0\right)}{\frac{\frac{z1}{z2}}{z2}} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (/ (- (- z0)) (/ (/ z1 z2) z2)))
double code(double z0, double z3, double z4, double z1, double z2) {
	return -(-z0) / ((z1 / z2) / z2);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    code = -(-z0) / ((z1 / z2) / z2)
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	return -(-z0) / ((z1 / z2) / z2);
}
def code(z0, z3, z4, z1, z2):
	return -(-z0) / ((z1 / z2) / z2)
function code(z0, z3, z4, z1, z2)
	return Float64(Float64(-Float64(-z0)) / Float64(Float64(z1 / z2) / z2))
end
function tmp = code(z0, z3, z4, z1, z2)
	tmp = -(-z0) / ((z1 / z2) / z2);
end
code[z0_, z3_, z4_, z1_, z2_] := N[((-(-z0)) / N[(N[(z1 / z2), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision]
\frac{-\left(-z0\right)}{\frac{\frac{z1}{z2}}{z2}}
Derivation
  1. Initial program 65.5%

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

    \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
  3. Step-by-step derivation
    1. lower-*.f6471.8%

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

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

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

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

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

      \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
    5. add-to-fractionN/A

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

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

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

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

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

    \[\leadsto \frac{--1 \cdot z0}{\color{blue}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}}} \]
  7. Taylor expanded in z3 around 0

    \[\leadsto \frac{--1 \cdot z0}{\frac{\color{blue}{\frac{z1}{z2}}}{z2}} \]
  8. Step-by-step derivation
    1. lower-/.f6447.7%

      \[\leadsto \frac{--1 \cdot z0}{\frac{\frac{z1}{\color{blue}{z2}}}{z2}} \]
  9. Applied rewrites47.7%

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

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

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

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

      \[\leadsto \frac{\mathsf{neg}\left(\left(-z0\right)\right)}{\frac{\frac{z1}{z2}}{z2}} \]
    5. lift-neg.f6447.7%

      \[\leadsto \frac{\color{blue}{-\left(-z0\right)}}{\frac{\frac{z1}{z2}}{z2}} \]
  11. Applied rewrites47.7%

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

Alternative 13: 47.3% accurate, 4.8× speedup?

\[\frac{z2}{\frac{z1}{z2}} \cdot \left(-\left(-z0\right)\right) \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (* (/ z2 (/ z1 z2)) (- (- z0))))
double code(double z0, double z3, double z4, double z1, double z2) {
	return (z2 / (z1 / z2)) * -(-z0);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    code = (z2 / (z1 / z2)) * -(-z0)
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	return (z2 / (z1 / z2)) * -(-z0);
}
def code(z0, z3, z4, z1, z2):
	return (z2 / (z1 / z2)) * -(-z0)
function code(z0, z3, z4, z1, z2)
	return Float64(Float64(z2 / Float64(z1 / z2)) * Float64(-Float64(-z0)))
end
function tmp = code(z0, z3, z4, z1, z2)
	tmp = (z2 / (z1 / z2)) * -(-z0);
end
code[z0_, z3_, z4_, z1_, z2_] := N[(N[(z2 / N[(z1 / z2), $MachinePrecision]), $MachinePrecision] * (-(-z0))), $MachinePrecision]
\frac{z2}{\frac{z1}{z2}} \cdot \left(-\left(-z0\right)\right)
Derivation
  1. Initial program 65.5%

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

    \[\leadsto \frac{-\color{blue}{-1 \cdot z0}}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
  3. Step-by-step derivation
    1. lower-*.f6471.8%

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

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

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

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

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

      \[\leadsto \frac{--1 \cdot z0}{\frac{z3}{z4 \cdot z4} + \color{blue}{\frac{\frac{z1}{z2}}{z2}}} \]
    5. add-to-fractionN/A

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

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

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

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

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

    \[\leadsto \frac{--1 \cdot z0}{\color{blue}{\frac{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}{z2}}} \]
  7. Taylor expanded in z3 around 0

    \[\leadsto \frac{--1 \cdot z0}{\frac{\color{blue}{\frac{z1}{z2}}}{z2}} \]
  8. Step-by-step derivation
    1. lower-/.f6447.7%

      \[\leadsto \frac{--1 \cdot z0}{\frac{\frac{z1}{\color{blue}{z2}}}{z2}} \]
  9. Applied rewrites47.7%

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

      \[\leadsto \color{blue}{\frac{--1 \cdot z0}{\frac{\frac{z1}{z2}}{z2}}} \]
    2. mult-flipN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z2}{\frac{z1}{z2}}} \cdot \left(-\left(-z0\right)\right) \]
    12. lower-/.f6447.3%

      \[\leadsto \color{blue}{\frac{z2}{\frac{z1}{z2}}} \cdot \left(-\left(-z0\right)\right) \]
  11. Applied rewrites47.3%

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

Reproduce

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