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

Percentage Accurate: 65.6% → 90.7%
Time: 4.5s
Alternatives: 13
Speedup: 2.3×

Specification

?
\[\frac{\log \left(1 - z0\right)}{\frac{z3}{\left(-z4\right) \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(log(Float64(1.0 - z0)) / Float64(Float64(z3 / Float64(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}{\left(-z4\right) \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.6% accurate, 1.0× speedup?

\[\frac{\log \left(1 - z0\right)}{\frac{z3}{\left(-z4\right) \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(log(Float64(1.0 - z0)) / Float64(Float64(z3 / Float64(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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}

Alternative 1: 90.7% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \frac{z3}{\left(-z4\right) \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}{t\_0 - \frac{1}{\frac{z2}{\frac{z1}{z2}}}}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+302}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-z0}{\frac{\frac{z1}{z2} \cdot z4 + \frac{z3}{z4} \cdot z2}{-z4}} \cdot \frac{1}{\frac{1}{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) (- t_0 (/ 1.0 (/ z2 (/ z1 z2)))))
      (if (<= t_1 2e+302)
        t_1
        (*
         (/ (- z0) (/ (+ (* (/ z1 z2) z4) (* (/ z3 z4) z2)) (- z4)))
         (/ 1.0 (/ 1.0 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 / (t_0 - (1.0 / (z2 / (z1 / z2))));
	} else if (t_1 <= 2e+302) {
		tmp = t_1;
	} else {
		tmp = (-z0 / ((((z1 / z2) * z4) + ((z3 / z4) * z2)) / -z4)) * (1.0 / (1.0 / 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 / (t_0 - (1.0d0 / (z2 / (z1 / z2))))
    else if (t_1 <= 2d+302) then
        tmp = t_1
    else
        tmp = (-z0 / ((((z1 / z2) * z4) + ((z3 / z4) * z2)) / -z4)) * (1.0d0 / (1.0d0 / 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 / (t_0 - (1.0 / (z2 / (z1 / z2))));
	} else if (t_1 <= 2e+302) {
		tmp = t_1;
	} else {
		tmp = (-z0 / ((((z1 / z2) * z4) + ((z3 / z4) * z2)) / -z4)) * (1.0 / (1.0 / 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 / (t_0 - (1.0 / (z2 / (z1 / z2))))
	elif t_1 <= 2e+302:
		tmp = t_1
	else:
		tmp = (-z0 / ((((z1 / z2) * z4) + ((z3 / z4) * z2)) / -z4)) * (1.0 / (1.0 / z2))
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z3 / Float64(Float64(-z4) * z4))
	t_1 = 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(t_0 - Float64(1.0 / Float64(z2 / Float64(z1 / z2)))));
	elseif (t_1 <= 2e+302)
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(-z0) / Float64(Float64(Float64(Float64(z1 / z2) * z4) + Float64(Float64(z3 / z4) * z2)) / Float64(-z4))) * Float64(1.0 / Float64(1.0 / 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 / (t_0 - (1.0 / (z2 / (z1 / z2))));
	elseif (t_1 <= 2e+302)
		tmp = t_1;
	else
		tmp = (-z0 / ((((z1 / z2) * z4) + ((z3 / z4) * z2)) / -z4)) * (1.0 / (1.0 / 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[(t$95$0 - N[(1.0 / N[(z2 / N[(z1 / z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+302], t$95$1, N[(N[((-z0) / N[(N[(N[(N[(z1 / z2), $MachinePrecision] * z4), $MachinePrecision] + N[(N[(z3 / z4), $MachinePrecision] * z2), $MachinePrecision]), $MachinePrecision] / (-z4)), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 / z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{z3}{\left(-z4\right) \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}{t\_0 - \frac{1}{\frac{z2}{\frac{z1}{z2}}}}\\

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

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


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

    1. Initial program 65.6%

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

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

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

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

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

Alternative 2: 88.4% accurate, 0.9× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < -7.8000000000000005e-7

    1. Initial program 65.6%

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

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

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

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

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

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

        \[\leadsto \left(-\log \left(1 - z0\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      7. sub-negate-revN/A

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

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

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

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

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

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

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

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

    if -7.8000000000000005e-7 < z0

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

Alternative 3: 87.6% accurate, 0.9× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < -1.6500000000000001e-6

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

    if -1.6500000000000001e-6 < z0

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

Alternative 4: 78.2% accurate, 0.6× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (log.f64 (-.f64 #s(literal 1 binary64) z0)) < 250

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

    if 250 < (log.f64 (-.f64 #s(literal 1 binary64) z0))

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      5. lower--.f6459.7%

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    6. Applied rewrites59.7%

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

        \[\leadsto \left(-1 \cdot \color{blue}{\frac{z4 \cdot \log \left(1 - z0\right)}{z3}}\right) \cdot z4 \]
      2. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right)\right) \cdot z4 \]
      3. lower-neg.f6459.7%

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

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

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

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

        \[\leadsto \left(-\frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      8. *-commutativeN/A

        \[\leadsto \left(-\frac{\log \left(1 - z0\right) \cdot z4}{z3}\right) \cdot z4 \]
      9. associate-/l*N/A

        \[\leadsto \left(-\log \left(1 - z0\right) \cdot \frac{z4}{z3}\right) \cdot z4 \]
      10. lower-/.f32N/A

        \[\leadsto \left(-\log \left(1 - z0\right) \cdot \frac{z4}{z3}\right) \cdot z4 \]
      11. lower-unsound-/.f32N/A

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

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

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

        \[\leadsto \left(-\log \left(1 - z0\right) \cdot \frac{z4}{z3}\right) \cdot z4 \]
      15. lower-unsound-/.f6456.6%

        \[\leadsto \left(-\log \left(1 - z0\right) \cdot \frac{z4}{z3}\right) \cdot z4 \]
    8. Applied rewrites56.6%

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

Alternative 5: 77.2% accurate, 1.6× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|z2\right| \leq 9 \cdot 10^{+208}:\\ \;\;\;\;\frac{-1 \cdot z0}{\frac{\frac{1}{\frac{\left|z2\right|}{\left(\left|z2\right| \cdot \frac{z3}{\left(-z4\right) \cdot z4}\right) \cdot \left|z2\right| - z1}}}{\left|z2\right|}}\\ \mathbf{else}:\\ \;\;\;\;\left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(-0.5 \cdot z4 + -0.3333333333333333 \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (if (<= (fabs z2) 9e+208)
  (/
   (* -1.0 z0)
   (/
    (/
     1.0
     (/
      (fabs z2)
      (- (* (* (fabs z2) (/ z3 (* (- z4) z4))) (fabs z2)) z1)))
    (fabs z2)))
  (*
   (*
    -1.0
    (/
     (*
      z0
      (+
       (* -1.0 z4)
       (* z0 (+ (* -0.5 z4) (* -0.3333333333333333 (* z0 z4))))))
     z3))
   z4)))
double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (fabs(z2) <= 9e+208) {
		tmp = (-1.0 * z0) / ((1.0 / (fabs(z2) / (((fabs(z2) * (z3 / (-z4 * z4))) * fabs(z2)) - z1))) / fabs(z2));
	} else {
		tmp = (-1.0 * ((z0 * ((-1.0 * z4) + (z0 * ((-0.5 * z4) + (-0.3333333333333333 * (z0 * z4)))))) / z3)) * 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) <= 9d+208) then
        tmp = ((-1.0d0) * z0) / ((1.0d0 / (abs(z2) / (((abs(z2) * (z3 / (-z4 * z4))) * abs(z2)) - z1))) / abs(z2))
    else
        tmp = ((-1.0d0) * ((z0 * (((-1.0d0) * z4) + (z0 * (((-0.5d0) * z4) + ((-0.3333333333333333d0) * (z0 * z4)))))) / z3)) * 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) <= 9e+208) {
		tmp = (-1.0 * z0) / ((1.0 / (Math.abs(z2) / (((Math.abs(z2) * (z3 / (-z4 * z4))) * Math.abs(z2)) - z1))) / Math.abs(z2));
	} else {
		tmp = (-1.0 * ((z0 * ((-1.0 * z4) + (z0 * ((-0.5 * z4) + (-0.3333333333333333 * (z0 * z4)))))) / z3)) * z4;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	tmp = 0
	if math.fabs(z2) <= 9e+208:
		tmp = (-1.0 * z0) / ((1.0 / (math.fabs(z2) / (((math.fabs(z2) * (z3 / (-z4 * z4))) * math.fabs(z2)) - z1))) / math.fabs(z2))
	else:
		tmp = (-1.0 * ((z0 * ((-1.0 * z4) + (z0 * ((-0.5 * z4) + (-0.3333333333333333 * (z0 * z4)))))) / z3)) * z4
	return tmp
function code(z0, z3, z4, z1, z2)
	tmp = 0.0
	if (abs(z2) <= 9e+208)
		tmp = Float64(Float64(-1.0 * z0) / Float64(Float64(1.0 / Float64(abs(z2) / Float64(Float64(Float64(abs(z2) * Float64(z3 / Float64(Float64(-z4) * z4))) * abs(z2)) - z1))) / abs(z2)));
	else
		tmp = Float64(Float64(-1.0 * Float64(Float64(z0 * Float64(Float64(-1.0 * z4) + Float64(z0 * Float64(Float64(-0.5 * z4) + Float64(-0.3333333333333333 * Float64(z0 * z4)))))) / z3)) * z4);
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	tmp = 0.0;
	if (abs(z2) <= 9e+208)
		tmp = (-1.0 * z0) / ((1.0 / (abs(z2) / (((abs(z2) * (z3 / (-z4 * z4))) * abs(z2)) - z1))) / abs(z2));
	else
		tmp = (-1.0 * ((z0 * ((-1.0 * z4) + (z0 * ((-0.5 * z4) + (-0.3333333333333333 * (z0 * z4)))))) / z3)) * z4;
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := If[LessEqual[N[Abs[z2], $MachinePrecision], 9e+208], N[(N[(-1.0 * z0), $MachinePrecision] / 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[(N[(-1.0 * N[(N[(z0 * N[(N[(-1.0 * z4), $MachinePrecision] + N[(z0 * N[(N[(-0.5 * z4), $MachinePrecision] + N[(-0.3333333333333333 * N[(z0 * z4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z3), $MachinePrecision]), $MachinePrecision] * z4), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 9 \cdot 10^{+208}:\\
\;\;\;\;\frac{-1 \cdot z0}{\frac{\frac{1}{\frac{\left|z2\right|}{\left(\left|z2\right| \cdot \frac{z3}{\left(-z4\right) \cdot z4}\right) \cdot \left|z2\right| - z1}}}{\left|z2\right|}}\\

\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(-0.5 \cdot z4 + -0.3333333333333333 \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4\\


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

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.0000000000000003e208 < z2

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      5. lower--.f6459.7%

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    6. Applied rewrites59.7%

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

      \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(\frac{-1}{2} \cdot z4 + \frac{-1}{3} \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(\frac{-1}{2} \cdot z4 + \frac{-1}{3} \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
      2. lower-+.f64N/A

        \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(\frac{-1}{2} \cdot z4 + \frac{-1}{3} \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
      3. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(\frac{-1}{2} \cdot z4 + \frac{-1}{3} \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
      4. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(\frac{-1}{2} \cdot z4 + \frac{-1}{3} \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
      5. lower-+.f64N/A

        \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(\frac{-1}{2} \cdot z4 + \frac{-1}{3} \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
      6. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(\frac{-1}{2} \cdot z4 + \frac{-1}{3} \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
      7. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(\frac{-1}{2} \cdot z4 + \frac{-1}{3} \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
      8. lower-*.f6443.3%

        \[\leadsto \left(-1 \cdot \frac{z0 \cdot \left(-1 \cdot z4 + z0 \cdot \left(-0.5 \cdot z4 + -0.3333333333333333 \cdot \left(z0 \cdot z4\right)\right)\right)}{z3}\right) \cdot z4 \]
    9. Applied rewrites43.3%

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

Alternative 6: 77.0% accurate, 2.1× speedup?

\[\begin{array}{l} t_0 := \frac{z3}{\left(-z4\right) \cdot z4}\\ \mathbf{if}\;\left|z2\right| \leq 4 \cdot 10^{-118}:\\ \;\;\;\;\left(\frac{-z0}{\left(\left|z2\right| \cdot t\_0\right) \cdot \left|z2\right| - z1} \cdot \left|z2\right|\right) \cdot \left|z2\right|\\ \mathbf{elif}\;\left|z2\right| \leq 3.6 \cdot 10^{+199}:\\ \;\;\;\;\frac{-\left(-z0\right)}{\frac{z1}{\left|z2\right| \cdot \left|z2\right|} - t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{z4}{z3} \cdot z0\right) \cdot z4\\ \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))
    (if (<= (fabs z2) 3.6e+199)
      (/ (- (- z0)) (- (/ z1 (* (fabs z2) (fabs z2))) t_0))
      (* (* (/ z4 z3) z0) z4)))))
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 if (fabs(z2) <= 3.6e+199) {
		tmp = -(-z0) / ((z1 / (fabs(z2) * fabs(z2))) - t_0);
	} else {
		tmp = ((z4 / z3) * z0) * 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) :: 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 if (abs(z2) <= 3.6d+199) then
        tmp = -(-z0) / ((z1 / (abs(z2) * abs(z2))) - t_0)
    else
        tmp = ((z4 / z3) * z0) * z4
    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 if (Math.abs(z2) <= 3.6e+199) {
		tmp = -(-z0) / ((z1 / (Math.abs(z2) * Math.abs(z2))) - t_0);
	} else {
		tmp = ((z4 / z3) * z0) * z4;
	}
	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)
	elif math.fabs(z2) <= 3.6e+199:
		tmp = -(-z0) / ((z1 / (math.fabs(z2) * math.fabs(z2))) - t_0)
	else:
		tmp = ((z4 / z3) * z0) * z4
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z3 / Float64(Float64(-z4) * z4))
	tmp = 0.0
	if (abs(z2) <= 4e-118)
		tmp = Float64(Float64(Float64(Float64(-z0) / Float64(Float64(Float64(abs(z2) * t_0) * abs(z2)) - z1)) * abs(z2)) * abs(z2));
	elseif (abs(z2) <= 3.6e+199)
		tmp = Float64(Float64(-Float64(-z0)) / Float64(Float64(z1 / Float64(abs(z2) * abs(z2))) - t_0));
	else
		tmp = Float64(Float64(Float64(z4 / z3) * z0) * z4);
	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);
	elseif (abs(z2) <= 3.6e+199)
		tmp = -(-z0) / ((z1 / (abs(z2) * abs(z2))) - t_0);
	else
		tmp = ((z4 / z3) * z0) * z4;
	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], If[LessEqual[N[Abs[z2], $MachinePrecision], 3.6e+199], N[((-(-z0)) / N[(N[(z1 / N[(N[Abs[z2], $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z4 / z3), $MachinePrecision] * z0), $MachinePrecision] * z4), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{z3}{\left(-z4\right) \cdot z4}\\
\mathbf{if}\;\left|z2\right| \leq 4 \cdot 10^{-118}:\\
\;\;\;\;\left(\frac{-z0}{\left(\left|z2\right| \cdot t\_0\right) \cdot \left|z2\right| - z1} \cdot \left|z2\right|\right) \cdot \left|z2\right|\\

\mathbf{elif}\;\left|z2\right| \leq 3.6 \cdot 10^{+199}:\\
\;\;\;\;\frac{-\left(-z0\right)}{\frac{z1}{\left|z2\right| \cdot \left|z2\right|} - t\_0}\\

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


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

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-1 \cdot z0}{\color{blue}{\frac{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} \cdot z2 - \frac{z1}{z2}}{z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

    if 3.9999999999999999e-118 < z2 < 3.6e199

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. frac-2negN/A

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

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

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

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

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

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

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

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

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

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

    if 3.6e199 < z2

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      5. lower--.f6459.7%

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    6. Applied rewrites59.7%

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

      \[\leadsto \frac{z0 \cdot z4}{\color{blue}{z3}} \cdot z4 \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lower-*.f6446.6%

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    9. Applied rewrites46.6%

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

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      3. associate-/l*N/A

        \[\leadsto \left(z0 \cdot \frac{z4}{\color{blue}{z3}}\right) \cdot z4 \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      6. lower-/.f6447.0%

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
    11. Applied rewrites47.0%

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

Alternative 7: 76.7% accurate, 2.1× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|z2\right| \leq 4.1 \cdot 10^{-118}:\\ \;\;\;\;\frac{-1 \cdot z0}{\frac{-1 \cdot \frac{z1}{\left|z2\right|}}{\left|z2\right|}}\\ \mathbf{elif}\;\left|z2\right| \leq 9 \cdot 10^{+208}:\\ \;\;\;\;\frac{-\left(-z0\right)}{\frac{z1}{\left|z2\right| \cdot \left|z2\right|} - \frac{z3}{\left(-z4\right) \cdot z4}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{z4}{z3} \cdot z0\right) \cdot z4\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (if (<= (fabs z2) 4.1e-118)
  (/ (* -1.0 z0) (/ (* -1.0 (/ z1 (fabs z2))) (fabs z2)))
  (if (<= (fabs z2) 9e+208)
    (/
     (- (- z0))
     (- (/ z1 (* (fabs z2) (fabs z2))) (/ z3 (* (- z4) z4))))
    (* (* (/ z4 z3) z0) z4))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (fabs(z2) <= 4.1e-118) {
		tmp = (-1.0 * z0) / ((-1.0 * (z1 / fabs(z2))) / fabs(z2));
	} else if (fabs(z2) <= 9e+208) {
		tmp = -(-z0) / ((z1 / (fabs(z2) * fabs(z2))) - (z3 / (-z4 * z4)));
	} else {
		tmp = ((z4 / z3) * z0) * 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 = ((-1.0d0) * z0) / (((-1.0d0) * (z1 / abs(z2))) / abs(z2))
    else if (abs(z2) <= 9d+208) then
        tmp = -(-z0) / ((z1 / (abs(z2) * abs(z2))) - (z3 / (-z4 * z4)))
    else
        tmp = ((z4 / z3) * z0) * 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 = (-1.0 * z0) / ((-1.0 * (z1 / Math.abs(z2))) / Math.abs(z2));
	} else if (Math.abs(z2) <= 9e+208) {
		tmp = -(-z0) / ((z1 / (Math.abs(z2) * Math.abs(z2))) - (z3 / (-z4 * z4)));
	} else {
		tmp = ((z4 / z3) * z0) * z4;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	tmp = 0
	if math.fabs(z2) <= 4.1e-118:
		tmp = (-1.0 * z0) / ((-1.0 * (z1 / math.fabs(z2))) / math.fabs(z2))
	elif math.fabs(z2) <= 9e+208:
		tmp = -(-z0) / ((z1 / (math.fabs(z2) * math.fabs(z2))) - (z3 / (-z4 * z4)))
	else:
		tmp = ((z4 / z3) * z0) * z4
	return tmp
function code(z0, z3, z4, z1, z2)
	tmp = 0.0
	if (abs(z2) <= 4.1e-118)
		tmp = Float64(Float64(-1.0 * z0) / Float64(Float64(-1.0 * Float64(z1 / abs(z2))) / abs(z2)));
	elseif (abs(z2) <= 9e+208)
		tmp = Float64(Float64(-Float64(-z0)) / Float64(Float64(z1 / Float64(abs(z2) * abs(z2))) - Float64(z3 / Float64(Float64(-z4) * z4))));
	else
		tmp = Float64(Float64(Float64(z4 / z3) * z0) * z4);
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	tmp = 0.0;
	if (abs(z2) <= 4.1e-118)
		tmp = (-1.0 * z0) / ((-1.0 * (z1 / abs(z2))) / abs(z2));
	elseif (abs(z2) <= 9e+208)
		tmp = -(-z0) / ((z1 / (abs(z2) * abs(z2))) - (z3 / (-z4 * z4)));
	else
		tmp = ((z4 / z3) * z0) * z4;
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := If[LessEqual[N[Abs[z2], $MachinePrecision], 4.1e-118], N[(N[(-1.0 * z0), $MachinePrecision] / N[(N[(-1.0 * N[(z1 / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[z2], $MachinePrecision], 9e+208], 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], N[(N[(N[(z4 / z3), $MachinePrecision] * z0), $MachinePrecision] * z4), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 4.1 \cdot 10^{-118}:\\
\;\;\;\;\frac{-1 \cdot z0}{\frac{-1 \cdot \frac{z1}{\left|z2\right|}}{\left|z2\right|}}\\

\mathbf{elif}\;\left|z2\right| \leq 9 \cdot 10^{+208}:\\
\;\;\;\;\frac{-\left(-z0\right)}{\frac{z1}{\left|z2\right| \cdot \left|z2\right|} - \frac{z3}{\left(-z4\right) \cdot z4}}\\

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


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

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot z0}{\frac{-1 \cdot \color{blue}{\frac{z1}{z2}}}{z2}} \]
      2. lower-/.f6447.7%

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

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

    if 4.1000000000000003e-118 < z2 < 9.0000000000000003e208

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. frac-2negN/A

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

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

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

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

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

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

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

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

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

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

    if 9.0000000000000003e208 < z2

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      5. lower--.f6459.7%

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    6. Applied rewrites59.7%

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

      \[\leadsto \frac{z0 \cdot z4}{\color{blue}{z3}} \cdot z4 \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lower-*.f6446.6%

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    9. Applied rewrites46.6%

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

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      3. associate-/l*N/A

        \[\leadsto \left(z0 \cdot \frac{z4}{\color{blue}{z3}}\right) \cdot z4 \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      6. lower-/.f6447.0%

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
    11. Applied rewrites47.0%

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

Alternative 8: 76.5% accurate, 0.7× speedup?

\[\begin{array}{l} t_0 := \frac{z3}{\left(-z4\right) \cdot z4}\\ \mathbf{if}\;\frac{\log \left(1 - z0\right)}{t\_0 - \frac{z1}{z2 \cdot z2}} \leq 5 \cdot 10^{+16}:\\ \;\;\;\;\frac{-1 \cdot z0}{t\_0 - \frac{\frac{z1}{z2}}{z2}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{z4}{z3} \cdot z0\right) \cdot z4\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (let* ((t_0 (/ z3 (* (- z4) z4))))
  (if (<= (/ (log (- 1.0 z0)) (- t_0 (/ z1 (* z2 z2)))) 5e+16)
    (/ (* -1.0 z0) (- t_0 (/ (/ z1 z2) z2)))
    (* (* (/ z4 z3) z0) z4))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z3 / (-z4 * z4);
	double tmp;
	if ((log((1.0 - z0)) / (t_0 - (z1 / (z2 * z2)))) <= 5e+16) {
		tmp = (-1.0 * z0) / (t_0 - ((z1 / z2) / z2));
	} else {
		tmp = ((z4 / z3) * z0) * 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) :: t_0
    real(8) :: tmp
    t_0 = z3 / (-z4 * z4)
    if ((log((1.0d0 - z0)) / (t_0 - (z1 / (z2 * z2)))) <= 5d+16) then
        tmp = ((-1.0d0) * z0) / (t_0 - ((z1 / z2) / z2))
    else
        tmp = ((z4 / z3) * z0) * z4
    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.log((1.0 - z0)) / (t_0 - (z1 / (z2 * z2)))) <= 5e+16) {
		tmp = (-1.0 * z0) / (t_0 - ((z1 / z2) / z2));
	} else {
		tmp = ((z4 / z3) * z0) * z4;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	t_0 = z3 / (-z4 * z4)
	tmp = 0
	if (math.log((1.0 - z0)) / (t_0 - (z1 / (z2 * z2)))) <= 5e+16:
		tmp = (-1.0 * z0) / (t_0 - ((z1 / z2) / z2))
	else:
		tmp = ((z4 / z3) * z0) * z4
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z3 / Float64(Float64(-z4) * z4))
	tmp = 0.0
	if (Float64(log(Float64(1.0 - z0)) / Float64(t_0 - Float64(z1 / Float64(z2 * z2)))) <= 5e+16)
		tmp = Float64(Float64(-1.0 * z0) / Float64(t_0 - Float64(Float64(z1 / z2) / z2)));
	else
		tmp = Float64(Float64(Float64(z4 / z3) * z0) * z4);
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	t_0 = z3 / (-z4 * z4);
	tmp = 0.0;
	if ((log((1.0 - z0)) / (t_0 - (z1 / (z2 * z2)))) <= 5e+16)
		tmp = (-1.0 * z0) / (t_0 - ((z1 / z2) / z2));
	else
		tmp = ((z4 / z3) * z0) * z4;
	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[(N[Log[N[(1.0 - z0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+16], N[(N[(-1.0 * z0), $MachinePrecision] / N[(t$95$0 - N[(N[(z1 / z2), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z4 / z3), $MachinePrecision] * z0), $MachinePrecision] * z4), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{z3}{\left(-z4\right) \cdot z4}\\
\mathbf{if}\;\frac{\log \left(1 - z0\right)}{t\_0 - \frac{z1}{z2 \cdot z2}} \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{-1 \cdot z0}{t\_0 - \frac{\frac{z1}{z2}}{z2}}\\

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


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

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

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

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

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

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

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

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

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

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

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      5. lower--.f6459.7%

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    6. Applied rewrites59.7%

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

      \[\leadsto \frac{z0 \cdot z4}{\color{blue}{z3}} \cdot z4 \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lower-*.f6446.6%

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    9. Applied rewrites46.6%

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

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      3. associate-/l*N/A

        \[\leadsto \left(z0 \cdot \frac{z4}{\color{blue}{z3}}\right) \cdot z4 \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      6. lower-/.f6447.0%

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
    11. Applied rewrites47.0%

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

Alternative 9: 75.8% accurate, 2.1× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|z2\right| \leq 9.2 \cdot 10^{-119}:\\ \;\;\;\;\frac{-1 \cdot z0}{\frac{-1 \cdot \frac{z1}{\left|z2\right|}}{\left|z2\right|}}\\ \mathbf{elif}\;\left|z2\right| \leq 3.6 \cdot 10^{+199}:\\ \;\;\;\;\frac{-z0}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{\left|z2\right| \cdot \left|z2\right|}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{z4}{z3} \cdot z0\right) \cdot z4\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (if (<= (fabs z2) 9.2e-119)
  (/ (* -1.0 z0) (/ (* -1.0 (/ z1 (fabs z2))) (fabs z2)))
  (if (<= (fabs z2) 3.6e+199)
    (/ (- z0) (- (/ z3 (* (- z4) z4)) (/ z1 (* (fabs z2) (fabs z2)))))
    (* (* (/ z4 z3) z0) z4))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if (fabs(z2) <= 9.2e-119) {
		tmp = (-1.0 * z0) / ((-1.0 * (z1 / fabs(z2))) / fabs(z2));
	} else if (fabs(z2) <= 3.6e+199) {
		tmp = -z0 / ((z3 / (-z4 * z4)) - (z1 / (fabs(z2) * fabs(z2))));
	} else {
		tmp = ((z4 / z3) * z0) * 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) <= 9.2d-119) then
        tmp = ((-1.0d0) * z0) / (((-1.0d0) * (z1 / abs(z2))) / abs(z2))
    else if (abs(z2) <= 3.6d+199) then
        tmp = -z0 / ((z3 / (-z4 * z4)) - (z1 / (abs(z2) * abs(z2))))
    else
        tmp = ((z4 / z3) * z0) * 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) <= 9.2e-119) {
		tmp = (-1.0 * z0) / ((-1.0 * (z1 / Math.abs(z2))) / Math.abs(z2));
	} else if (Math.abs(z2) <= 3.6e+199) {
		tmp = -z0 / ((z3 / (-z4 * z4)) - (z1 / (Math.abs(z2) * Math.abs(z2))));
	} else {
		tmp = ((z4 / z3) * z0) * z4;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	tmp = 0
	if math.fabs(z2) <= 9.2e-119:
		tmp = (-1.0 * z0) / ((-1.0 * (z1 / math.fabs(z2))) / math.fabs(z2))
	elif math.fabs(z2) <= 3.6e+199:
		tmp = -z0 / ((z3 / (-z4 * z4)) - (z1 / (math.fabs(z2) * math.fabs(z2))))
	else:
		tmp = ((z4 / z3) * z0) * z4
	return tmp
function code(z0, z3, z4, z1, z2)
	tmp = 0.0
	if (abs(z2) <= 9.2e-119)
		tmp = Float64(Float64(-1.0 * z0) / Float64(Float64(-1.0 * Float64(z1 / abs(z2))) / abs(z2)));
	elseif (abs(z2) <= 3.6e+199)
		tmp = Float64(Float64(-z0) / Float64(Float64(z3 / Float64(Float64(-z4) * z4)) - Float64(z1 / Float64(abs(z2) * abs(z2)))));
	else
		tmp = Float64(Float64(Float64(z4 / z3) * z0) * z4);
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	tmp = 0.0;
	if (abs(z2) <= 9.2e-119)
		tmp = (-1.0 * z0) / ((-1.0 * (z1 / abs(z2))) / abs(z2));
	elseif (abs(z2) <= 3.6e+199)
		tmp = -z0 / ((z3 / (-z4 * z4)) - (z1 / (abs(z2) * abs(z2))));
	else
		tmp = ((z4 / z3) * z0) * z4;
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := If[LessEqual[N[Abs[z2], $MachinePrecision], 9.2e-119], N[(N[(-1.0 * z0), $MachinePrecision] / N[(N[(-1.0 * N[(z1 / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[z2], $MachinePrecision], 3.6e+199], N[((-z0) / N[(N[(z3 / N[((-z4) * z4), $MachinePrecision]), $MachinePrecision] - N[(z1 / N[(N[Abs[z2], $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z4 / z3), $MachinePrecision] * z0), $MachinePrecision] * z4), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 9.2 \cdot 10^{-119}:\\
\;\;\;\;\frac{-1 \cdot z0}{\frac{-1 \cdot \frac{z1}{\left|z2\right|}}{\left|z2\right|}}\\

\mathbf{elif}\;\left|z2\right| \leq 3.6 \cdot 10^{+199}:\\
\;\;\;\;\frac{-z0}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{\left|z2\right| \cdot \left|z2\right|}}\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z2 < 9.1999999999999997e-119

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot z0}{\frac{-1 \cdot \color{blue}{\frac{z1}{z2}}}{z2}} \]
      2. lower-/.f6447.7%

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

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

    if 9.1999999999999997e-119 < z2 < 3.6e199

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

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

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

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

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

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

    if 3.6e199 < z2

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      5. lower--.f6459.7%

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    6. Applied rewrites59.7%

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

      \[\leadsto \frac{z0 \cdot z4}{\color{blue}{z3}} \cdot z4 \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lower-*.f6446.6%

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    9. Applied rewrites46.6%

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

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      3. associate-/l*N/A

        \[\leadsto \left(z0 \cdot \frac{z4}{\color{blue}{z3}}\right) \cdot z4 \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      6. lower-/.f6447.0%

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
    11. Applied rewrites47.0%

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

Alternative 10: 75.4% accurate, 1.5× speedup?

\[\begin{array}{l} t_0 := \frac{z3}{\left(-z4\right) \cdot z4}\\ t_1 := \frac{z1}{z2 \cdot z2}\\ \mathbf{if}\;t\_0 - t\_1 \leq 5 \cdot 10^{+171}:\\ \;\;\;\;\frac{-z0}{\frac{\frac{-z3}{z4}}{z4} - t\_1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-z0}{\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))) (t_1 (/ z1 (* z2 z2))))
  (if (<= (- t_0 t_1) 5e+171)
    (/ (- z0) (- (/ (/ (- z3) z4) z4) t_1))
    (* (* (/ (- 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 t_1 = z1 / (z2 * z2);
	double tmp;
	if ((t_0 - t_1) <= 5e+171) {
		tmp = -z0 / (((-z3 / z4) / z4) - t_1);
	} else {
		tmp = ((-z0 / (((z2 * t_0) * z2) - z1)) * z2) * 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 = z1 / (z2 * z2)
    if ((t_0 - t_1) <= 5d+171) then
        tmp = -z0 / (((-z3 / z4) / z4) - t_1)
    else
        tmp = ((-z0 / (((z2 * t_0) * z2) - z1)) * z2) * 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 = z1 / (z2 * z2);
	double tmp;
	if ((t_0 - t_1) <= 5e+171) {
		tmp = -z0 / (((-z3 / z4) / z4) - t_1);
	} else {
		tmp = ((-z0 / (((z2 * t_0) * z2) - z1)) * z2) * z2;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	t_0 = z3 / (-z4 * z4)
	t_1 = z1 / (z2 * z2)
	tmp = 0
	if (t_0 - t_1) <= 5e+171:
		tmp = -z0 / (((-z3 / z4) / z4) - t_1)
	else:
		tmp = ((-z0 / (((z2 * t_0) * z2) - z1)) * z2) * z2
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z3 / Float64(Float64(-z4) * z4))
	t_1 = Float64(z1 / Float64(z2 * z2))
	tmp = 0.0
	if (Float64(t_0 - t_1) <= 5e+171)
		tmp = Float64(Float64(-z0) / Float64(Float64(Float64(Float64(-z3) / z4) / z4) - t_1));
	else
		tmp = 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);
	t_1 = z1 / (z2 * z2);
	tmp = 0.0;
	if ((t_0 - t_1) <= 5e+171)
		tmp = -z0 / (((-z3 / z4) / z4) - t_1);
	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]}, Block[{t$95$1 = N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 5e+171], N[((-z0) / N[(N[(N[((-z3) / z4), $MachinePrecision] / z4), $MachinePrecision] - t$95$1), $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}{\left(-z4\right) \cdot z4}\\
t_1 := \frac{z1}{z2 \cdot z2}\\
\mathbf{if}\;t\_0 - t\_1 \leq 5 \cdot 10^{+171}:\\
\;\;\;\;\frac{-z0}{\frac{\frac{-z3}{z4}}{z4} - t\_1}\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{-z0}{\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 (neg.f64 z4) z4)) (/.f64 z1 (*.f64 z2 z2))) < 5.0000000000000004e171

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000004e171 < (-.f64 (/.f64 z3 (*.f64 (neg.f64 z4) z4)) (/.f64 z1 (*.f64 z2 z2)))

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-1 \cdot z0}{\color{blue}{\frac{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} \cdot z2 - \frac{z1}{z2}}{z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

Alternative 11: 75.3% accurate, 2.3× speedup?

\[\begin{array}{l} \mathbf{if}\;z2 \cdot z2 \leq 5 \cdot 10^{+297}:\\ \;\;\;\;\frac{z2 \cdot z2}{\left(\frac{z3}{\left(-z4\right) \cdot z4} \cdot z2\right) \cdot z2 - z1} \cdot \left(-z0\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{z4}{z3} \cdot z0\right) \cdot z4\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (if (<= (* z2 z2) 5e+297)
  (* (/ (* z2 z2) (- (* (* (/ z3 (* (- z4) z4)) z2) z2) z1)) (- z0))
  (* (* (/ z4 z3) z0) z4)))
double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if ((z2 * z2) <= 5e+297) {
		tmp = ((z2 * z2) / ((((z3 / (-z4 * z4)) * z2) * z2) - z1)) * -z0;
	} else {
		tmp = ((z4 / z3) * z0) * 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 ((z2 * z2) <= 5d+297) then
        tmp = ((z2 * z2) / ((((z3 / (-z4 * z4)) * z2) * z2) - z1)) * -z0
    else
        tmp = ((z4 / z3) * z0) * z4
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double tmp;
	if ((z2 * z2) <= 5e+297) {
		tmp = ((z2 * z2) / ((((z3 / (-z4 * z4)) * z2) * z2) - z1)) * -z0;
	} else {
		tmp = ((z4 / z3) * z0) * z4;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	tmp = 0
	if (z2 * z2) <= 5e+297:
		tmp = ((z2 * z2) / ((((z3 / (-z4 * z4)) * z2) * z2) - z1)) * -z0
	else:
		tmp = ((z4 / z3) * z0) * z4
	return tmp
function code(z0, z3, z4, z1, z2)
	tmp = 0.0
	if (Float64(z2 * z2) <= 5e+297)
		tmp = Float64(Float64(Float64(z2 * z2) / Float64(Float64(Float64(Float64(z3 / Float64(Float64(-z4) * z4)) * z2) * z2) - z1)) * Float64(-z0));
	else
		tmp = Float64(Float64(Float64(z4 / z3) * z0) * z4);
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	tmp = 0.0;
	if ((z2 * z2) <= 5e+297)
		tmp = ((z2 * z2) / ((((z3 / (-z4 * z4)) * z2) * z2) - z1)) * -z0;
	else
		tmp = ((z4 / z3) * z0) * z4;
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := If[LessEqual[N[(z2 * z2), $MachinePrecision], 5e+297], N[(N[(N[(z2 * z2), $MachinePrecision] / N[(N[(N[(N[(z3 / N[((-z4) * z4), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision] * z2), $MachinePrecision] - z1), $MachinePrecision]), $MachinePrecision] * (-z0)), $MachinePrecision], N[(N[(N[(z4 / z3), $MachinePrecision] * z0), $MachinePrecision] * z4), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z2 \cdot z2 \leq 5 \cdot 10^{+297}:\\
\;\;\;\;\frac{z2 \cdot z2}{\left(\frac{z3}{\left(-z4\right) \cdot z4} \cdot z2\right) \cdot z2 - z1} \cdot \left(-z0\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z2 z2) < 4.9999999999999998e297

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999998e297 < (*.f64 z2 z2)

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      5. lower--.f6459.7%

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    6. Applied rewrites59.7%

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

      \[\leadsto \frac{z0 \cdot z4}{\color{blue}{z3}} \cdot z4 \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lower-*.f6446.6%

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    9. Applied rewrites46.6%

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

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      3. associate-/l*N/A

        \[\leadsto \left(z0 \cdot \frac{z4}{\color{blue}{z3}}\right) \cdot z4 \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      6. lower-/.f6447.0%

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
    11. Applied rewrites47.0%

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

Alternative 12: 67.1% accurate, 1.7× speedup?

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

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

real(8) function code(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 / (z2 * z2)
    t_1 = ((-1.0d0) * z0) / (((-1.0d0) * (z1 / z2)) / z2)
    if (t_0 <= (-1d+23)) then
        tmp = t_1
    else if (t_0 <= 5d+32) then
        tmp = ((z4 / z3) * z0) * z4
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z1 / (z2 * z2);
	double t_1 = (-1.0 * z0) / ((-1.0 * (z1 / z2)) / z2);
	double tmp;
	if (t_0 <= -1e+23) {
		tmp = t_1;
	} else if (t_0 <= 5e+32) {
		tmp = ((z4 / z3) * z0) * z4;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	t_0 = z1 / (z2 * z2)
	t_1 = (-1.0 * z0) / ((-1.0 * (z1 / z2)) / z2)
	tmp = 0
	if t_0 <= -1e+23:
		tmp = t_1
	elif t_0 <= 5e+32:
		tmp = ((z4 / z3) * z0) * z4
	else:
		tmp = t_1
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z1 / Float64(z2 * z2))
	t_1 = Float64(Float64(-1.0 * z0) / Float64(Float64(-1.0 * Float64(z1 / z2)) / z2))
	tmp = 0.0
	if (t_0 <= -1e+23)
		tmp = t_1;
	elseif (t_0 <= 5e+32)
		tmp = Float64(Float64(Float64(z4 / z3) * z0) * z4);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	t_0 = z1 / (z2 * z2);
	t_1 = (-1.0 * z0) / ((-1.0 * (z1 / z2)) / z2);
	tmp = 0.0;
	if (t_0 <= -1e+23)
		tmp = t_1;
	elseif (t_0 <= 5e+32)
		tmp = ((z4 / z3) * z0) * z4;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[z0_, z3_, z4_, z1_, z2_] := Block[{t$95$0 = N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-1.0 * z0), $MachinePrecision] / N[(N[(-1.0 * N[(z1 / z2), $MachinePrecision]), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+23], t$95$1, If[LessEqual[t$95$0, 5e+32], N[(N[(N[(z4 / z3), $MachinePrecision] * z0), $MachinePrecision] * z4), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \frac{z1}{z2 \cdot z2}\\
t_1 := \frac{-1 \cdot z0}{\frac{-1 \cdot \frac{z1}{z2}}{z2}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+32}:\\
\;\;\;\;\left(\frac{z4}{z3} \cdot z0\right) \cdot z4\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 z1 (*.f64 z2 z2)) < -9.9999999999999992e22 or 4.9999999999999997e32 < (/.f64 z1 (*.f64 z2 z2))

    1. Initial program 65.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}} \]
    3. Step-by-step derivation
      1. lower-*.f6471.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot z0}}{\frac{z3}{\left(-z4\right) \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}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}}} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot z0}{\frac{-1 \cdot \color{blue}{\frac{z1}{z2}}}{z2}} \]
      2. lower-/.f6447.7%

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

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

    if -9.9999999999999992e22 < (/.f64 z1 (*.f64 z2 z2)) < 4.9999999999999997e32

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
      4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
      5. lower--.f6459.7%

        \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    6. Applied rewrites59.7%

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

      \[\leadsto \frac{z0 \cdot z4}{\color{blue}{z3}} \cdot z4 \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lower-*.f6446.6%

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    9. Applied rewrites46.6%

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

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
      3. associate-/l*N/A

        \[\leadsto \left(z0 \cdot \frac{z4}{\color{blue}{z3}}\right) \cdot z4 \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
      6. lower-/.f6447.0%

        \[\leadsto \left(\frac{z4}{z3} \cdot z0\right) \cdot z4 \]
    11. Applied rewrites47.0%

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

Alternative 13: 46.4% accurate, 6.9× speedup?

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

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

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

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

      \[\leadsto \frac{\mathsf{neg}\left(\log \left(1 - z0\right)\right)}{\mathsf{neg}\left(\color{blue}{\left(\frac{z3}{\left(-z4\right) \cdot z4} - \frac{z1}{z2 \cdot z2}\right)}\right)} \]
    4. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
    5. lower--.f6459.7%

      \[\leadsto \left(-1 \cdot \frac{z4 \cdot \log \left(1 - z0\right)}{z3}\right) \cdot z4 \]
  6. Applied rewrites59.7%

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

    \[\leadsto \frac{z0 \cdot z4}{\color{blue}{z3}} \cdot z4 \]
  8. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    2. lower-*.f6446.6%

      \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
  9. Applied rewrites46.6%

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

      \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    2. lift-*.f64N/A

      \[\leadsto \frac{z0 \cdot z4}{z3} \cdot z4 \]
    3. *-commutativeN/A

      \[\leadsto \frac{z4 \cdot z0}{z3} \cdot z4 \]
    4. associate-/l*N/A

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

      \[\leadsto \left(z4 \cdot \frac{z0}{\color{blue}{z3}}\right) \cdot z4 \]
    6. lower-/.f6446.4%

      \[\leadsto \left(z4 \cdot \frac{z0}{z3}\right) \cdot z4 \]
  11. Applied rewrites46.4%

    \[\leadsto \left(z4 \cdot \frac{z0}{\color{blue}{z3}}\right) \cdot z4 \]
  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)))))