Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1

Percentage Accurate: 65.8% → 96.5%
Time: 3.7s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
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(x, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = ((x * x) / (y * y)) + ((z * z) / (t * t))
end function
public static double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
def code(x, y, z, t):
	return ((x * x) / (y * y)) + ((z * z) / (t * t))
function code(x, y, z, t)
	return Float64(Float64(Float64(x * x) / Float64(y * y)) + Float64(Float64(z * z) / Float64(t * t)))
end
function tmp = code(x, y, z, t)
	tmp = ((x * x) / (y * y)) + ((z * z) / (t * t));
end
code[x_, y_, z_, t_] := N[(N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\end{array}

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 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 65.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
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(x, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = ((x * x) / (y * y)) + ((z * z) / (t * t))
end function
public static double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
def code(x, y, z, t):
	return ((x * x) / (y * y)) + ((z * z) / (t * t))
function code(x, y, z, t)
	return Float64(Float64(Float64(x * x) / Float64(y * y)) + Float64(Float64(z * z) / Float64(t * t)))
end
function tmp = code(x, y, z, t)
	tmp = ((x * x) / (y * y)) + ((z * z) / (t * t));
end
code[x_, y_, z_, t_] := N[(N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\end{array}

Alternative 1: 96.5% accurate, 0.9× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 3 \cdot 10^{-157}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z\_m}{t}, \frac{z\_m}{t}, \frac{\frac{x}{y} \cdot x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z\_m}{t}, \frac{z\_m}{t}, \frac{\frac{x}{y}}{y} \cdot x\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= z_m 3e-157)
   (fma (/ z_m t) (/ z_m t) (/ (* (/ x y) x) y))
   (fma (/ z_m t) (/ z_m t) (* (/ (/ x y) y) x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if (z_m <= 3e-157) {
		tmp = fma((z_m / t), (z_m / t), (((x / y) * x) / y));
	} else {
		tmp = fma((z_m / t), (z_m / t), (((x / y) / y) * x));
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (z_m <= 3e-157)
		tmp = fma(Float64(z_m / t), Float64(z_m / t), Float64(Float64(Float64(x / y) * x) / y));
	else
		tmp = fma(Float64(z_m / t), Float64(z_m / t), Float64(Float64(Float64(x / y) / y) * x));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 3e-157], N[(N[(z$95$m / t), $MachinePrecision] * N[(z$95$m / t), $MachinePrecision] + N[(N[(N[(x / y), $MachinePrecision] * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(z$95$m / t), $MachinePrecision] * N[(z$95$m / t), $MachinePrecision] + N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 3 \cdot 10^{-157}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z\_m}{t}, \frac{z\_m}{t}, \frac{\frac{x}{y} \cdot x}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z\_m}{t}, \frac{z\_m}{t}, \frac{\frac{x}{y}}{y} \cdot x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 3e-157

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t} + \frac{x \cdot x}{y \cdot y}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{z \cdot z}}{t \cdot t} + \frac{x \cdot x}{y \cdot y} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{z \cdot z}{\color{blue}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      8. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      9. times-fracN/A

        \[\leadsto \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} + \frac{x \cdot x}{y \cdot y} \]
      10. pow2N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{t} + \frac{\color{blue}{{x}^{2}}}{y \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{t} + \frac{{x}^{2}}{\color{blue}{{y}^{2}}} \]
      12. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{{x}^{2}}{{y}^{2}}\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t}}, \frac{z}{t}, \frac{{x}^{2}}{{y}^{2}}\right) \]
      14. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \color{blue}{\frac{z}{t}}, \frac{{x}^{2}}{{y}^{2}}\right) \]
      15. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\color{blue}{x \cdot x}}{{y}^{2}}\right) \]
      16. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{x \cdot \frac{x}{{y}^{2}}}\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
      18. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
      19. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}}} \cdot x\right) \]
      20. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
      21. lift-*.f6489.2

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
    3. Applied rewrites89.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y \cdot y} \cdot x\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{y \cdot y} \cdot x}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
      3. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{y \cdot y}} \cdot x\right) \]
      4. associate-/r*N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y}}{y}} \cdot x\right) \]
      5. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\color{blue}{\frac{x}{y}}}{y} \cdot x\right) \]
      6. associate-*l/N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y} \cdot x}{y}}\right) \]
      7. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\color{blue}{\frac{x}{y} \cdot x}}{y}\right) \]
      8. lift-/.f6496.7

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y} \cdot x}{y}}\right) \]
    5. Applied rewrites96.7%

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y} \cdot x}{y}}\right) \]

    if 3e-157 < z

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t} + \frac{x \cdot x}{y \cdot y}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{z \cdot z}}{t \cdot t} + \frac{x \cdot x}{y \cdot y} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{z \cdot z}{\color{blue}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      8. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      9. times-fracN/A

        \[\leadsto \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} + \frac{x \cdot x}{y \cdot y} \]
      10. pow2N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{t} + \frac{\color{blue}{{x}^{2}}}{y \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{t} + \frac{{x}^{2}}{\color{blue}{{y}^{2}}} \]
      12. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{{x}^{2}}{{y}^{2}}\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t}}, \frac{z}{t}, \frac{{x}^{2}}{{y}^{2}}\right) \]
      14. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \color{blue}{\frac{z}{t}}, \frac{{x}^{2}}{{y}^{2}}\right) \]
      15. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\color{blue}{x \cdot x}}{{y}^{2}}\right) \]
      16. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{x \cdot \frac{x}{{y}^{2}}}\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
      18. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
      19. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}}} \cdot x\right) \]
      20. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
      21. lift-*.f6489.2

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
    3. Applied rewrites89.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y \cdot y} \cdot x\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
      2. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{y \cdot y}} \cdot x\right) \]
      3. associate-/r*N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y}}{y}} \cdot x\right) \]
      4. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\color{blue}{\frac{x}{y}}}{y} \cdot x\right) \]
      5. lower-/.f6496.5

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y}}{y}} \cdot x\right) \]
    5. Applied rewrites96.5%

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y}}{y}} \cdot x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 96.4% accurate, 0.6× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 10^{+196}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z\_m}{t}, \frac{z\_m}{t}, \frac{x}{y \cdot y} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z\_m}{t \cdot t} \cdot z\_m\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= (/ (* x x) (* y y)) 1e+196)
   (fma (/ z_m t) (/ z_m t) (* (/ x (* y y)) x))
   (fma (/ x y) (/ x y) (* (/ z_m (* t t)) z_m))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if (((x * x) / (y * y)) <= 1e+196) {
		tmp = fma((z_m / t), (z_m / t), ((x / (y * y)) * x));
	} else {
		tmp = fma((x / y), (x / y), ((z_m / (t * t)) * z_m));
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (Float64(Float64(x * x) / Float64(y * y)) <= 1e+196)
		tmp = fma(Float64(z_m / t), Float64(z_m / t), Float64(Float64(x / Float64(y * y)) * x));
	else
		tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z_m / Float64(t * t)) * z_m));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], 1e+196], N[(N[(z$95$m / t), $MachinePrecision] * N[(z$95$m / t), $MachinePrecision] + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z$95$m / N[(t * t), $MachinePrecision]), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z\_m}{t}, \frac{z\_m}{t}, \frac{x}{y \cdot y} \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z\_m}{t \cdot t} \cdot z\_m\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x x) (*.f64 y y)) < 9.9999999999999995e195

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t} + \frac{x \cdot x}{y \cdot y}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{z \cdot z}}{t \cdot t} + \frac{x \cdot x}{y \cdot y} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{z \cdot z}{\color{blue}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      8. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      9. times-fracN/A

        \[\leadsto \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} + \frac{x \cdot x}{y \cdot y} \]
      10. pow2N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{t} + \frac{\color{blue}{{x}^{2}}}{y \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{t} + \frac{{x}^{2}}{\color{blue}{{y}^{2}}} \]
      12. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{{x}^{2}}{{y}^{2}}\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t}}, \frac{z}{t}, \frac{{x}^{2}}{{y}^{2}}\right) \]
      14. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \color{blue}{\frac{z}{t}}, \frac{{x}^{2}}{{y}^{2}}\right) \]
      15. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\color{blue}{x \cdot x}}{{y}^{2}}\right) \]
      16. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{x \cdot \frac{x}{{y}^{2}}}\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
      18. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
      19. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}}} \cdot x\right) \]
      20. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
      21. lift-*.f6489.2

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
    3. Applied rewrites89.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y \cdot y} \cdot x\right)} \]

    if 9.9999999999999995e195 < (/.f64 (*.f64 x x) (*.f64 y y))

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      5. times-fracN/A

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} + \frac{z \cdot z}{t \cdot t} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{\color{blue}{z \cdot z}}{t \cdot t} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{z \cdot z}{\color{blue}{t \cdot t}} \]
      8. lift-/.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \color{blue}{\frac{z \cdot z}{t \cdot t}} \]
      9. pow2N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{\color{blue}{{z}^{2}}}{t \cdot t} \]
      10. pow2N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{{z}^{2}}{\color{blue}{{t}^{2}}} \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{{z}^{2}}{{t}^{2}}\right)} \]
      12. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, \frac{x}{y}, \frac{{z}^{2}}{{t}^{2}}\right) \]
      13. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \color{blue}{\frac{x}{y}}, \frac{{z}^{2}}{{t}^{2}}\right) \]
      14. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{\color{blue}{z \cdot z}}{{t}^{2}}\right) \]
      15. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{z \cdot \frac{z}{{t}^{2}}}\right) \]
      16. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{{t}^{2}} \cdot z}\right) \]
      17. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{{t}^{2}} \cdot z}\right) \]
      18. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{{t}^{2}}} \cdot z\right) \]
      19. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{\color{blue}{t \cdot t}} \cdot z\right) \]
      20. lift-*.f6488.8

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{\color{blue}{t \cdot t}} \cdot z\right) \]
    3. Applied rewrites88.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 96.3% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \mathsf{fma}\left(\frac{z\_m}{t}, \frac{z\_m}{t}, \frac{\frac{x}{y}}{y} \cdot x\right) \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (fma (/ z_m t) (/ z_m t) (* (/ (/ x y) y) x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	return fma((z_m / t), (z_m / t), (((x / y) / y) * x));
}
z_m = abs(z)
function code(x, y, z_m, t)
	return fma(Float64(z_m / t), Float64(z_m / t), Float64(Float64(Float64(x / y) / y) * x))
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := N[(N[(z$95$m / t), $MachinePrecision] * N[(z$95$m / t), $MachinePrecision] + N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|

\\
\mathsf{fma}\left(\frac{z\_m}{t}, \frac{z\_m}{t}, \frac{\frac{x}{y}}{y} \cdot x\right)
\end{array}
Derivation
  1. Initial program 65.8%

    \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
    4. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
    5. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t} + \frac{x \cdot x}{y \cdot y}} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{z \cdot z}}{t \cdot t} + \frac{x \cdot x}{y \cdot y} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{z \cdot z}{\color{blue}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
    8. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
    9. times-fracN/A

      \[\leadsto \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} + \frac{x \cdot x}{y \cdot y} \]
    10. pow2N/A

      \[\leadsto \frac{z}{t} \cdot \frac{z}{t} + \frac{\color{blue}{{x}^{2}}}{y \cdot y} \]
    11. pow2N/A

      \[\leadsto \frac{z}{t} \cdot \frac{z}{t} + \frac{{x}^{2}}{\color{blue}{{y}^{2}}} \]
    12. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{{x}^{2}}{{y}^{2}}\right)} \]
    13. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t}}, \frac{z}{t}, \frac{{x}^{2}}{{y}^{2}}\right) \]
    14. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \color{blue}{\frac{z}{t}}, \frac{{x}^{2}}{{y}^{2}}\right) \]
    15. pow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\color{blue}{x \cdot x}}{{y}^{2}}\right) \]
    16. associate-/l*N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{x \cdot \frac{x}{{y}^{2}}}\right) \]
    17. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
    18. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
    19. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{{y}^{2}}} \cdot x\right) \]
    20. pow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
    21. lift-*.f6489.2

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
  3. Applied rewrites89.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y \cdot y} \cdot x\right)} \]
  4. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
    2. lift-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{x}{y \cdot y}} \cdot x\right) \]
    3. associate-/r*N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y}}{y}} \cdot x\right) \]
    4. lift-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\color{blue}{\frac{x}{y}}}{y} \cdot x\right) \]
    5. lower-/.f6496.5

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y}}{y}} \cdot x\right) \]
  5. Applied rewrites96.5%

    \[\leadsto \mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \color{blue}{\frac{\frac{x}{y}}{y}} \cdot x\right) \]
  6. Add Preprocessing

Alternative 4: 92.8% accurate, 0.6× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 10^{-224}:\\ \;\;\;\;\frac{z\_m}{t} \cdot \left(\frac{1}{t} \cdot z\_m\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z\_m}{t \cdot t} \cdot z\_m\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= (/ (* x x) (* y y)) 1e-224)
   (* (/ z_m t) (* (/ 1.0 t) z_m))
   (fma (/ x y) (/ x y) (* (/ z_m (* t t)) z_m))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if (((x * x) / (y * y)) <= 1e-224) {
		tmp = (z_m / t) * ((1.0 / t) * z_m);
	} else {
		tmp = fma((x / y), (x / y), ((z_m / (t * t)) * z_m));
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (Float64(Float64(x * x) / Float64(y * y)) <= 1e-224)
		tmp = Float64(Float64(z_m / t) * Float64(Float64(1.0 / t) * z_m));
	else
		tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z_m / Float64(t * t)) * z_m));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], 1e-224], N[(N[(z$95$m / t), $MachinePrecision] * N[(N[(1.0 / t), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z$95$m / N[(t * t), $MachinePrecision]), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 10^{-224}:\\
\;\;\;\;\frac{z\_m}{t} \cdot \left(\frac{1}{t} \cdot z\_m\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z\_m}{t \cdot t} \cdot z\_m\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x x) (*.f64 y y)) < 1e-224

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot \color{blue}{z} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      4. associate-/r*N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      5. associate-*l/N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{\color{blue}{t}} \]
      6. associate-*r/N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      7. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      8. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      9. lift-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites59.1%

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

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
      4. frac-2negN/A

        \[\leadsto \frac{z}{t} \cdot \frac{\mathsf{neg}\left(z\right)}{\color{blue}{\mathsf{neg}\left(t\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\mathsf{neg}\left(z\right)}{-t} \]
      6. frac-timesN/A

        \[\leadsto \frac{z \cdot \left(\mathsf{neg}\left(z\right)\right)}{\color{blue}{t \cdot \left(-t\right)}} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto \frac{\mathsf{neg}\left(z \cdot z\right)}{\color{blue}{t} \cdot \left(-t\right)} \]
      8. pow2N/A

        \[\leadsto \frac{\mathsf{neg}\left({z}^{2}\right)}{t \cdot \left(-t\right)} \]
      9. mul-1-negN/A

        \[\leadsto \frac{-1 \cdot {z}^{2}}{\color{blue}{t} \cdot \left(-t\right)} \]
      10. *-commutativeN/A

        \[\leadsto \frac{{z}^{2} \cdot -1}{\color{blue}{t} \cdot \left(-t\right)} \]
      11. frac-timesN/A

        \[\leadsto \frac{{z}^{2}}{t} \cdot \color{blue}{\frac{-1}{-t}} \]
      12. pow2N/A

        \[\leadsto \frac{z \cdot z}{t} \cdot \frac{-1}{-t} \]
      13. associate-*l/N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{\color{blue}{-1}}{-t} \]
      14. lift-/.f64N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{-1}{-t} \]
      15. lift-/.f64N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{-1}{\color{blue}{-t}} \]
      16. associate-*l*N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(z \cdot \frac{-1}{-t}\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(z \cdot \frac{-1}{-t}\right)} \]
      18. *-commutativeN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot \color{blue}{z}\right) \]
      19. lower-*.f6459.1

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot \color{blue}{z}\right) \]
      20. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot z\right) \]
      21. metadata-evalN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{\mathsf{neg}\left(1\right)}{-t} \cdot z\right) \]
      22. lift-neg.f64N/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(t\right)} \cdot z\right) \]
      23. frac-2negN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{1}{t} \cdot z\right) \]
      24. lower-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \left(\frac{1}{t} \cdot z\right) \]
    8. Applied rewrites59.1%

      \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(\frac{1}{t} \cdot z\right)} \]

    if 1e-224 < (/.f64 (*.f64 x x) (*.f64 y y))

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      5. times-fracN/A

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} + \frac{z \cdot z}{t \cdot t} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{\color{blue}{z \cdot z}}{t \cdot t} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{z \cdot z}{\color{blue}{t \cdot t}} \]
      8. lift-/.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \color{blue}{\frac{z \cdot z}{t \cdot t}} \]
      9. pow2N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{\color{blue}{{z}^{2}}}{t \cdot t} \]
      10. pow2N/A

        \[\leadsto \frac{x}{y} \cdot \frac{x}{y} + \frac{{z}^{2}}{\color{blue}{{t}^{2}}} \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{{z}^{2}}{{t}^{2}}\right)} \]
      12. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, \frac{x}{y}, \frac{{z}^{2}}{{t}^{2}}\right) \]
      13. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \color{blue}{\frac{x}{y}}, \frac{{z}^{2}}{{t}^{2}}\right) \]
      14. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{\color{blue}{z \cdot z}}{{t}^{2}}\right) \]
      15. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{z \cdot \frac{z}{{t}^{2}}}\right) \]
      16. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{{t}^{2}} \cdot z}\right) \]
      17. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{{t}^{2}} \cdot z}\right) \]
      18. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{{t}^{2}}} \cdot z\right) \]
      19. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{\color{blue}{t \cdot t}} \cdot z\right) \]
      20. lift-*.f6488.8

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{\color{blue}{t \cdot t}} \cdot z\right) \]
    3. Applied rewrites88.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 86.1% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} t_1 := \frac{x \cdot x}{y \cdot y}\\ \mathbf{if}\;t\_1 \leq 10^{-224}:\\ \;\;\;\;\frac{z\_m}{t} \cdot \left(\frac{1}{t} \cdot z\_m\right)\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{z\_m}{t \cdot t}, z\_m, \frac{x}{y \cdot y} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{z\_m}{t}}{t} \cdot z\_m\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (let* ((t_1 (/ (* x x) (* y y))))
   (if (<= t_1 1e-224)
     (* (/ z_m t) (* (/ 1.0 t) z_m))
     (if (<= t_1 INFINITY)
       (fma (/ z_m (* t t)) z_m (* (/ x (* y y)) x))
       (* (/ (/ z_m t) t) z_m)))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double t_1 = (x * x) / (y * y);
	double tmp;
	if (t_1 <= 1e-224) {
		tmp = (z_m / t) * ((1.0 / t) * z_m);
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = fma((z_m / (t * t)), z_m, ((x / (y * y)) * x));
	} else {
		tmp = ((z_m / t) / t) * z_m;
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m, t)
	t_1 = Float64(Float64(x * x) / Float64(y * y))
	tmp = 0.0
	if (t_1 <= 1e-224)
		tmp = Float64(Float64(z_m / t) * Float64(Float64(1.0 / t) * z_m));
	elseif (t_1 <= Inf)
		tmp = fma(Float64(z_m / Float64(t * t)), z_m, Float64(Float64(x / Float64(y * y)) * x));
	else
		tmp = Float64(Float64(Float64(z_m / t) / t) * z_m);
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-224], N[(N[(z$95$m / t), $MachinePrecision] * N[(N[(1.0 / t), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(z$95$m / N[(t * t), $MachinePrecision]), $MachinePrecision] * z$95$m + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m / t), $MachinePrecision] / t), $MachinePrecision] * z$95$m), $MachinePrecision]]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
t_1 := \frac{x \cdot x}{y \cdot y}\\
\mathbf{if}\;t\_1 \leq 10^{-224}:\\
\;\;\;\;\frac{z\_m}{t} \cdot \left(\frac{1}{t} \cdot z\_m\right)\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{z\_m}{t \cdot t}, z\_m, \frac{x}{y \cdot y} \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{z\_m}{t}}{t} \cdot z\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x x) (*.f64 y y)) < 1e-224

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot \color{blue}{z} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      4. associate-/r*N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      5. associate-*l/N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{\color{blue}{t}} \]
      6. associate-*r/N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      7. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      8. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      9. lift-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites59.1%

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

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
      4. frac-2negN/A

        \[\leadsto \frac{z}{t} \cdot \frac{\mathsf{neg}\left(z\right)}{\color{blue}{\mathsf{neg}\left(t\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\mathsf{neg}\left(z\right)}{-t} \]
      6. frac-timesN/A

        \[\leadsto \frac{z \cdot \left(\mathsf{neg}\left(z\right)\right)}{\color{blue}{t \cdot \left(-t\right)}} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto \frac{\mathsf{neg}\left(z \cdot z\right)}{\color{blue}{t} \cdot \left(-t\right)} \]
      8. pow2N/A

        \[\leadsto \frac{\mathsf{neg}\left({z}^{2}\right)}{t \cdot \left(-t\right)} \]
      9. mul-1-negN/A

        \[\leadsto \frac{-1 \cdot {z}^{2}}{\color{blue}{t} \cdot \left(-t\right)} \]
      10. *-commutativeN/A

        \[\leadsto \frac{{z}^{2} \cdot -1}{\color{blue}{t} \cdot \left(-t\right)} \]
      11. frac-timesN/A

        \[\leadsto \frac{{z}^{2}}{t} \cdot \color{blue}{\frac{-1}{-t}} \]
      12. pow2N/A

        \[\leadsto \frac{z \cdot z}{t} \cdot \frac{-1}{-t} \]
      13. associate-*l/N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{\color{blue}{-1}}{-t} \]
      14. lift-/.f64N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{-1}{-t} \]
      15. lift-/.f64N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{-1}{\color{blue}{-t}} \]
      16. associate-*l*N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(z \cdot \frac{-1}{-t}\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(z \cdot \frac{-1}{-t}\right)} \]
      18. *-commutativeN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot \color{blue}{z}\right) \]
      19. lower-*.f6459.1

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot \color{blue}{z}\right) \]
      20. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot z\right) \]
      21. metadata-evalN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{\mathsf{neg}\left(1\right)}{-t} \cdot z\right) \]
      22. lift-neg.f64N/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(t\right)} \cdot z\right) \]
      23. frac-2negN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{1}{t} \cdot z\right) \]
      24. lower-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \left(\frac{1}{t} \cdot z\right) \]
    8. Applied rewrites59.1%

      \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(\frac{1}{t} \cdot z\right)} \]

    if 1e-224 < (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t} + \frac{x \cdot x}{y \cdot y}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{z \cdot z}}{t \cdot t} + \frac{x \cdot x}{y \cdot y} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{z \cdot z}{\color{blue}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      8. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      9. pow2N/A

        \[\leadsto \frac{z \cdot z}{\color{blue}{{t}^{2}}} + \frac{x \cdot x}{y \cdot y} \]
      10. associate-/l*N/A

        \[\leadsto \color{blue}{z \cdot \frac{z}{{t}^{2}}} + \frac{x \cdot x}{y \cdot y} \]
      11. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{z}{{t}^{2}} \cdot z} + \frac{x \cdot x}{y \cdot y} \]
      12. pow2N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z + \frac{\color{blue}{{x}^{2}}}{y \cdot y} \]
      13. pow2N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z + \frac{{x}^{2}}{\color{blue}{{y}^{2}}} \]
      14. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{{t}^{2}}, z, \frac{{x}^{2}}{{y}^{2}}\right)} \]
      15. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{{t}^{2}}}, z, \frac{{x}^{2}}{{y}^{2}}\right) \]
      16. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{\color{blue}{t \cdot t}}, z, \frac{{x}^{2}}{{y}^{2}}\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{\color{blue}{t \cdot t}}, z, \frac{{x}^{2}}{{y}^{2}}\right) \]
      18. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t \cdot t}, z, \frac{\color{blue}{x \cdot x}}{{y}^{2}}\right) \]
      19. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t \cdot t}, z, \color{blue}{x \cdot \frac{x}{{y}^{2}}}\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t \cdot t}, z, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
      21. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t \cdot t}, z, \color{blue}{\frac{x}{{y}^{2}} \cdot x}\right) \]
      22. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t \cdot t}, z, \color{blue}{\frac{x}{{y}^{2}}} \cdot x\right) \]
      23. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{z}{t \cdot t}, z, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
      24. lift-*.f6479.6

        \[\leadsto \mathsf{fma}\left(\frac{z}{t \cdot t}, z, \frac{x}{\color{blue}{y \cdot y}} \cdot x\right) \]
    3. Applied rewrites79.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t \cdot t}, z, \frac{x}{y \cdot y} \cdot x\right)} \]

    if +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y))

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      2. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. associate-/r*N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      5. lift-/.f6457.0

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
    6. Applied rewrites57.0%

      \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 79.8% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} t_1 := \frac{x \cdot x}{y \cdot y}\\ \mathbf{if}\;t\_1 \leq 10^{-38}:\\ \;\;\;\;\frac{z\_m}{t} \cdot \left(\frac{1}{t} \cdot z\_m\right)\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;\frac{\left(\frac{x}{y} \cdot x\right) \cdot t}{t \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{z\_m}{t}}{t} \cdot z\_m\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (let* ((t_1 (/ (* x x) (* y y))))
   (if (<= t_1 1e-38)
     (* (/ z_m t) (* (/ 1.0 t) z_m))
     (if (<= t_1 INFINITY)
       (/ (* (* (/ x y) x) t) (* t y))
       (* (/ (/ z_m t) t) z_m)))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double t_1 = (x * x) / (y * y);
	double tmp;
	if (t_1 <= 1e-38) {
		tmp = (z_m / t) * ((1.0 / t) * z_m);
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = (((x / y) * x) * t) / (t * y);
	} else {
		tmp = ((z_m / t) / t) * z_m;
	}
	return tmp;
}
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
	double t_1 = (x * x) / (y * y);
	double tmp;
	if (t_1 <= 1e-38) {
		tmp = (z_m / t) * ((1.0 / t) * z_m);
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = (((x / y) * x) * t) / (t * y);
	} else {
		tmp = ((z_m / t) / t) * z_m;
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	t_1 = (x * x) / (y * y)
	tmp = 0
	if t_1 <= 1e-38:
		tmp = (z_m / t) * ((1.0 / t) * z_m)
	elif t_1 <= math.inf:
		tmp = (((x / y) * x) * t) / (t * y)
	else:
		tmp = ((z_m / t) / t) * z_m
	return tmp
z_m = abs(z)
function code(x, y, z_m, t)
	t_1 = Float64(Float64(x * x) / Float64(y * y))
	tmp = 0.0
	if (t_1 <= 1e-38)
		tmp = Float64(Float64(z_m / t) * Float64(Float64(1.0 / t) * z_m));
	elseif (t_1 <= Inf)
		tmp = Float64(Float64(Float64(Float64(x / y) * x) * t) / Float64(t * y));
	else
		tmp = Float64(Float64(Float64(z_m / t) / t) * z_m);
	end
	return tmp
end
z_m = abs(z);
function tmp_2 = code(x, y, z_m, t)
	t_1 = (x * x) / (y * y);
	tmp = 0.0;
	if (t_1 <= 1e-38)
		tmp = (z_m / t) * ((1.0 / t) * z_m);
	elseif (t_1 <= Inf)
		tmp = (((x / y) * x) * t) / (t * y);
	else
		tmp = ((z_m / t) / t) * z_m;
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-38], N[(N[(z$95$m / t), $MachinePrecision] * N[(N[(1.0 / t), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[(x / y), $MachinePrecision] * x), $MachinePrecision] * t), $MachinePrecision] / N[(t * y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m / t), $MachinePrecision] / t), $MachinePrecision] * z$95$m), $MachinePrecision]]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
t_1 := \frac{x \cdot x}{y \cdot y}\\
\mathbf{if}\;t\_1 \leq 10^{-38}:\\
\;\;\;\;\frac{z\_m}{t} \cdot \left(\frac{1}{t} \cdot z\_m\right)\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\left(\frac{x}{y} \cdot x\right) \cdot t}{t \cdot y}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{z\_m}{t}}{t} \cdot z\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x x) (*.f64 y y)) < 9.9999999999999996e-39

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot \color{blue}{z} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      4. associate-/r*N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      5. associate-*l/N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{\color{blue}{t}} \]
      6. associate-*r/N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      7. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      8. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      9. lift-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites59.1%

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

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
      4. frac-2negN/A

        \[\leadsto \frac{z}{t} \cdot \frac{\mathsf{neg}\left(z\right)}{\color{blue}{\mathsf{neg}\left(t\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\mathsf{neg}\left(z\right)}{-t} \]
      6. frac-timesN/A

        \[\leadsto \frac{z \cdot \left(\mathsf{neg}\left(z\right)\right)}{\color{blue}{t \cdot \left(-t\right)}} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto \frac{\mathsf{neg}\left(z \cdot z\right)}{\color{blue}{t} \cdot \left(-t\right)} \]
      8. pow2N/A

        \[\leadsto \frac{\mathsf{neg}\left({z}^{2}\right)}{t \cdot \left(-t\right)} \]
      9. mul-1-negN/A

        \[\leadsto \frac{-1 \cdot {z}^{2}}{\color{blue}{t} \cdot \left(-t\right)} \]
      10. *-commutativeN/A

        \[\leadsto \frac{{z}^{2} \cdot -1}{\color{blue}{t} \cdot \left(-t\right)} \]
      11. frac-timesN/A

        \[\leadsto \frac{{z}^{2}}{t} \cdot \color{blue}{\frac{-1}{-t}} \]
      12. pow2N/A

        \[\leadsto \frac{z \cdot z}{t} \cdot \frac{-1}{-t} \]
      13. associate-*l/N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{\color{blue}{-1}}{-t} \]
      14. lift-/.f64N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{-1}{-t} \]
      15. lift-/.f64N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{-1}{\color{blue}{-t}} \]
      16. associate-*l*N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(z \cdot \frac{-1}{-t}\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(z \cdot \frac{-1}{-t}\right)} \]
      18. *-commutativeN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot \color{blue}{z}\right) \]
      19. lower-*.f6459.1

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot \color{blue}{z}\right) \]
      20. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot z\right) \]
      21. metadata-evalN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{\mathsf{neg}\left(1\right)}{-t} \cdot z\right) \]
      22. lift-neg.f64N/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(t\right)} \cdot z\right) \]
      23. frac-2negN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{1}{t} \cdot z\right) \]
      24. lower-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \left(\frac{1}{t} \cdot z\right) \]
    8. Applied rewrites59.1%

      \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(\frac{1}{t} \cdot z\right)} \]

    if 9.9999999999999996e-39 < (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t} + \frac{x \cdot x}{y \cdot y}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{z \cdot z}}{t \cdot t} + \frac{x \cdot x}{y \cdot y} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{z \cdot z}{\color{blue}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      8. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{z \cdot z}{t \cdot t}} + \frac{x \cdot x}{y \cdot y} \]
      9. pow2N/A

        \[\leadsto \frac{\color{blue}{{z}^{2}}}{t \cdot t} + \frac{x \cdot x}{y \cdot y} \]
      10. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{{z}^{2}}{t}}{t}} + \frac{x \cdot x}{y \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{t} + \frac{\color{blue}{{x}^{2}}}{y \cdot y} \]
      12. associate-/r*N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{t} + \color{blue}{\frac{\frac{{x}^{2}}{y}}{y}} \]
      13. frac-addN/A

        \[\leadsto \color{blue}{\frac{\frac{{z}^{2}}{t} \cdot y + t \cdot \frac{{x}^{2}}{y}}{t \cdot y}} \]
      14. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{{z}^{2}}{t} \cdot y + t \cdot \frac{{x}^{2}}{y}}{t \cdot y}} \]
    3. Applied rewrites81.2%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z \cdot \frac{z}{t}, y, t \cdot \left(x \cdot \frac{x}{y}\right)\right)}{t \cdot y}} \]
    4. Taylor expanded in x around 0

      \[\leadsto \frac{\color{blue}{\frac{y \cdot {z}^{2}}{t}}}{t \cdot y} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{y \cdot {z}^{2}}{\color{blue}{t}}}{t \cdot y} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\frac{{z}^{2} \cdot y}{t}}{t \cdot y} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{\frac{{z}^{2} \cdot y}{t}}{t \cdot y} \]
      4. pow2N/A

        \[\leadsto \frac{\frac{\left(z \cdot z\right) \cdot y}{t}}{t \cdot y} \]
      5. lift-*.f6447.7

        \[\leadsto \frac{\frac{\left(z \cdot z\right) \cdot y}{t}}{t \cdot y} \]
    6. Applied rewrites47.7%

      \[\leadsto \frac{\color{blue}{\frac{\left(z \cdot z\right) \cdot y}{t}}}{t \cdot y} \]
    7. Taylor expanded in x around inf

      \[\leadsto \frac{\color{blue}{\frac{t \cdot {x}^{2}}{y}}}{t \cdot y} \]
    8. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \frac{t \cdot \color{blue}{\frac{{x}^{2}}{y}}}{t \cdot y} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\frac{{x}^{2}}{y} \cdot \color{blue}{t}}{t \cdot y} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{\frac{{x}^{2}}{y} \cdot \color{blue}{t}}{t \cdot y} \]
      4. pow2N/A

        \[\leadsto \frac{\frac{x \cdot x}{y} \cdot t}{t \cdot y} \]
      5. associate-*l/N/A

        \[\leadsto \frac{\left(\frac{x}{y} \cdot x\right) \cdot t}{t \cdot y} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{\left(\frac{x}{y} \cdot x\right) \cdot t}{t \cdot y} \]
      7. lift-*.f6451.6

        \[\leadsto \frac{\left(\frac{x}{y} \cdot x\right) \cdot t}{t \cdot y} \]
    9. Applied rewrites51.6%

      \[\leadsto \frac{\color{blue}{\left(\frac{x}{y} \cdot x\right) \cdot t}}{t \cdot y} \]

    if +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y))

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      2. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. associate-/r*N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      5. lift-/.f6457.0

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
    6. Applied rewrites57.0%

      \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 59.1% accurate, 1.3× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;y \leq 6 \cdot 10^{-222}:\\ \;\;\;\;\frac{\frac{z\_m \cdot z\_m}{t}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{z\_m}{t} \cdot \left(\frac{1}{t} \cdot z\_m\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= y 6e-222) (/ (/ (* z_m z_m) t) t) (* (/ z_m t) (* (/ 1.0 t) z_m))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if (y <= 6e-222) {
		tmp = ((z_m * z_m) / t) / t;
	} else {
		tmp = (z_m / t) * ((1.0 / t) * z_m);
	}
	return tmp;
}
z_m =     private
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(x, y, z_m, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    real(8) :: tmp
    if (y <= 6d-222) then
        tmp = ((z_m * z_m) / t) / t
    else
        tmp = (z_m / t) * ((1.0d0 / t) * z_m)
    end if
    code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
	double tmp;
	if (y <= 6e-222) {
		tmp = ((z_m * z_m) / t) / t;
	} else {
		tmp = (z_m / t) * ((1.0 / t) * z_m);
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	tmp = 0
	if y <= 6e-222:
		tmp = ((z_m * z_m) / t) / t
	else:
		tmp = (z_m / t) * ((1.0 / t) * z_m)
	return tmp
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (y <= 6e-222)
		tmp = Float64(Float64(Float64(z_m * z_m) / t) / t);
	else
		tmp = Float64(Float64(z_m / t) * Float64(Float64(1.0 / t) * z_m));
	end
	return tmp
end
z_m = abs(z);
function tmp_2 = code(x, y, z_m, t)
	tmp = 0.0;
	if (y <= 6e-222)
		tmp = ((z_m * z_m) / t) / t;
	else
		tmp = (z_m / t) * ((1.0 / t) * z_m);
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[y, 6e-222], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] / t), $MachinePrecision] / t), $MachinePrecision], N[(N[(z$95$m / t), $MachinePrecision] * N[(N[(1.0 / t), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{-222}:\\
\;\;\;\;\frac{\frac{z\_m \cdot z\_m}{t}}{t}\\

\mathbf{else}:\\
\;\;\;\;\frac{z\_m}{t} \cdot \left(\frac{1}{t} \cdot z\_m\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 6.00000000000000059e-222

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot \color{blue}{z} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      4. pow2N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      5. associate-*l/N/A

        \[\leadsto \frac{z \cdot z}{\color{blue}{{t}^{2}}} \]
      6. pow2N/A

        \[\leadsto \frac{{z}^{2}}{{\color{blue}{t}}^{2}} \]
      7. pow2N/A

        \[\leadsto \frac{{z}^{2}}{t \cdot \color{blue}{t}} \]
      8. associate-/r*N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{\color{blue}{t}} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{\color{blue}{t}} \]
      10. pow2N/A

        \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]
      11. associate-*l/N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
      13. lift-/.f6457.4

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
    6. Applied rewrites57.4%

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

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
      3. associate-*l/N/A

        \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]
      4. pow2N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{t} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{t} \]
      6. pow2N/A

        \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]
      7. lift-*.f6453.2

        \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]
    8. Applied rewrites53.2%

      \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]

    if 6.00000000000000059e-222 < y

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot \color{blue}{z} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      4. associate-/r*N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      5. associate-*l/N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{\color{blue}{t}} \]
      6. associate-*r/N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      7. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      8. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      9. lift-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites59.1%

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

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
      4. frac-2negN/A

        \[\leadsto \frac{z}{t} \cdot \frac{\mathsf{neg}\left(z\right)}{\color{blue}{\mathsf{neg}\left(t\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\mathsf{neg}\left(z\right)}{-t} \]
      6. frac-timesN/A

        \[\leadsto \frac{z \cdot \left(\mathsf{neg}\left(z\right)\right)}{\color{blue}{t \cdot \left(-t\right)}} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto \frac{\mathsf{neg}\left(z \cdot z\right)}{\color{blue}{t} \cdot \left(-t\right)} \]
      8. pow2N/A

        \[\leadsto \frac{\mathsf{neg}\left({z}^{2}\right)}{t \cdot \left(-t\right)} \]
      9. mul-1-negN/A

        \[\leadsto \frac{-1 \cdot {z}^{2}}{\color{blue}{t} \cdot \left(-t\right)} \]
      10. *-commutativeN/A

        \[\leadsto \frac{{z}^{2} \cdot -1}{\color{blue}{t} \cdot \left(-t\right)} \]
      11. frac-timesN/A

        \[\leadsto \frac{{z}^{2}}{t} \cdot \color{blue}{\frac{-1}{-t}} \]
      12. pow2N/A

        \[\leadsto \frac{z \cdot z}{t} \cdot \frac{-1}{-t} \]
      13. associate-*l/N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{\color{blue}{-1}}{-t} \]
      14. lift-/.f64N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{-1}{-t} \]
      15. lift-/.f64N/A

        \[\leadsto \left(\frac{z}{t} \cdot z\right) \cdot \frac{-1}{\color{blue}{-t}} \]
      16. associate-*l*N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(z \cdot \frac{-1}{-t}\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\left(z \cdot \frac{-1}{-t}\right)} \]
      18. *-commutativeN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot \color{blue}{z}\right) \]
      19. lower-*.f6459.1

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot \color{blue}{z}\right) \]
      20. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{-1}{-t} \cdot z\right) \]
      21. metadata-evalN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{\mathsf{neg}\left(1\right)}{-t} \cdot z\right) \]
      22. lift-neg.f64N/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(t\right)} \cdot z\right) \]
      23. frac-2negN/A

        \[\leadsto \frac{z}{t} \cdot \left(\frac{1}{t} \cdot z\right) \]
      24. lower-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \left(\frac{1}{t} \cdot z\right) \]
    8. Applied rewrites59.1%

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

Alternative 8: 56.5% accurate, 1.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;y \leq 6 \cdot 10^{-222}:\\ \;\;\;\;\frac{\frac{z\_m \cdot z\_m}{t}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{z\_m}{t} \cdot \frac{z\_m}{t}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= y 6e-222) (/ (/ (* z_m z_m) t) t) (* (/ z_m t) (/ z_m t))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if (y <= 6e-222) {
		tmp = ((z_m * z_m) / t) / t;
	} else {
		tmp = (z_m / t) * (z_m / t);
	}
	return tmp;
}
z_m =     private
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(x, y, z_m, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    real(8) :: tmp
    if (y <= 6d-222) then
        tmp = ((z_m * z_m) / t) / t
    else
        tmp = (z_m / t) * (z_m / t)
    end if
    code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
	double tmp;
	if (y <= 6e-222) {
		tmp = ((z_m * z_m) / t) / t;
	} else {
		tmp = (z_m / t) * (z_m / t);
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	tmp = 0
	if y <= 6e-222:
		tmp = ((z_m * z_m) / t) / t
	else:
		tmp = (z_m / t) * (z_m / t)
	return tmp
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (y <= 6e-222)
		tmp = Float64(Float64(Float64(z_m * z_m) / t) / t);
	else
		tmp = Float64(Float64(z_m / t) * Float64(z_m / t));
	end
	return tmp
end
z_m = abs(z);
function tmp_2 = code(x, y, z_m, t)
	tmp = 0.0;
	if (y <= 6e-222)
		tmp = ((z_m * z_m) / t) / t;
	else
		tmp = (z_m / t) * (z_m / t);
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[y, 6e-222], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] / t), $MachinePrecision] / t), $MachinePrecision], N[(N[(z$95$m / t), $MachinePrecision] * N[(z$95$m / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{-222}:\\
\;\;\;\;\frac{\frac{z\_m \cdot z\_m}{t}}{t}\\

\mathbf{else}:\\
\;\;\;\;\frac{z\_m}{t} \cdot \frac{z\_m}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 6.00000000000000059e-222

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot \color{blue}{z} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      4. pow2N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      5. associate-*l/N/A

        \[\leadsto \frac{z \cdot z}{\color{blue}{{t}^{2}}} \]
      6. pow2N/A

        \[\leadsto \frac{{z}^{2}}{{\color{blue}{t}}^{2}} \]
      7. pow2N/A

        \[\leadsto \frac{{z}^{2}}{t \cdot \color{blue}{t}} \]
      8. associate-/r*N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{\color{blue}{t}} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{\color{blue}{t}} \]
      10. pow2N/A

        \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]
      11. associate-*l/N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
      13. lift-/.f6457.4

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
    6. Applied rewrites57.4%

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

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{t} \]
      3. associate-*l/N/A

        \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]
      4. pow2N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{t} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\frac{{z}^{2}}{t}}{t} \]
      6. pow2N/A

        \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]
      7. lift-*.f6453.2

        \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]
    8. Applied rewrites53.2%

      \[\leadsto \frac{\frac{z \cdot z}{t}}{t} \]

    if 6.00000000000000059e-222 < y

    1. Initial program 65.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
      6. pow2N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      7. lift-*.f6452.1

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. Applied rewrites52.1%

      \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot \color{blue}{z} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      3. lift-/.f64N/A

        \[\leadsto \frac{z}{t \cdot t} \cdot z \]
      4. associate-/r*N/A

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      5. associate-*l/N/A

        \[\leadsto \frac{\frac{z}{t} \cdot z}{\color{blue}{t}} \]
      6. associate-*r/N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      7. lower-*.f64N/A

        \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
      8. lift-/.f64N/A

        \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
      9. lift-/.f6459.1

        \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites59.1%

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

Alternative 9: 56.5% accurate, 2.1× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \frac{z\_m}{t} \cdot \frac{z\_m}{t} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t) :precision binary64 (* (/ z_m t) (/ z_m t)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	return (z_m / t) * (z_m / t);
}
z_m =     private
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(x, y, z_m, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    code = (z_m / t) * (z_m / t)
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
	return (z_m / t) * (z_m / t);
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	return (z_m / t) * (z_m / t)
z_m = abs(z)
function code(x, y, z_m, t)
	return Float64(Float64(z_m / t) * Float64(z_m / t))
end
z_m = abs(z);
function tmp = code(x, y, z_m, t)
	tmp = (z_m / t) * (z_m / t);
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := N[(N[(z$95$m / t), $MachinePrecision] * N[(z$95$m / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|

\\
\frac{z\_m}{t} \cdot \frac{z\_m}{t}
\end{array}
Derivation
  1. Initial program 65.8%

    \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
  3. Step-by-step derivation
    1. pow2N/A

      \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
    2. associate-/l*N/A

      \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
    3. *-commutativeN/A

      \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
    5. lower-/.f64N/A

      \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
    6. pow2N/A

      \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    7. lift-*.f6452.1

      \[\leadsto \frac{z}{t \cdot t} \cdot z \]
  4. Applied rewrites52.1%

    \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{z}{t \cdot t} \cdot \color{blue}{z} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    3. lift-/.f64N/A

      \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    4. associate-/r*N/A

      \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
    5. associate-*l/N/A

      \[\leadsto \frac{\frac{z}{t} \cdot z}{\color{blue}{t}} \]
    6. associate-*r/N/A

      \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
    7. lower-*.f64N/A

      \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
    8. lift-/.f64N/A

      \[\leadsto \frac{z}{t} \cdot \frac{\color{blue}{z}}{t} \]
    9. lift-/.f6459.1

      \[\leadsto \frac{z}{t} \cdot \frac{z}{\color{blue}{t}} \]
  6. Applied rewrites59.1%

    \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
  7. Add Preprocessing

Alternative 10: 52.1% accurate, 2.2× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \frac{z\_m}{t \cdot t} \cdot z\_m \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t) :precision binary64 (* (/ z_m (* t t)) z_m))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	return (z_m / (t * t)) * z_m;
}
z_m =     private
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(x, y, z_m, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    code = (z_m / (t * t)) * z_m
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
	return (z_m / (t * t)) * z_m;
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	return (z_m / (t * t)) * z_m
z_m = abs(z)
function code(x, y, z_m, t)
	return Float64(Float64(z_m / Float64(t * t)) * z_m)
end
z_m = abs(z);
function tmp = code(x, y, z_m, t)
	tmp = (z_m / (t * t)) * z_m;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := N[(N[(z$95$m / N[(t * t), $MachinePrecision]), $MachinePrecision] * z$95$m), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|

\\
\frac{z\_m}{t \cdot t} \cdot z\_m
\end{array}
Derivation
  1. Initial program 65.8%

    \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
  3. Step-by-step derivation
    1. pow2N/A

      \[\leadsto \frac{z \cdot z}{{\color{blue}{t}}^{2}} \]
    2. associate-/l*N/A

      \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
    3. *-commutativeN/A

      \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{z}{{t}^{2}} \cdot \color{blue}{z} \]
    5. lower-/.f64N/A

      \[\leadsto \frac{z}{{t}^{2}} \cdot z \]
    6. pow2N/A

      \[\leadsto \frac{z}{t \cdot t} \cdot z \]
    7. lift-*.f6452.1

      \[\leadsto \frac{z}{t \cdot t} \cdot z \]
  4. Applied rewrites52.1%

    \[\leadsto \color{blue}{\frac{z}{t \cdot t} \cdot z} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025131 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1"
  :precision binary64
  (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))