Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3

Percentage Accurate: 50.2% → 91.7%
Time: 8.0s
Alternatives: 6
Speedup: 2.2×

Specification

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

\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t\_0}{x \cdot x + t\_0}
\end{array}
\end{array}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t\_0}{x \cdot x + t\_0}
\end{array}
\end{array}

Alternative 1: 91.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3.8 \cdot 10^{+99}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-4 \cdot \frac{y\_m}{x}, y\_m, x\right)}{\mathsf{fma}\left(4 \cdot y\_m, \frac{y\_m}{x}, x\right)}\\

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 3.8e99

    1. Initial program 50.2%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      2. mult-flipN/A

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

        \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      4. lift--.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      5. sub-flipN/A

        \[\leadsto \color{blue}{\left(x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot y\right)\right)\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      6. +-commutativeN/A

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot y}\right)\right) + x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      8. distribute-lft-neg-outN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y \cdot 4\right), y, x \cdot x\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{y \cdot 4}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{4 \cdot y}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      12. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      13. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      14. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-4} \cdot y, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      15. lower-/.f6449.4

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

        \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      17. +-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{\left(y \cdot 4\right) \cdot y} + x \cdot x} \]
      19. lower-fma.f6449.4

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

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

        \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{4 \cdot y}, y, x \cdot x\right)} \]
      22. lower-*.f6449.4

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

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

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

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

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

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

        \[\leadsto \frac{1 - \left(\color{blue}{\frac{\frac{y}{x}}{x}} \cdot 4\right) \cdot y}{\mathsf{fma}\left(\frac{y}{x \cdot x}, 4 \cdot y, 1\right)} \cdot 1 \]
      5. lower-/.f6459.9

        \[\leadsto \frac{1 - \left(\frac{\color{blue}{\frac{y}{x}}}{x} \cdot 4\right) \cdot y}{\mathsf{fma}\left(\frac{y}{x \cdot x}, 4 \cdot y, 1\right)} \cdot 1 \]
    6. Applied rewrites59.9%

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

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

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

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

        \[\leadsto \frac{1 - \left(\frac{\frac{y}{x}}{x} \cdot 4\right) \cdot y}{\mathsf{fma}\left(\color{blue}{\frac{\frac{y}{x}}{x}}, 4 \cdot y, 1\right)} \cdot 1 \]
      5. lower-/.f6468.7

        \[\leadsto \frac{1 - \left(\frac{\frac{y}{x}}{x} \cdot 4\right) \cdot y}{\mathsf{fma}\left(\frac{\color{blue}{\frac{y}{x}}}{x}, 4 \cdot y, 1\right)} \cdot 1 \]
    8. Applied rewrites68.7%

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

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

    if 3.8e99 < y

    1. Initial program 50.2%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-1} \]
    3. Step-by-step derivation
      1. Applied rewrites50.1%

        \[\leadsto \color{blue}{-1} \]
    4. Recombined 2 regimes into one program.
    5. Add Preprocessing

    Alternative 2: 65.0% accurate, 0.8× speedup?

    \[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{-162}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{+103}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-4 \cdot y\_m, y\_m, x \cdot x\right)}{\mathsf{fma}\left(4 \cdot y\_m, y\_m, x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4 \cdot \frac{y\_m}{x}, y\_m, x\right) \cdot \frac{1}{x}\\ \end{array} \end{array} \]
    y_m = (fabs.f64 y)
    (FPCore (x y_m)
     :precision binary64
     (if (<= x 3.5e-162)
       -1.0
       (if (<= x 9e+103)
         (/ (fma (* -4.0 y_m) y_m (* x x)) (fma (* 4.0 y_m) y_m (* x x)))
         (* (fma (* -4.0 (/ y_m x)) y_m x) (/ 1.0 x)))))
    y_m = fabs(y);
    double code(double x, double y_m) {
    	double tmp;
    	if (x <= 3.5e-162) {
    		tmp = -1.0;
    	} else if (x <= 9e+103) {
    		tmp = fma((-4.0 * y_m), y_m, (x * x)) / fma((4.0 * y_m), y_m, (x * x));
    	} else {
    		tmp = fma((-4.0 * (y_m / x)), y_m, x) * (1.0 / x);
    	}
    	return tmp;
    }
    
    y_m = abs(y)
    function code(x, y_m)
    	tmp = 0.0
    	if (x <= 3.5e-162)
    		tmp = -1.0;
    	elseif (x <= 9e+103)
    		tmp = Float64(fma(Float64(-4.0 * y_m), y_m, Float64(x * x)) / fma(Float64(4.0 * y_m), y_m, Float64(x * x)));
    	else
    		tmp = Float64(fma(Float64(-4.0 * Float64(y_m / x)), y_m, x) * Float64(1.0 / x));
    	end
    	return tmp
    end
    
    y_m = N[Abs[y], $MachinePrecision]
    code[x_, y$95$m_] := If[LessEqual[x, 3.5e-162], -1.0, If[LessEqual[x, 9e+103], N[(N[(N[(-4.0 * y$95$m), $MachinePrecision] * y$95$m + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(N[(4.0 * y$95$m), $MachinePrecision] * y$95$m + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] * y$95$m + x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    y_m = \left|y\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 3.5 \cdot 10^{-162}:\\
    \;\;\;\;-1\\
    
    \mathbf{elif}\;x \leq 9 \cdot 10^{+103}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(-4 \cdot y\_m, y\_m, x \cdot x\right)}{\mathsf{fma}\left(4 \cdot y\_m, y\_m, x \cdot x\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(-4 \cdot \frac{y\_m}{x}, y\_m, x\right) \cdot \frac{1}{x}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if x < 3.4999999999999999e-162

      1. Initial program 50.2%

        \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      2. Taylor expanded in x around 0

        \[\leadsto \color{blue}{-1} \]
      3. Step-by-step derivation
        1. Applied rewrites50.1%

          \[\leadsto \color{blue}{-1} \]

        if 3.4999999999999999e-162 < x < 9.00000000000000002e103

        1. Initial program 50.2%

          \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
        2. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \frac{\color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot y}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          2. sub-flipN/A

            \[\leadsto \frac{\color{blue}{x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot y\right)\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          3. +-commutativeN/A

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

            \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot y}\right)\right) + x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          5. distribute-lft-neg-outN/A

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

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

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

            \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{4 \cdot y}\right), y, x \cdot x\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          9. distribute-lft-neg-inN/A

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

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          11. metadata-eval50.2

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

            \[\leadsto \frac{\mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right)}{\color{blue}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
          13. +-commutativeN/A

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

            \[\leadsto \frac{\mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right)}{\color{blue}{\left(y \cdot 4\right) \cdot y} + x \cdot x} \]
          15. lower-fma.f6450.2

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

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

            \[\leadsto \frac{\mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right)}{\mathsf{fma}\left(\color{blue}{4 \cdot y}, y, x \cdot x\right)} \]
          18. lower-*.f6450.2

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

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

        if 9.00000000000000002e103 < x

        1. Initial program 50.2%

          \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
        2. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \color{blue}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
          2. mult-flipN/A

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

            \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
          4. lift--.f64N/A

            \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          5. sub-flipN/A

            \[\leadsto \color{blue}{\left(x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot y\right)\right)\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          6. +-commutativeN/A

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

            \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot y}\right)\right) + x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          8. distribute-lft-neg-outN/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y \cdot 4\right), y, x \cdot x\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          10. lift-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{y \cdot 4}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          11. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{4 \cdot y}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          12. distribute-lft-neg-inN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          13. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          14. metadata-evalN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{-4} \cdot y, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          15. lower-/.f6449.4

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

            \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
          17. +-commutativeN/A

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

            \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{\left(y \cdot 4\right) \cdot y} + x \cdot x} \]
          19. lower-fma.f6449.4

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

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

            \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{4 \cdot y}, y, x \cdot x\right)} \]
          22. lower-*.f6449.4

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

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

          \[\leadsto \color{blue}{\left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \frac{x}{\mathsf{fma}\left(4 \cdot y, y, x \cdot x\right)}} \]
        5. Taylor expanded in x around inf

          \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \color{blue}{\frac{1}{x}} \]
        6. Step-by-step derivation
          1. lower-/.f6445.4

            \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \frac{1}{\color{blue}{x}} \]
        7. Applied rewrites45.4%

          \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \color{blue}{\frac{1}{x}} \]
        8. Step-by-step derivation
          1. Applied rewrites51.6%

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

        Alternative 3: 61.1% accurate, 0.9× speedup?

        \[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \mathsf{fma}\left(-4 \cdot \frac{y\_m}{x}, y\_m, x\right) \cdot \frac{1}{x}\\ \mathbf{if}\;x \leq 8 \cdot 10^{-73}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-16}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+46}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        y_m = (fabs.f64 y)
        (FPCore (x y_m)
         :precision binary64
         (let* ((t_0 (* (fma (* -4.0 (/ y_m x)) y_m x) (/ 1.0 x))))
           (if (<= x 8e-73)
             -1.0
             (if (<= x 3.3e-16) t_0 (if (<= x 3.7e+46) -1.0 t_0)))))
        y_m = fabs(y);
        double code(double x, double y_m) {
        	double t_0 = fma((-4.0 * (y_m / x)), y_m, x) * (1.0 / x);
        	double tmp;
        	if (x <= 8e-73) {
        		tmp = -1.0;
        	} else if (x <= 3.3e-16) {
        		tmp = t_0;
        	} else if (x <= 3.7e+46) {
        		tmp = -1.0;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        y_m = abs(y)
        function code(x, y_m)
        	t_0 = Float64(fma(Float64(-4.0 * Float64(y_m / x)), y_m, x) * Float64(1.0 / x))
        	tmp = 0.0
        	if (x <= 8e-73)
        		tmp = -1.0;
        	elseif (x <= 3.3e-16)
        		tmp = t_0;
        	elseif (x <= 3.7e+46)
        		tmp = -1.0;
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        y_m = N[Abs[y], $MachinePrecision]
        code[x_, y$95$m_] := Block[{t$95$0 = N[(N[(N[(-4.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] * y$95$m + x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 8e-73], -1.0, If[LessEqual[x, 3.3e-16], t$95$0, If[LessEqual[x, 3.7e+46], -1.0, t$95$0]]]]
        
        \begin{array}{l}
        y_m = \left|y\right|
        
        \\
        \begin{array}{l}
        t_0 := \mathsf{fma}\left(-4 \cdot \frac{y\_m}{x}, y\_m, x\right) \cdot \frac{1}{x}\\
        \mathbf{if}\;x \leq 8 \cdot 10^{-73}:\\
        \;\;\;\;-1\\
        
        \mathbf{elif}\;x \leq 3.3 \cdot 10^{-16}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;x \leq 3.7 \cdot 10^{+46}:\\
        \;\;\;\;-1\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 7.99999999999999998e-73 or 3.29999999999999988e-16 < x < 3.6999999999999999e46

          1. Initial program 50.2%

            \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
          2. Taylor expanded in x around 0

            \[\leadsto \color{blue}{-1} \]
          3. Step-by-step derivation
            1. Applied rewrites50.1%

              \[\leadsto \color{blue}{-1} \]

            if 7.99999999999999998e-73 < x < 3.29999999999999988e-16 or 3.6999999999999999e46 < x

            1. Initial program 50.2%

              \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
            2. Step-by-step derivation
              1. lift-/.f64N/A

                \[\leadsto \color{blue}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
              2. mult-flipN/A

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

                \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
              4. lift--.f64N/A

                \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              5. sub-flipN/A

                \[\leadsto \color{blue}{\left(x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot y\right)\right)\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              6. +-commutativeN/A

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

                \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot y}\right)\right) + x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              8. distribute-lft-neg-outN/A

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y \cdot 4\right), y, x \cdot x\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              10. lift-*.f64N/A

                \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{y \cdot 4}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              11. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{4 \cdot y}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              12. distribute-lft-neg-inN/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              13. lower-*.f64N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              14. metadata-evalN/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{-4} \cdot y, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              15. lower-/.f6449.4

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

                \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
              17. +-commutativeN/A

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

                \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{\left(y \cdot 4\right) \cdot y} + x \cdot x} \]
              19. lower-fma.f6449.4

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

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

                \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{4 \cdot y}, y, x \cdot x\right)} \]
              22. lower-*.f6449.4

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

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

              \[\leadsto \color{blue}{\left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \frac{x}{\mathsf{fma}\left(4 \cdot y, y, x \cdot x\right)}} \]
            5. Taylor expanded in x around inf

              \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \color{blue}{\frac{1}{x}} \]
            6. Step-by-step derivation
              1. lower-/.f6445.4

                \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \frac{1}{\color{blue}{x}} \]
            7. Applied rewrites45.4%

              \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \color{blue}{\frac{1}{x}} \]
            8. Step-by-step derivation
              1. Applied rewrites51.6%

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

            Alternative 4: 61.1% accurate, 0.9× speedup?

            \[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 8 \cdot 10^{-73}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-16}:\\ \;\;\;\;\left(\mathsf{fma}\left(-4 \cdot y\_m, \frac{y\_m}{x \cdot x}, 1\right) \cdot x\right) \cdot \frac{1}{x}\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+46}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4 \cdot \frac{y\_m}{x}, y\_m, x\right) \cdot \frac{1}{x}\\ \end{array} \end{array} \]
            y_m = (fabs.f64 y)
            (FPCore (x y_m)
             :precision binary64
             (if (<= x 8e-73)
               -1.0
               (if (<= x 3.3e-16)
                 (* (* (fma (* -4.0 y_m) (/ y_m (* x x)) 1.0) x) (/ 1.0 x))
                 (if (<= x 3.7e+46) -1.0 (* (fma (* -4.0 (/ y_m x)) y_m x) (/ 1.0 x))))))
            y_m = fabs(y);
            double code(double x, double y_m) {
            	double tmp;
            	if (x <= 8e-73) {
            		tmp = -1.0;
            	} else if (x <= 3.3e-16) {
            		tmp = (fma((-4.0 * y_m), (y_m / (x * x)), 1.0) * x) * (1.0 / x);
            	} else if (x <= 3.7e+46) {
            		tmp = -1.0;
            	} else {
            		tmp = fma((-4.0 * (y_m / x)), y_m, x) * (1.0 / x);
            	}
            	return tmp;
            }
            
            y_m = abs(y)
            function code(x, y_m)
            	tmp = 0.0
            	if (x <= 8e-73)
            		tmp = -1.0;
            	elseif (x <= 3.3e-16)
            		tmp = Float64(Float64(fma(Float64(-4.0 * y_m), Float64(y_m / Float64(x * x)), 1.0) * x) * Float64(1.0 / x));
            	elseif (x <= 3.7e+46)
            		tmp = -1.0;
            	else
            		tmp = Float64(fma(Float64(-4.0 * Float64(y_m / x)), y_m, x) * Float64(1.0 / x));
            	end
            	return tmp
            end
            
            y_m = N[Abs[y], $MachinePrecision]
            code[x_, y$95$m_] := If[LessEqual[x, 8e-73], -1.0, If[LessEqual[x, 3.3e-16], N[(N[(N[(N[(-4.0 * y$95$m), $MachinePrecision] * N[(y$95$m / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.7e+46], -1.0, N[(N[(N[(-4.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision] * y$95$m + x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]]
            
            \begin{array}{l}
            y_m = \left|y\right|
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq 8 \cdot 10^{-73}:\\
            \;\;\;\;-1\\
            
            \mathbf{elif}\;x \leq 3.3 \cdot 10^{-16}:\\
            \;\;\;\;\left(\mathsf{fma}\left(-4 \cdot y\_m, \frac{y\_m}{x \cdot x}, 1\right) \cdot x\right) \cdot \frac{1}{x}\\
            
            \mathbf{elif}\;x \leq 3.7 \cdot 10^{+46}:\\
            \;\;\;\;-1\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(-4 \cdot \frac{y\_m}{x}, y\_m, x\right) \cdot \frac{1}{x}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if x < 7.99999999999999998e-73 or 3.29999999999999988e-16 < x < 3.6999999999999999e46

              1. Initial program 50.2%

                \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
              2. Taylor expanded in x around 0

                \[\leadsto \color{blue}{-1} \]
              3. Step-by-step derivation
                1. Applied rewrites50.1%

                  \[\leadsto \color{blue}{-1} \]

                if 7.99999999999999998e-73 < x < 3.29999999999999988e-16

                1. Initial program 50.2%

                  \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                2. Step-by-step derivation
                  1. lift-/.f64N/A

                    \[\leadsto \color{blue}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
                  2. mult-flipN/A

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

                    \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
                  4. lift--.f64N/A

                    \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  5. sub-flipN/A

                    \[\leadsto \color{blue}{\left(x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot y\right)\right)\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  6. +-commutativeN/A

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

                    \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot y}\right)\right) + x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  8. distribute-lft-neg-outN/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y \cdot 4\right), y, x \cdot x\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  10. lift-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{y \cdot 4}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  11. *-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{4 \cdot y}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  12. distribute-lft-neg-inN/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  13. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  14. metadata-evalN/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{-4} \cdot y, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  15. lower-/.f6449.4

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

                    \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
                  17. +-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{\left(y \cdot 4\right) \cdot y} + x \cdot x} \]
                  19. lower-fma.f6449.4

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

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

                    \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{4 \cdot y}, y, x \cdot x\right)} \]
                  22. lower-*.f6449.4

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

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

                  \[\leadsto \color{blue}{\left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \frac{x}{\mathsf{fma}\left(4 \cdot y, y, x \cdot x\right)}} \]
                5. Taylor expanded in x around inf

                  \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \color{blue}{\frac{1}{x}} \]
                6. Step-by-step derivation
                  1. lower-/.f6445.4

                    \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \frac{1}{\color{blue}{x}} \]
                7. Applied rewrites45.4%

                  \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \color{blue}{\frac{1}{x}} \]
                8. Applied rewrites48.5%

                  \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-4 \cdot y, \frac{y}{x \cdot x}, 1\right) \cdot x\right)} \cdot \frac{1}{x} \]

                if 3.6999999999999999e46 < x

                1. Initial program 50.2%

                  \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                2. Step-by-step derivation
                  1. lift-/.f64N/A

                    \[\leadsto \color{blue}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
                  2. mult-flipN/A

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

                    \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
                  4. lift--.f64N/A

                    \[\leadsto \color{blue}{\left(x \cdot x - \left(y \cdot 4\right) \cdot y\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  5. sub-flipN/A

                    \[\leadsto \color{blue}{\left(x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot y\right)\right)\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  6. +-commutativeN/A

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

                    \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot y}\right)\right) + x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  8. distribute-lft-neg-outN/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y \cdot 4\right), y, x \cdot x\right)} \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  10. lift-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{y \cdot 4}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  11. *-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{4 \cdot y}\right), y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  12. distribute-lft-neg-inN/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  13. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot y}, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  14. metadata-evalN/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{-4} \cdot y, y, x \cdot x\right) \cdot \frac{1}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  15. lower-/.f6449.4

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

                    \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
                  17. +-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\color{blue}{\left(y \cdot 4\right) \cdot y} + x \cdot x} \]
                  19. lower-fma.f6449.4

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

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

                    \[\leadsto \mathsf{fma}\left(-4 \cdot y, y, x \cdot x\right) \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{4 \cdot y}, y, x \cdot x\right)} \]
                  22. lower-*.f6449.4

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

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

                  \[\leadsto \color{blue}{\left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \frac{x}{\mathsf{fma}\left(4 \cdot y, y, x \cdot x\right)}} \]
                5. Taylor expanded in x around inf

                  \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \color{blue}{\frac{1}{x}} \]
                6. Step-by-step derivation
                  1. lower-/.f6445.4

                    \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \frac{1}{\color{blue}{x}} \]
                7. Applied rewrites45.4%

                  \[\leadsto \left(\left(\frac{\left(-4 \cdot y\right) \cdot y}{x \cdot x} + 1\right) \cdot x\right) \cdot \color{blue}{\frac{1}{x}} \]
                8. Step-by-step derivation
                  1. Applied rewrites51.6%

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

                Alternative 5: 60.9% accurate, 2.2× speedup?

                \[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{-73}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-16}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+46}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
                y_m = (fabs.f64 y)
                (FPCore (x y_m)
                 :precision binary64
                 (if (<= x 4e-73) -1.0 (if (<= x 2e-16) 1.0 (if (<= x 3.7e+46) -1.0 1.0))))
                y_m = fabs(y);
                double code(double x, double y_m) {
                	double tmp;
                	if (x <= 4e-73) {
                		tmp = -1.0;
                	} else if (x <= 2e-16) {
                		tmp = 1.0;
                	} else if (x <= 3.7e+46) {
                		tmp = -1.0;
                	} else {
                		tmp = 1.0;
                	}
                	return tmp;
                }
                
                y_m =     private
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(x, y_m)
                use fmin_fmax_functions
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y_m
                    real(8) :: tmp
                    if (x <= 4d-73) then
                        tmp = -1.0d0
                    else if (x <= 2d-16) then
                        tmp = 1.0d0
                    else if (x <= 3.7d+46) then
                        tmp = -1.0d0
                    else
                        tmp = 1.0d0
                    end if
                    code = tmp
                end function
                
                y_m = Math.abs(y);
                public static double code(double x, double y_m) {
                	double tmp;
                	if (x <= 4e-73) {
                		tmp = -1.0;
                	} else if (x <= 2e-16) {
                		tmp = 1.0;
                	} else if (x <= 3.7e+46) {
                		tmp = -1.0;
                	} else {
                		tmp = 1.0;
                	}
                	return tmp;
                }
                
                y_m = math.fabs(y)
                def code(x, y_m):
                	tmp = 0
                	if x <= 4e-73:
                		tmp = -1.0
                	elif x <= 2e-16:
                		tmp = 1.0
                	elif x <= 3.7e+46:
                		tmp = -1.0
                	else:
                		tmp = 1.0
                	return tmp
                
                y_m = abs(y)
                function code(x, y_m)
                	tmp = 0.0
                	if (x <= 4e-73)
                		tmp = -1.0;
                	elseif (x <= 2e-16)
                		tmp = 1.0;
                	elseif (x <= 3.7e+46)
                		tmp = -1.0;
                	else
                		tmp = 1.0;
                	end
                	return tmp
                end
                
                y_m = abs(y);
                function tmp_2 = code(x, y_m)
                	tmp = 0.0;
                	if (x <= 4e-73)
                		tmp = -1.0;
                	elseif (x <= 2e-16)
                		tmp = 1.0;
                	elseif (x <= 3.7e+46)
                		tmp = -1.0;
                	else
                		tmp = 1.0;
                	end
                	tmp_2 = tmp;
                end
                
                y_m = N[Abs[y], $MachinePrecision]
                code[x_, y$95$m_] := If[LessEqual[x, 4e-73], -1.0, If[LessEqual[x, 2e-16], 1.0, If[LessEqual[x, 3.7e+46], -1.0, 1.0]]]
                
                \begin{array}{l}
                y_m = \left|y\right|
                
                \\
                \begin{array}{l}
                \mathbf{if}\;x \leq 4 \cdot 10^{-73}:\\
                \;\;\;\;-1\\
                
                \mathbf{elif}\;x \leq 2 \cdot 10^{-16}:\\
                \;\;\;\;1\\
                
                \mathbf{elif}\;x \leq 3.7 \cdot 10^{+46}:\\
                \;\;\;\;-1\\
                
                \mathbf{else}:\\
                \;\;\;\;1\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if x < 3.99999999999999999e-73 or 2e-16 < x < 3.6999999999999999e46

                  1. Initial program 50.2%

                    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                  2. Taylor expanded in x around 0

                    \[\leadsto \color{blue}{-1} \]
                  3. Step-by-step derivation
                    1. Applied rewrites50.1%

                      \[\leadsto \color{blue}{-1} \]

                    if 3.99999999999999999e-73 < x < 2e-16 or 3.6999999999999999e46 < x

                    1. Initial program 50.2%

                      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                    2. Taylor expanded in x around inf

                      \[\leadsto \color{blue}{1} \]
                    3. Step-by-step derivation
                      1. Applied rewrites50.4%

                        \[\leadsto \color{blue}{1} \]
                    4. Recombined 2 regimes into one program.
                    5. Add Preprocessing

                    Alternative 6: 50.1% accurate, 27.4× speedup?

                    \[\begin{array}{l} y_m = \left|y\right| \\ -1 \end{array} \]
                    y_m = (fabs.f64 y)
                    (FPCore (x y_m) :precision binary64 -1.0)
                    y_m = fabs(y);
                    double code(double x, double y_m) {
                    	return -1.0;
                    }
                    
                    y_m =     private
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(x, y_m)
                    use fmin_fmax_functions
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y_m
                        code = -1.0d0
                    end function
                    
                    y_m = Math.abs(y);
                    public static double code(double x, double y_m) {
                    	return -1.0;
                    }
                    
                    y_m = math.fabs(y)
                    def code(x, y_m):
                    	return -1.0
                    
                    y_m = abs(y)
                    function code(x, y_m)
                    	return -1.0
                    end
                    
                    y_m = abs(y);
                    function tmp = code(x, y_m)
                    	tmp = -1.0;
                    end
                    
                    y_m = N[Abs[y], $MachinePrecision]
                    code[x_, y$95$m_] := -1.0
                    
                    \begin{array}{l}
                    y_m = \left|y\right|
                    
                    \\
                    -1
                    \end{array}
                    
                    Derivation
                    1. Initial program 50.2%

                      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
                    2. Taylor expanded in x around 0

                      \[\leadsto \color{blue}{-1} \]
                    3. Step-by-step derivation
                      1. Applied rewrites50.1%

                        \[\leadsto \color{blue}{-1} \]
                      2. Add Preprocessing

                      Reproduce

                      ?
                      herbie shell --seed 2025148 
                      (FPCore (x y)
                        :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
                        :precision binary64
                        (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))