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

Percentage Accurate: 66.4% → 92.3%
Time: 6.5s
Alternatives: 9
Speedup: 0.8×

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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 66.4% 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: 92.3% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{z\_m \cdot z\_m}{t\_m \cdot t\_m}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+228}:\\
\;\;\;\;\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m} + t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 1.9999999999999998e228

    1. Initial program 77.5%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. 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. times-fracN/A

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

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

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot \frac{x}{y} + \frac{z \cdot z}{t \cdot t} \]
      7. lower-/.f6496.6

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} + \frac{z \cdot z}{t \cdot t} \]
    4. Applied rewrites96.6%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} + \frac{z \cdot z}{t \cdot t} \]

    if 1.9999999999999998e228 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 55.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. Applied rewrites81.5%

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

      \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \color{blue}{\frac{z}{t}} \]
    5. Step-by-step derivation
      1. lower-/.f6485.9

        \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites85.9%

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

Alternative 2: 89.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{z\_m \cdot z\_m}{t\_m \cdot t\_m}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-315}:\\
\;\;\;\;\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+228}:\\
\;\;\;\;\frac{x\_m \cdot x\_m}{y\_m \cdot y\_m} + z\_m \cdot \frac{z\_m}{t\_m \cdot t\_m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 2.0000000019e-315

    1. Initial program 70.3%

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z}{t}} \cdot \frac{z}{t} \]
      7. lower-/.f6474.6

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
    4. Applied rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(\frac{x}{y} \cdot x\right) \cdot t + y \cdot \left(\frac{z}{t} \cdot z\right)}{y \cdot t}} \]
      14. *-commutativeN/A

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

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

        \[\leadsto \frac{t \cdot \left(\frac{x}{y} \cdot x\right) + \color{blue}{\left(\frac{z}{t} \cdot z\right) \cdot y}}{y \cdot t} \]
      17. +-commutativeN/A

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
    8. Step-by-step derivation
      1. unpow2N/A

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

        \[\leadsto \frac{x \cdot x}{y \cdot \color{blue}{y}} \]
      3. times-fracN/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{x}}{y} \]
      6. lower-/.f6495.2

        \[\leadsto \frac{x}{y} \cdot \frac{x}{\color{blue}{y}} \]
    9. Applied rewrites95.2%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} \]

    if 2.0000000019e-315 < (/.f64 (*.f64 z z) (*.f64 t t)) < 1.9999999999999998e228

    1. Initial program 92.7%

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z}{t}} \cdot \frac{z}{t} \]
      7. lower-/.f6492.8

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
    4. Applied rewrites92.8%

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \frac{\mathsf{neg}\left(z\right)}{t \cdot t}} \]
      8. lower-neg.f64N/A

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\left(-z\right)} \cdot \frac{\mathsf{neg}\left(z\right)}{t \cdot t} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \left(-z\right) \cdot \color{blue}{\frac{\mathsf{neg}\left(z\right)}{t \cdot t}} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \left(-z\right) \cdot \frac{\color{blue}{-z}}{t \cdot t} \]
      11. lower-*.f6492.9

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \left(-z\right) \cdot \frac{-z}{\color{blue}{t \cdot t}} \]
    6. Applied rewrites92.9%

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

    if 1.9999999999999998e228 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 55.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. Applied rewrites81.5%

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

      \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \color{blue}{\frac{z}{t}} \]
    5. Step-by-step derivation
      1. lower-/.f6485.9

        \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites85.9%

      \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \color{blue}{\frac{z}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 2 \cdot 10^{-315}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\ \mathbf{elif}\;\frac{z \cdot z}{t \cdot t} \leq 2 \cdot 10^{+228}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y} + z \cdot \frac{z}{t \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{z}{t} + \frac{x}{y}\right) \cdot \frac{z}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 89.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{z\_m \cdot z\_m}{t\_m \cdot t\_m}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-315}:\\
\;\;\;\;\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+228}:\\
\;\;\;\;\frac{x\_m \cdot x\_m}{y\_m \cdot y\_m} + t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 2.0000000019e-315

    1. Initial program 70.3%

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z}{t}} \cdot \frac{z}{t} \]
      7. lower-/.f6474.6

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
    4. Applied rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(\frac{x}{y} \cdot x\right) \cdot t + y \cdot \left(\frac{z}{t} \cdot z\right)}{y \cdot t}} \]
      14. *-commutativeN/A

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

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

        \[\leadsto \frac{t \cdot \left(\frac{x}{y} \cdot x\right) + \color{blue}{\left(\frac{z}{t} \cdot z\right) \cdot y}}{y \cdot t} \]
      17. +-commutativeN/A

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
    8. Step-by-step derivation
      1. unpow2N/A

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

        \[\leadsto \frac{x \cdot x}{y \cdot \color{blue}{y}} \]
      3. times-fracN/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{x}}{y} \]
      6. lower-/.f6495.2

        \[\leadsto \frac{x}{y} \cdot \frac{x}{\color{blue}{y}} \]
    9. Applied rewrites95.2%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} \]

    if 2.0000000019e-315 < (/.f64 (*.f64 z z) (*.f64 t t)) < 1.9999999999999998e228

    1. Initial program 92.7%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing

    if 1.9999999999999998e228 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 55.8%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. Applied rewrites81.5%

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

      \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \color{blue}{\frac{z}{t}} \]
    5. Step-by-step derivation
      1. lower-/.f6485.9

        \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites85.9%

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

Alternative 4: 86.6% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 5.00000000000000018e-285

    1. Initial program 70.6%

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z}{t}} \cdot \frac{z}{t} \]
      7. lower-/.f6474.9

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
    4. Applied rewrites74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(\frac{x}{y} \cdot x\right) \cdot t + y \cdot \left(\frac{z}{t} \cdot z\right)}{y \cdot t}} \]
      14. *-commutativeN/A

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

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

        \[\leadsto \frac{t \cdot \left(\frac{x}{y} \cdot x\right) + \color{blue}{\left(\frac{z}{t} \cdot z\right) \cdot y}}{y \cdot t} \]
      17. +-commutativeN/A

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
    8. Step-by-step derivation
      1. unpow2N/A

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

        \[\leadsto \frac{x \cdot x}{y \cdot \color{blue}{y}} \]
      3. times-fracN/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{x}}{y} \]
      6. lower-/.f6495.3

        \[\leadsto \frac{x}{y} \cdot \frac{x}{\color{blue}{y}} \]
    9. Applied rewrites95.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} \]

    if 5.00000000000000018e-285 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 65.5%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. Applied rewrites77.0%

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

      \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \color{blue}{\frac{z}{t}} \]
    5. Step-by-step derivation
      1. lower-/.f6481.9

        \[\leadsto \left(\frac{z}{t} + \frac{x}{y}\right) \cdot \frac{z}{\color{blue}{t}} \]
    6. Applied rewrites81.9%

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

Alternative 5: 80.5% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 5.00000000000000018e-285

    1. Initial program 70.6%

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z}{t}} \cdot \frac{z}{t} \]
      7. lower-/.f6474.9

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
    4. Applied rewrites74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(\frac{x}{y} \cdot x\right) \cdot t + y \cdot \left(\frac{z}{t} \cdot z\right)}{y \cdot t}} \]
      14. *-commutativeN/A

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

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

        \[\leadsto \frac{t \cdot \left(\frac{x}{y} \cdot x\right) + \color{blue}{\left(\frac{z}{t} \cdot z\right) \cdot y}}{y \cdot t} \]
      17. +-commutativeN/A

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
    8. Step-by-step derivation
      1. unpow2N/A

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

        \[\leadsto \frac{x \cdot x}{y \cdot \color{blue}{y}} \]
      3. times-fracN/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{x}}{y} \]
      6. lower-/.f6495.3

        \[\leadsto \frac{x}{y} \cdot \frac{x}{\color{blue}{y}} \]
    9. Applied rewrites95.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} \]

    if 5.00000000000000018e-285 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 65.5%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y \cdot \frac{z}{t}, z, \color{blue}{\left(\frac{x}{y} \cdot x\right) \cdot t}\right)}{t \cdot y} \]
      9. lower-*.f6484.4

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

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

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

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

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

        \[\leadsto \frac{{z}^{2}}{{t}^{2}} \]
      4. *-commutativeN/A

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

        \[\leadsto \frac{{z}^{2}}{{t}^{2}} \]
      6. +-commutativeN/A

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

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

        \[\leadsto \frac{\color{blue}{{z}^{2}}}{{t}^{2}} \]
    9. Applied rewrites81.5%

      \[\leadsto \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 5 \cdot 10^{-285}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 78.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 5.00000000000000018e-285

    1. Initial program 70.6%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

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

        \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
      6. lower-/.f64N/A

        \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
      7. lower-/.f6487.4

        \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
    5. Applied rewrites87.4%

      \[\leadsto \color{blue}{\frac{\frac{x}{y}}{y} \cdot x} \]

    if 5.00000000000000018e-285 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 65.5%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y \cdot \frac{z}{t}, z, \color{blue}{\left(\frac{x}{y} \cdot x\right) \cdot t}\right)}{t \cdot y} \]
      9. lower-*.f6484.4

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

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

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

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

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

        \[\leadsto \frac{{z}^{2}}{{t}^{2}} \]
      4. *-commutativeN/A

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

        \[\leadsto \frac{{z}^{2}}{{t}^{2}} \]
      6. +-commutativeN/A

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

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

        \[\leadsto \frac{\color{blue}{{z}^{2}}}{{t}^{2}} \]
    9. Applied rewrites81.5%

      \[\leadsto \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 5 \cdot 10^{-285}:\\ \;\;\;\;\frac{\frac{x}{y}}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 77.2% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 5.00000000000000018e-285

    1. Initial program 70.6%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

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

        \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
      6. lower-/.f64N/A

        \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
      7. lower-/.f6487.4

        \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
    5. Applied rewrites87.4%

      \[\leadsto \color{blue}{\frac{\frac{x}{y}}{y} \cdot x} \]

    if 5.00000000000000018e-285 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 65.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
      7. lower-/.f6478.7

        \[\leadsto \frac{\frac{z}{t}}{t} \cdot z \]
    5. Applied rewrites78.7%

      \[\leadsto \color{blue}{\frac{\frac{z}{t}}{t} \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification81.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 5 \cdot 10^{-285}:\\ \;\;\;\;\frac{\frac{x}{y}}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{z}{t}}{t} \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 57.5% accurate, 1.6× speedup?

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

\\
\frac{\frac{x\_m}{y\_m}}{y\_m} \cdot x\_m
\end{array}
Derivation
  1. Initial program 67.4%

    \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

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

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

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

      \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
    6. lower-/.f64N/A

      \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
    7. lower-/.f6449.2

      \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
  5. Applied rewrites49.2%

    \[\leadsto \color{blue}{\frac{\frac{x}{y}}{y} \cdot x} \]
  6. Final simplification49.2%

    \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
  7. Add Preprocessing

Alternative 9: 53.0% accurate, 2.1× speedup?

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

\\
\frac{x\_m}{y\_m \cdot y\_m} \cdot x\_m
\end{array}
Derivation
  1. Initial program 67.4%

    \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
  4. Step-by-step derivation
    1. unpow2N/A

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

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

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

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

      \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
    6. lower-/.f64N/A

      \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
    7. lower-/.f6449.2

      \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
  5. Applied rewrites49.2%

    \[\leadsto \color{blue}{\frac{\frac{x}{y}}{y} \cdot x} \]
  6. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \frac{\frac{x}{y}}{y} \cdot x \]
    2. lift-/.f64N/A

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

      \[\leadsto \frac{x}{y \cdot y} \cdot x \]
    4. lift-*.f64N/A

      \[\leadsto \frac{x}{y \cdot y} \cdot x \]
    5. lower-/.f6444.6

      \[\leadsto \frac{x}{y \cdot y} \cdot x \]
  7. Applied rewrites44.6%

    \[\leadsto \frac{x}{y \cdot y} \cdot x \]
  8. Final simplification44.6%

    \[\leadsto \frac{x}{y \cdot y} \cdot x \]
  9. Add Preprocessing

Developer Target 1: 99.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ {\left(\frac{x}{y}\right)}^{2} + {\left(\frac{z}{t}\right)}^{2} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ (pow (/ x y) 2.0) (pow (/ z t) 2.0)))
double code(double x, double y, double z, double t) {
	return pow((x / y), 2.0) + pow((z / t), 2.0);
}
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 / y) ** 2.0d0) + ((z / t) ** 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
	return Math.pow((x / y), 2.0) + Math.pow((z / t), 2.0);
}
def code(x, y, z, t):
	return math.pow((x / y), 2.0) + math.pow((z / t), 2.0)
function code(x, y, z, t)
	return Float64((Float64(x / y) ^ 2.0) + (Float64(z / t) ^ 2.0))
end
function tmp = code(x, y, z, t)
	tmp = ((x / y) ^ 2.0) + ((z / t) ^ 2.0);
end
code[x_, y_, z_, t_] := N[(N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(z / t), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(\frac{x}{y}\right)}^{2} + {\left(\frac{z}{t}\right)}^{2}
\end{array}

Reproduce

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

  :alt
  (! :herbie-platform default (+ (pow (/ x y) 2) (pow (/ z t) 2)))

  (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))