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

Percentage Accurate: 76.6% → 88.4%
Time: 3.2s
Alternatives: 12
Speedup: 0.7×

Specification

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 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: 76.6% accurate, 1.0× speedup?

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

Alternative 1: 88.4% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z4 < 3.3000000000000001e-208 or 4.1000000000000003e-8 < z4

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\color{blue}{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}} \cdot z2 \]
    5. Applied rewrites80.8%

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

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

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

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

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

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

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

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

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

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

    if 3.3000000000000001e-208 < z4 < 4.1000000000000003e-8

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
      18. lower-*.f6453.2%

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
    5. Applied rewrites53.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z2 \cdot z4\right) \cdot \left(z4 \cdot \frac{z0}{\color{blue}{z2 \cdot z3 + \frac{z1 \cdot \left(z4 \cdot z4\right)}{z2}}}\right) \]
      12. lower-+.f6464.6%

        \[\leadsto \left(z2 \cdot z4\right) \cdot \left(z4 \cdot \frac{z0}{\color{blue}{z2 \cdot z3 + \frac{z1 \cdot \left(z4 \cdot z4\right)}{z2}}}\right) \]
    7. Applied rewrites64.6%

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

Alternative 2: 87.3% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;\left|z2\right| \leq 10^{+140}:\\
\;\;\;\;\frac{z0}{\frac{\frac{z3}{z4}}{z4} + \frac{z1}{\left|z2\right| \cdot \left|z2\right|}}\\

\mathbf{else}:\\
\;\;\;\;\frac{z0}{t\_0 + \frac{\frac{z1}{\left|z2\right|}}{\left|z2\right|}}\\


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

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\color{blue}{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}} \cdot z2 \]
    5. Applied rewrites80.8%

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

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

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

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

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

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

    if 1.5e-103 < z2 < 1.0000000000000001e140

    1. Initial program 76.6%

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

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

        \[\leadsto \frac{z0}{\frac{z3}{\color{blue}{z4 \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. lower-/.f6481.2%

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

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

    if 1.0000000000000001e140 < z2

    1. Initial program 76.6%

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

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

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

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

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

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

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

Alternative 3: 86.5% accurate, 0.7× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{z0}{t\_0 + \frac{\frac{z1}{\left|z2\right|}}{\left|z2\right|}}\\


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

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\color{blue}{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}} \cdot z2 \]
    5. Applied rewrites80.8%

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

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

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

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

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

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

    if 1.5e-103 < z2

    1. Initial program 76.6%

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

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

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

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

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

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

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

Alternative 4: 84.9% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \frac{z3}{z4 \cdot z4}\\ t_1 := \frac{z0}{t\_0 + \frac{z1}{z2 \cdot z2}}\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\left(z2 \cdot z4\right) \cdot \left(z4 \cdot \frac{z0}{z2 \cdot z3}\right)\\ \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-307}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-195}:\\ \;\;\;\;\left(z2 \cdot z0\right) \cdot \frac{z2}{z1}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (z0 z3 z4 z1 z2)
  :precision binary64
  (let* ((t_0 (/ z3 (* z4 z4))) (t_1 (/ z0 (+ t_0 (/ z1 (* z2 z2))))))
  (if (<= t_0 (- INFINITY))
    (* (* z2 z4) (* z4 (/ z0 (* z2 z3))))
    (if (<= t_0 -1e-307)
      t_1
      (if (<= t_0 5e-195) (* (* z2 z0) (/ z2 z1)) t_1)))))
double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z3 / (z4 * z4);
	double t_1 = z0 / (t_0 + (z1 / (z2 * z2)));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (z2 * z4) * (z4 * (z0 / (z2 * z3)));
	} else if (t_0 <= -1e-307) {
		tmp = t_1;
	} else if (t_0 <= 5e-195) {
		tmp = (z2 * z0) * (z2 / z1);
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z3 / (z4 * z4);
	double t_1 = z0 / (t_0 + (z1 / (z2 * z2)));
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = (z2 * z4) * (z4 * (z0 / (z2 * z3)));
	} else if (t_0 <= -1e-307) {
		tmp = t_1;
	} else if (t_0 <= 5e-195) {
		tmp = (z2 * z0) * (z2 / z1);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	t_0 = z3 / (z4 * z4)
	t_1 = z0 / (t_0 + (z1 / (z2 * z2)))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = (z2 * z4) * (z4 * (z0 / (z2 * z3)))
	elif t_0 <= -1e-307:
		tmp = t_1
	elif t_0 <= 5e-195:
		tmp = (z2 * z0) * (z2 / z1)
	else:
		tmp = t_1
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z3 / Float64(z4 * z4))
	t_1 = Float64(z0 / Float64(t_0 + Float64(z1 / Float64(z2 * z2))))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(z2 * z4) * Float64(z4 * Float64(z0 / Float64(z2 * z3))));
	elseif (t_0 <= -1e-307)
		tmp = t_1;
	elseif (t_0 <= 5e-195)
		tmp = Float64(Float64(z2 * z0) * Float64(z2 / z1));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	t_0 = z3 / (z4 * z4);
	t_1 = z0 / (t_0 + (z1 / (z2 * z2)));
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (z2 * z4) * (z4 * (z0 / (z2 * z3)));
	elseif (t_0 <= -1e-307)
		tmp = t_1;
	elseif (t_0 <= 5e-195)
		tmp = (z2 * z0) * (z2 / z1);
	else
		tmp = t_1;
	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[(z0 / N[(t$95$0 + N[(z1 / N[(z2 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(z2 * z4), $MachinePrecision] * N[(z4 * N[(z0 / N[(z2 * z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1e-307], t$95$1, If[LessEqual[t$95$0, 5e-195], N[(N[(z2 * z0), $MachinePrecision] * N[(z2 / z1), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
t_0 := \frac{z3}{z4 \cdot z4}\\
t_1 := \frac{z0}{t\_0 + \frac{z1}{z2 \cdot z2}}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(z2 \cdot z4\right) \cdot \left(z4 \cdot \frac{z0}{z2 \cdot z3}\right)\\

\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-307}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-195}:\\
\;\;\;\;\left(z2 \cdot z0\right) \cdot \frac{z2}{z1}\\

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


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

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
      18. lower-*.f6453.2%

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
    5. Applied rewrites53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z2 \cdot z4\right) \cdot \color{blue}{\left(z4 \cdot \frac{z0}{z2 \cdot z3}\right)} \]
    10. Applied rewrites44.0%

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

    if -inf.0 < (/.f64 z3 (*.f64 z4 z4)) < -9.9999999999999991e-308 or 5.0000000000000001e-195 < (/.f64 z3 (*.f64 z4 z4))

    1. Initial program 76.6%

      \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]

    if -9.9999999999999991e-308 < (/.f64 z3 (*.f64 z4 z4)) < 5.0000000000000001e-195

    1. Initial program 76.6%

      \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    2. Taylor expanded in z3 around 0

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

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

        \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
      3. lower-pow.f6450.2%

        \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
    4. Applied rewrites50.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
    6. Applied rewrites49.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 83.0% accurate, 0.6× speedup?

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

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

real(8) function code(z0, z3, z4, z1, z2)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z3
    real(8), intent (in) :: z4
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = z3 / (z4 * z4)
    t_1 = abs(z2) * t_0
    if (abs(z2) <= 1.5d-103) then
        tmp = ((abs(z2) / ((t_1 * abs(z2)) + z1)) * z0) * abs(z2)
    else if (abs(z2) <= 1.28d+238) then
        tmp = z0 * (abs(z2) / (t_1 + (z1 / abs(z2))))
    else
        tmp = z0 / (t_0 + (z1 / (abs(z2) * abs(z2))))
    end if
    code = tmp
end function
public static double code(double z0, double z3, double z4, double z1, double z2) {
	double t_0 = z3 / (z4 * z4);
	double t_1 = Math.abs(z2) * t_0;
	double tmp;
	if (Math.abs(z2) <= 1.5e-103) {
		tmp = ((Math.abs(z2) / ((t_1 * Math.abs(z2)) + z1)) * z0) * Math.abs(z2);
	} else if (Math.abs(z2) <= 1.28e+238) {
		tmp = z0 * (Math.abs(z2) / (t_1 + (z1 / Math.abs(z2))));
	} else {
		tmp = z0 / (t_0 + (z1 / (Math.abs(z2) * Math.abs(z2))));
	}
	return tmp;
}
def code(z0, z3, z4, z1, z2):
	t_0 = z3 / (z4 * z4)
	t_1 = math.fabs(z2) * t_0
	tmp = 0
	if math.fabs(z2) <= 1.5e-103:
		tmp = ((math.fabs(z2) / ((t_1 * math.fabs(z2)) + z1)) * z0) * math.fabs(z2)
	elif math.fabs(z2) <= 1.28e+238:
		tmp = z0 * (math.fabs(z2) / (t_1 + (z1 / math.fabs(z2))))
	else:
		tmp = z0 / (t_0 + (z1 / (math.fabs(z2) * math.fabs(z2))))
	return tmp
function code(z0, z3, z4, z1, z2)
	t_0 = Float64(z3 / Float64(z4 * z4))
	t_1 = Float64(abs(z2) * t_0)
	tmp = 0.0
	if (abs(z2) <= 1.5e-103)
		tmp = Float64(Float64(Float64(abs(z2) / Float64(Float64(t_1 * abs(z2)) + z1)) * z0) * abs(z2));
	elseif (abs(z2) <= 1.28e+238)
		tmp = Float64(z0 * Float64(abs(z2) / Float64(t_1 + Float64(z1 / abs(z2)))));
	else
		tmp = Float64(z0 / Float64(t_0 + Float64(z1 / Float64(abs(z2) * abs(z2)))));
	end
	return tmp
end
function tmp_2 = code(z0, z3, z4, z1, z2)
	t_0 = z3 / (z4 * z4);
	t_1 = abs(z2) * t_0;
	tmp = 0.0;
	if (abs(z2) <= 1.5e-103)
		tmp = ((abs(z2) / ((t_1 * abs(z2)) + z1)) * z0) * abs(z2);
	elseif (abs(z2) <= 1.28e+238)
		tmp = z0 * (abs(z2) / (t_1 + (z1 / abs(z2))));
	else
		tmp = z0 / (t_0 + (z1 / (abs(z2) * abs(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[Abs[z2], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[N[Abs[z2], $MachinePrecision], 1.5e-103], N[(N[(N[(N[Abs[z2], $MachinePrecision] / N[(N[(t$95$1 * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + z1), $MachinePrecision]), $MachinePrecision] * z0), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[z2], $MachinePrecision], 1.28e+238], N[(z0 * N[(N[Abs[z2], $MachinePrecision] / N[(t$95$1 + N[(z1 / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z0 / N[(t$95$0 + N[(z1 / N[(N[Abs[z2], $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \frac{z3}{z4 \cdot z4}\\
t_1 := \left|z2\right| \cdot t\_0\\
\mathbf{if}\;\left|z2\right| \leq 1.5 \cdot 10^{-103}:\\
\;\;\;\;\left(\frac{\left|z2\right|}{t\_1 \cdot \left|z2\right| + z1} \cdot z0\right) \cdot \left|z2\right|\\

\mathbf{elif}\;\left|z2\right| \leq 1.28 \cdot 10^{+238}:\\
\;\;\;\;z0 \cdot \frac{\left|z2\right|}{t\_1 + \frac{z1}{\left|z2\right|}}\\

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


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

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\color{blue}{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}} \cdot z2 \]
    5. Applied rewrites80.8%

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

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

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

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

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

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

    if 1.5e-103 < z2 < 1.2800000000000001e238

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\color{blue}{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}} \cdot z2 \]
    5. Applied rewrites80.8%

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

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

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

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

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

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

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

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

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

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

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

    if 1.2800000000000001e238 < z2

    1. Initial program 76.6%

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

Alternative 6: 82.4% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\color{blue}{\frac{z3}{z4 \cdot z4} \cdot z2 + \frac{z1}{z2}}} \cdot z2 \]
    5. Applied rewrites80.8%

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

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

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

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

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

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

    if 7.8000000000000005e211 < z2

    1. Initial program 76.6%

      \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 72.6% accurate, 0.8× speedup?

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

\mathbf{elif}\;\left|z4\right| \leq 110000000:\\
\;\;\;\;\frac{\frac{z0}{z3}}{z2} \cdot \left(z2 \cdot \left(\left|z4\right| \cdot \left|z4\right|\right)\right)\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z4 < 5.0000000000000001e-180

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
      18. lower-*.f6453.2%

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
    5. Applied rewrites53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z2 \cdot z4\right) \cdot \color{blue}{\left(z4 \cdot \frac{z0}{z2 \cdot z3}\right)} \]
    10. Applied rewrites44.0%

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

    if 5.0000000000000001e-180 < z4 < 1.1e8

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
      18. lower-*.f6453.2%

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
    5. Applied rewrites53.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{z0}{z3}}{z2} \cdot \left(z2 \cdot \left(z4 \cdot z4\right)\right) \]
    10. Applied rewrites43.5%

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

    if 1.1e8 < z4

    1. Initial program 76.6%

      \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    2. Taylor expanded in z3 around 0

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

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

        \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
      3. lower-pow.f6450.2%

        \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
    4. Applied rewrites50.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
    6. Applied rewrites49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{z1} \cdot z2\right) \cdot \left(z2 \cdot \color{blue}{z0}\right) \]
      16. lower-*.f6455.8%

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

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

Alternative 8: 72.1% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 z3 (*.f64 z4 z4)) < -5.0000000000000002e138 or 9.9999999999999992e22 < (/.f64 z3 (*.f64 z4 z4))

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
      18. lower-*.f6453.2%

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
    5. Applied rewrites53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z2 \cdot z4\right) \cdot \color{blue}{\left(z4 \cdot \frac{z0}{z2 \cdot z3}\right)} \]
    10. Applied rewrites44.0%

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

    if -5.0000000000000002e138 < (/.f64 z3 (*.f64 z4 z4)) < 9.9999999999999992e22

    1. Initial program 76.6%

      \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    2. Taylor expanded in z3 around 0

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

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

        \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
      3. lower-pow.f6450.2%

        \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
    4. Applied rewrites50.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
    6. Applied rewrites49.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 69.6% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 z3 (*.f64 z4 z4)) < -1e153 or 9.9999999999999992e22 < (/.f64 z3 (*.f64 z4 z4))

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
      18. lower-*.f6453.2%

        \[\leadsto \frac{z0}{\frac{z1 \cdot \left(z4 \cdot z4\right)}{z2} + z2 \cdot z3} \cdot \color{blue}{\left(z2 \cdot \left(z4 \cdot z4\right)\right)} \]
    5. Applied rewrites53.2%

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

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

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

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

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

    if -1e153 < (/.f64 z3 (*.f64 z4 z4)) < 9.9999999999999992e22

    1. Initial program 76.6%

      \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
    2. Taylor expanded in z3 around 0

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

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

        \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
      3. lower-pow.f6450.2%

        \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
    4. Applied rewrites50.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
    6. Applied rewrites49.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 55.9% accurate, 2.1× speedup?

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

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

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

    \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
  2. Taylor expanded in z3 around 0

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

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

      \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
    3. lower-pow.f6450.2%

      \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
  4. Applied rewrites50.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
  6. Applied rewrites49.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 55.7% accurate, 2.1× speedup?

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

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

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

    \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
  2. Taylor expanded in z3 around 0

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

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

      \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
    3. lower-pow.f6450.2%

      \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
  4. Applied rewrites50.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
  6. Applied rewrites49.8%

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

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

      \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
    3. lift-*.f64N/A

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

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

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

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

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

      \[\leadsto z2 \cdot \left(\frac{z2}{z1} \cdot z0\right) \]
  8. Applied rewrites55.7%

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

Alternative 12: 54.0% accurate, 2.1× speedup?

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

    \[\frac{z0}{\frac{z3}{z4 \cdot z4} + \frac{z1}{z2 \cdot z2}} \]
  2. Taylor expanded in z3 around 0

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

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

      \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
    3. lower-pow.f6450.2%

      \[\leadsto \frac{z0 \cdot {z2}^{2}}{z1} \]
  4. Applied rewrites50.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
  6. Applied rewrites49.8%

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

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

      \[\leadsto \frac{z2 \cdot z2}{z1} \cdot z0 \]
    3. lift-*.f64N/A

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

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

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

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

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

      \[\leadsto z2 \cdot \left(\frac{z2}{z1} \cdot z0\right) \]
  8. Applied rewrites55.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto z2 \cdot \left(\frac{z0}{z1} \cdot z2\right) \]
  10. Applied rewrites54.0%

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

Reproduce

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