Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A

Percentage Accurate: 69.4% → 99.9%
Time: 3.2s
Alternatives: 11
Speedup: 1.1×

Specification

?
\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z):
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z)
	return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0))
end
function tmp = code(x, y, z)
	tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	(((x * x) + (y * y)) - (z * z)) / (y * (2))
END code
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}

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 11 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: 69.4% accurate, 1.0× speedup?

\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z):
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z)
	return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0))
end
function tmp = code(x, y, z)
	tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	(((x * x) + (y * y)) - (z * z)) / (y * (2))
END code
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}

Alternative 1: 99.9% accurate, 1.1× speedup?

\[0.5 \cdot \mathsf{fma}\left(x - \left|z\right|, \frac{\left|z\right| + x}{y}, y\right) \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (* 0.5 (fma (- x (fabs z)) (/ (+ (fabs z) x) y) y)))
double code(double x, double y, double z) {
	return 0.5 * fma((x - fabs(z)), ((fabs(z) + x) / y), y);
}
function code(x, y, z)
	return Float64(0.5 * fma(Float64(x - abs(z)), Float64(Float64(abs(z) + x) / y), y))
end
code[x_, y_, z_] := N[(0.5 * N[(N[(x - N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Abs[z], $MachinePrecision] + x), $MachinePrecision] / y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	(5e-1) * (((x - (abs(z))) * (((abs(z)) + x) / y)) + y)
END code
0.5 \cdot \mathsf{fma}\left(x - \left|z\right|, \frac{\left|z\right| + x}{y}, y\right)
Derivation
  1. Initial program 69.4%

    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
  2. Step-by-step derivation
    1. Applied rewrites89.0%

      \[\leadsto 0.5 \cdot \left(\frac{\left(x + z\right) \cdot \left(x - z\right)}{y} + y\right) \]
    2. Step-by-step derivation
      1. Applied rewrites99.9%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(x - z, \frac{z + x}{y}, y\right) \]
      2. Add Preprocessing

      Alternative 2: 85.7% accurate, 0.9× speedup?

      \[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+97}:\\ \;\;\;\;\mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x - z}{2 \cdot \frac{y}{z + x}}\\ \end{array} \]
      (FPCore (x y z)
        :precision binary64
        :pre TRUE
        (if (<= (* x x) 5e+97)
        (fma z (* z (/ -0.5 y)) (* y 0.5))
        (/ (- x z) (* 2.0 (/ y (+ z x))))))
      double code(double x, double y, double z) {
      	double tmp;
      	if ((x * x) <= 5e+97) {
      		tmp = fma(z, (z * (-0.5 / y)), (y * 0.5));
      	} else {
      		tmp = (x - z) / (2.0 * (y / (z + x)));
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	tmp = 0.0
      	if (Float64(x * x) <= 5e+97)
      		tmp = fma(z, Float64(z * Float64(-0.5 / y)), Float64(y * 0.5));
      	else
      		tmp = Float64(Float64(x - z) / Float64(2.0 * Float64(y / Float64(z + x))));
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+97], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision] + N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] / N[(2.0 * N[(y / N[(z + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      f(x, y, z):
      	x in [-inf, +inf],
      	y in [-inf, +inf],
      	z in [-inf, +inf]
      code: THEORY
      BEGIN
      f(x, y, z: real): real =
      	LET tmp = IF ((x * x) <= (49999999999999999884518512257185400348306273996201919460278431983048793274064838238955966239342592)) THEN ((z * (z * ((-5e-1) / y))) + (y * (5e-1))) ELSE ((x - z) / ((2) * (y / (z + x)))) ENDIF IN
      	tmp
      END code
      \begin{array}{l}
      \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+97}:\\
      \;\;\;\;\mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{x - z}{2 \cdot \frac{y}{z + x}}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 x x) < 5e97

        1. Initial program 69.4%

          \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
        2. Step-by-step derivation
          1. Applied rewrites93.6%

            \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, \mathsf{fma}\left(x, \frac{x}{y}, y\right) \cdot 0.5\right) \]
          2. Taylor expanded in x around 0

            \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, y \cdot 0.5\right) \]
          3. Step-by-step derivation
            1. Applied rewrites67.0%

              \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, y \cdot 0.5\right) \]
            2. Step-by-step derivation
              1. Applied rewrites66.9%

                \[\leadsto \mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right) \]

              if 5e97 < (*.f64 x x)

              1. Initial program 69.4%

                \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
              2. Step-by-step derivation
                1. Applied rewrites89.0%

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

                  \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                3. Step-by-step derivation
                  1. Applied rewrites61.6%

                    \[\leadsto 0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                  2. Step-by-step derivation
                    1. Applied rewrites67.1%

                      \[\leadsto \left(0.5 \cdot \frac{z + x}{y}\right) \cdot \left(x - z\right) \]
                    2. Step-by-step derivation
                      1. Applied rewrites67.1%

                        \[\leadsto \frac{x - z}{2 \cdot \frac{y}{z + x}} \]
                    3. Recombined 2 regimes into one program.
                    4. Add Preprocessing

                    Alternative 3: 85.7% accurate, 1.0× speedup?

                    \[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+112}:\\ \;\;\;\;\mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \frac{z + x}{y}\right) \cdot \left(x - z\right)\\ \end{array} \]
                    (FPCore (x y z)
                      :precision binary64
                      :pre TRUE
                      (if (<= (* x x) 2e+112)
                      (fma z (* z (/ -0.5 y)) (* y 0.5))
                      (* (* 0.5 (/ (+ z x) y)) (- x z))))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if ((x * x) <= 2e+112) {
                    		tmp = fma(z, (z * (-0.5 / y)), (y * 0.5));
                    	} else {
                    		tmp = (0.5 * ((z + x) / y)) * (x - z);
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if (Float64(x * x) <= 2e+112)
                    		tmp = fma(z, Float64(z * Float64(-0.5 / y)), Float64(y * 0.5));
                    	else
                    		tmp = Float64(Float64(0.5 * Float64(Float64(z + x) / y)) * Float64(x - z));
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+112], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision] + N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision]]
                    
                    f(x, y, z):
                    	x in [-inf, +inf],
                    	y in [-inf, +inf],
                    	z in [-inf, +inf]
                    code: THEORY
                    BEGIN
                    f(x, y, z: real): real =
                    	LET tmp = IF ((x * x) <= (19999999999999998602398693852608794569346663002779536985231793723294459665661827807523927173788508935154456068096)) THEN ((z * (z * ((-5e-1) / y))) + (y * (5e-1))) ELSE (((5e-1) * ((z + x) / y)) * (x - z)) ENDIF IN
                    	tmp
                    END code
                    \begin{array}{l}
                    \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+112}:\\
                    \;\;\;\;\mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\left(0.5 \cdot \frac{z + x}{y}\right) \cdot \left(x - z\right)\\
                    
                    
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (*.f64 x x) < 1.9999999999999999e112

                      1. Initial program 69.4%

                        \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                      2. Step-by-step derivation
                        1. Applied rewrites93.6%

                          \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, \mathsf{fma}\left(x, \frac{x}{y}, y\right) \cdot 0.5\right) \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, y \cdot 0.5\right) \]
                        3. Step-by-step derivation
                          1. Applied rewrites67.0%

                            \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, y \cdot 0.5\right) \]
                          2. Step-by-step derivation
                            1. Applied rewrites66.9%

                              \[\leadsto \mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right) \]

                            if 1.9999999999999999e112 < (*.f64 x x)

                            1. Initial program 69.4%

                              \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                            2. Step-by-step derivation
                              1. Applied rewrites89.0%

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

                                \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                              3. Step-by-step derivation
                                1. Applied rewrites61.6%

                                  \[\leadsto 0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                2. Step-by-step derivation
                                  1. Applied rewrites67.1%

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

                                Alternative 4: 85.6% accurate, 1.0× speedup?

                                \[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+112}:\\ \;\;\;\;\mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \frac{x - z}{y}\right) \cdot \left(z + x\right)\\ \end{array} \]
                                (FPCore (x y z)
                                  :precision binary64
                                  :pre TRUE
                                  (if (<= (* x x) 2e+112)
                                  (fma z (* z (/ -0.5 y)) (* y 0.5))
                                  (* (* 0.5 (/ (- x z) y)) (+ z x))))
                                double code(double x, double y, double z) {
                                	double tmp;
                                	if ((x * x) <= 2e+112) {
                                		tmp = fma(z, (z * (-0.5 / y)), (y * 0.5));
                                	} else {
                                		tmp = (0.5 * ((x - z) / y)) * (z + x);
                                	}
                                	return tmp;
                                }
                                
                                function code(x, y, z)
                                	tmp = 0.0
                                	if (Float64(x * x) <= 2e+112)
                                		tmp = fma(z, Float64(z * Float64(-0.5 / y)), Float64(y * 0.5));
                                	else
                                		tmp = Float64(Float64(0.5 * Float64(Float64(x - z) / y)) * Float64(z + x));
                                	end
                                	return tmp
                                end
                                
                                code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+112], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision] + N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * N[(z + x), $MachinePrecision]), $MachinePrecision]]
                                
                                f(x, y, z):
                                	x in [-inf, +inf],
                                	y in [-inf, +inf],
                                	z in [-inf, +inf]
                                code: THEORY
                                BEGIN
                                f(x, y, z: real): real =
                                	LET tmp = IF ((x * x) <= (19999999999999998602398693852608794569346663002779536985231793723294459665661827807523927173788508935154456068096)) THEN ((z * (z * ((-5e-1) / y))) + (y * (5e-1))) ELSE (((5e-1) * ((x - z) / y)) * (z + x)) ENDIF IN
                                	tmp
                                END code
                                \begin{array}{l}
                                \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+112}:\\
                                \;\;\;\;\mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right)\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\left(0.5 \cdot \frac{x - z}{y}\right) \cdot \left(z + x\right)\\
                                
                                
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if (*.f64 x x) < 1.9999999999999999e112

                                  1. Initial program 69.4%

                                    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites93.6%

                                      \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, \mathsf{fma}\left(x, \frac{x}{y}, y\right) \cdot 0.5\right) \]
                                    2. Taylor expanded in x around 0

                                      \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, y \cdot 0.5\right) \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites67.0%

                                        \[\leadsto \mathsf{fma}\left(z, \frac{z}{-2 \cdot y}, y \cdot 0.5\right) \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites66.9%

                                          \[\leadsto \mathsf{fma}\left(z, z \cdot \frac{-0.5}{y}, y \cdot 0.5\right) \]

                                        if 1.9999999999999999e112 < (*.f64 x x)

                                        1. Initial program 69.4%

                                          \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites89.0%

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

                                            \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites61.6%

                                              \[\leadsto 0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites67.1%

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

                                            Alternative 5: 82.4% accurate, 0.9× speedup?

                                            \[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 1.5 \cdot 10^{+300}:\\ \;\;\;\;0.5 \cdot \mathsf{fma}\left(x - \left|z\right|, \frac{\left|z\right|}{y}, y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \frac{x}{y}\right) \cdot \left(\left|z\right| + x\right)\\ \end{array} \]
                                            (FPCore (x y z)
                                              :precision binary64
                                              :pre TRUE
                                              (if (<= (* x x) 1.5e+300)
                                              (* 0.5 (fma (- x (fabs z)) (/ (fabs z) y) y))
                                              (* (* 0.5 (/ x y)) (+ (fabs z) x))))
                                            double code(double x, double y, double z) {
                                            	double tmp;
                                            	if ((x * x) <= 1.5e+300) {
                                            		tmp = 0.5 * fma((x - fabs(z)), (fabs(z) / y), y);
                                            	} else {
                                            		tmp = (0.5 * (x / y)) * (fabs(z) + x);
                                            	}
                                            	return tmp;
                                            }
                                            
                                            function code(x, y, z)
                                            	tmp = 0.0
                                            	if (Float64(x * x) <= 1.5e+300)
                                            		tmp = Float64(0.5 * fma(Float64(x - abs(z)), Float64(abs(z) / y), y));
                                            	else
                                            		tmp = Float64(Float64(0.5 * Float64(x / y)) * Float64(abs(z) + x));
                                            	end
                                            	return tmp
                                            end
                                            
                                            code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.5e+300], N[(0.5 * N[(N[(x - N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[z], $MachinePrecision] / y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(x / y), $MachinePrecision]), $MachinePrecision] * N[(N[Abs[z], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
                                            
                                            f(x, y, z):
                                            	x in [-inf, +inf],
                                            	y in [-inf, +inf],
                                            	z in [-inf, +inf]
                                            code: THEORY
                                            BEGIN
                                            f(x, y, z: real): real =
                                            	LET tmp = IF ((x * x) <= (1500000000000000078757140382806630373056702871662238732373781173267703686983362293679557062620671796065556665749325817265413784853040645863467188277180060474272580801389863705606745350692182135089053429852456199917621678558451461320111979114170213741868888183230085264257173504208294580298189100810240)) THEN ((5e-1) * (((x - (abs(z))) * ((abs(z)) / y)) + y)) ELSE (((5e-1) * (x / y)) * ((abs(z)) + x)) ENDIF IN
                                            	tmp
                                            END code
                                            \begin{array}{l}
                                            \mathbf{if}\;x \cdot x \leq 1.5 \cdot 10^{+300}:\\
                                            \;\;\;\;0.5 \cdot \mathsf{fma}\left(x - \left|z\right|, \frac{\left|z\right|}{y}, y\right)\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\left(0.5 \cdot \frac{x}{y}\right) \cdot \left(\left|z\right| + x\right)\\
                                            
                                            
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. if (*.f64 x x) < 1.5000000000000001e300

                                              1. Initial program 69.4%

                                                \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites89.0%

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

                                                  \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites65.6%

                                                    \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                  2. Step-by-step derivation
                                                    1. Applied rewrites71.1%

                                                      \[\leadsto 0.5 \cdot \mathsf{fma}\left(x - z, \frac{z}{y}, y\right) \]

                                                    if 1.5000000000000001e300 < (*.f64 x x)

                                                    1. Initial program 69.4%

                                                      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                    2. Step-by-step derivation
                                                      1. Applied rewrites89.0%

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

                                                        \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites61.6%

                                                          \[\leadsto 0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                        2. Step-by-step derivation
                                                          1. Applied rewrites67.1%

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

                                                            \[\leadsto \left(0.5 \cdot \frac{x}{y}\right) \cdot \left(z + x\right) \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites39.1%

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

                                                          Alternative 6: 81.9% accurate, 0.9× speedup?

                                                          \[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 1.5 \cdot 10^{+300}:\\ \;\;\;\;0.5 \cdot \mathsf{fma}\left(\frac{x - \left|z\right|}{y}, \left|z\right|, y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \frac{x}{y}\right) \cdot \left(\left|z\right| + x\right)\\ \end{array} \]
                                                          (FPCore (x y z)
                                                            :precision binary64
                                                            :pre TRUE
                                                            (if (<= (* x x) 1.5e+300)
                                                            (* 0.5 (fma (/ (- x (fabs z)) y) (fabs z) y))
                                                            (* (* 0.5 (/ x y)) (+ (fabs z) x))))
                                                          double code(double x, double y, double z) {
                                                          	double tmp;
                                                          	if ((x * x) <= 1.5e+300) {
                                                          		tmp = 0.5 * fma(((x - fabs(z)) / y), fabs(z), y);
                                                          	} else {
                                                          		tmp = (0.5 * (x / y)) * (fabs(z) + x);
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          function code(x, y, z)
                                                          	tmp = 0.0
                                                          	if (Float64(x * x) <= 1.5e+300)
                                                          		tmp = Float64(0.5 * fma(Float64(Float64(x - abs(z)) / y), abs(z), y));
                                                          	else
                                                          		tmp = Float64(Float64(0.5 * Float64(x / y)) * Float64(abs(z) + x));
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.5e+300], N[(0.5 * N[(N[(N[(x - N[Abs[z], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * N[Abs[z], $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(x / y), $MachinePrecision]), $MachinePrecision] * N[(N[Abs[z], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
                                                          
                                                          f(x, y, z):
                                                          	x in [-inf, +inf],
                                                          	y in [-inf, +inf],
                                                          	z in [-inf, +inf]
                                                          code: THEORY
                                                          BEGIN
                                                          f(x, y, z: real): real =
                                                          	LET tmp = IF ((x * x) <= (1500000000000000078757140382806630373056702871662238732373781173267703686983362293679557062620671796065556665749325817265413784853040645863467188277180060474272580801389863705606745350692182135089053429852456199917621678558451461320111979114170213741868888183230085264257173504208294580298189100810240)) THEN ((5e-1) * ((((x - (abs(z))) / y) * (abs(z))) + y)) ELSE (((5e-1) * (x / y)) * ((abs(z)) + x)) ENDIF IN
                                                          	tmp
                                                          END code
                                                          \begin{array}{l}
                                                          \mathbf{if}\;x \cdot x \leq 1.5 \cdot 10^{+300}:\\
                                                          \;\;\;\;0.5 \cdot \mathsf{fma}\left(\frac{x - \left|z\right|}{y}, \left|z\right|, y\right)\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;\left(0.5 \cdot \frac{x}{y}\right) \cdot \left(\left|z\right| + x\right)\\
                                                          
                                                          
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 2 regimes
                                                          2. if (*.f64 x x) < 1.5000000000000001e300

                                                            1. Initial program 69.4%

                                                              \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                            2. Step-by-step derivation
                                                              1. Applied rewrites89.0%

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

                                                                \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites65.6%

                                                                  \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                2. Step-by-step derivation
                                                                  1. Applied rewrites73.2%

                                                                    \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x - z}{y}, z, y\right) \]

                                                                  if 1.5000000000000001e300 < (*.f64 x x)

                                                                  1. Initial program 69.4%

                                                                    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                  2. Step-by-step derivation
                                                                    1. Applied rewrites89.0%

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

                                                                      \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                                    3. Step-by-step derivation
                                                                      1. Applied rewrites61.6%

                                                                        \[\leadsto 0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                                      2. Step-by-step derivation
                                                                        1. Applied rewrites67.1%

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

                                                                          \[\leadsto \left(0.5 \cdot \frac{x}{y}\right) \cdot \left(z + x\right) \]
                                                                        3. Step-by-step derivation
                                                                          1. Applied rewrites39.1%

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

                                                                        Alternative 7: 77.6% accurate, 0.2× speedup?

                                                                        \[\begin{array}{l} t_0 := \frac{\left|x\right|}{\left|y\right|}\\ t_1 := \frac{\left(\left|x\right| \cdot \left|x\right| + \left|y\right| \cdot \left|y\right|\right) - \left|z\right| \cdot \left|z\right|}{\left|y\right| \cdot 2}\\ t_2 := 0.5 \cdot \mathsf{fma}\left(t\_0, \left|z\right|, \left|y\right|\right)\\ \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq -4 \cdot 10^{-140}:\\ \;\;\;\;\left|z\right| \cdot \left(\frac{\left|x\right| - \left|z\right|}{\left|y\right|} \cdot 0.5\right)\\ \mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+145}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 10^{+300}:\\ \;\;\;\;\left(0.5 \cdot t\_0\right) \cdot \left(\left|z\right| + \left|x\right|\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
                                                                        (FPCore (x y z)
                                                                          :precision binary64
                                                                          :pre TRUE
                                                                          (let* ((t_0 (/ (fabs x) (fabs y)))
                                                                               (t_1
                                                                                (/
                                                                                 (-
                                                                                  (+ (* (fabs x) (fabs x)) (* (fabs y) (fabs y)))
                                                                                  (* (fabs z) (fabs z)))
                                                                                 (* (fabs y) 2.0)))
                                                                               (t_2 (* 0.5 (fma t_0 (fabs z) (fabs y)))))
                                                                          (*
                                                                           (copysign 1.0 y)
                                                                           (if (<= t_1 -4e-140)
                                                                             (* (fabs z) (* (/ (- (fabs x) (fabs z)) (fabs y)) 0.5))
                                                                             (if (<= t_1 4e+145)
                                                                               t_2
                                                                               (if (<= t_1 1e+300)
                                                                                 (* (* 0.5 t_0) (+ (fabs z) (fabs x)))
                                                                                 t_2))))))
                                                                        double code(double x, double y, double z) {
                                                                        	double t_0 = fabs(x) / fabs(y);
                                                                        	double t_1 = (((fabs(x) * fabs(x)) + (fabs(y) * fabs(y))) - (fabs(z) * fabs(z))) / (fabs(y) * 2.0);
                                                                        	double t_2 = 0.5 * fma(t_0, fabs(z), fabs(y));
                                                                        	double tmp;
                                                                        	if (t_1 <= -4e-140) {
                                                                        		tmp = fabs(z) * (((fabs(x) - fabs(z)) / fabs(y)) * 0.5);
                                                                        	} else if (t_1 <= 4e+145) {
                                                                        		tmp = t_2;
                                                                        	} else if (t_1 <= 1e+300) {
                                                                        		tmp = (0.5 * t_0) * (fabs(z) + fabs(x));
                                                                        	} else {
                                                                        		tmp = t_2;
                                                                        	}
                                                                        	return copysign(1.0, y) * tmp;
                                                                        }
                                                                        
                                                                        function code(x, y, z)
                                                                        	t_0 = Float64(abs(x) / abs(y))
                                                                        	t_1 = Float64(Float64(Float64(Float64(abs(x) * abs(x)) + Float64(abs(y) * abs(y))) - Float64(abs(z) * abs(z))) / Float64(abs(y) * 2.0))
                                                                        	t_2 = Float64(0.5 * fma(t_0, abs(z), abs(y)))
                                                                        	tmp = 0.0
                                                                        	if (t_1 <= -4e-140)
                                                                        		tmp = Float64(abs(z) * Float64(Float64(Float64(abs(x) - abs(z)) / abs(y)) * 0.5));
                                                                        	elseif (t_1 <= 4e+145)
                                                                        		tmp = t_2;
                                                                        	elseif (t_1 <= 1e+300)
                                                                        		tmp = Float64(Float64(0.5 * t_0) * Float64(abs(z) + abs(x)));
                                                                        	else
                                                                        		tmp = t_2;
                                                                        	end
                                                                        	return Float64(copysign(1.0, y) * tmp)
                                                                        end
                                                                        
                                                                        code[x_, y_, z_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[Abs[y], $MachinePrecision] * N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[y], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(t$95$0 * N[Abs[z], $MachinePrecision] + N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -4e-140], N[(N[Abs[z], $MachinePrecision] * N[(N[(N[(N[Abs[x], $MachinePrecision] - N[Abs[z], $MachinePrecision]), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+145], t$95$2, If[LessEqual[t$95$1, 1e+300], N[(N[(0.5 * t$95$0), $MachinePrecision] * N[(N[Abs[z], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]), $MachinePrecision]]]]
                                                                        
                                                                        \begin{array}{l}
                                                                        t_0 := \frac{\left|x\right|}{\left|y\right|}\\
                                                                        t_1 := \frac{\left(\left|x\right| \cdot \left|x\right| + \left|y\right| \cdot \left|y\right|\right) - \left|z\right| \cdot \left|z\right|}{\left|y\right| \cdot 2}\\
                                                                        t_2 := 0.5 \cdot \mathsf{fma}\left(t\_0, \left|z\right|, \left|y\right|\right)\\
                                                                        \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
                                                                        \mathbf{if}\;t\_1 \leq -4 \cdot 10^{-140}:\\
                                                                        \;\;\;\;\left|z\right| \cdot \left(\frac{\left|x\right| - \left|z\right|}{\left|y\right|} \cdot 0.5\right)\\
                                                                        
                                                                        \mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+145}:\\
                                                                        \;\;\;\;t\_2\\
                                                                        
                                                                        \mathbf{elif}\;t\_1 \leq 10^{+300}:\\
                                                                        \;\;\;\;\left(0.5 \cdot t\_0\right) \cdot \left(\left|z\right| + \left|x\right|\right)\\
                                                                        
                                                                        \mathbf{else}:\\
                                                                        \;\;\;\;t\_2\\
                                                                        
                                                                        
                                                                        \end{array}
                                                                        \end{array}
                                                                        
                                                                        Derivation
                                                                        1. Split input into 3 regimes
                                                                        2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -3.9999999999999999e-140

                                                                          1. Initial program 69.4%

                                                                            \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                          2. Step-by-step derivation
                                                                            1. Applied rewrites89.0%

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

                                                                              \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                                            3. Step-by-step derivation
                                                                              1. Applied rewrites61.6%

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

                                                                                \[\leadsto 0.5 \cdot \frac{z \cdot \left(x - z\right)}{y} \]
                                                                              3. Step-by-step derivation
                                                                                1. Applied rewrites36.0%

                                                                                  \[\leadsto 0.5 \cdot \frac{z \cdot \left(x - z\right)}{y} \]
                                                                                2. Applied rewrites40.3%

                                                                                  \[\leadsto z \cdot \left(\frac{x - z}{y} \cdot 0.5\right) \]

                                                                                if -3.9999999999999999e-140 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 4e145 or 1.0000000000000001e300 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

                                                                                1. Initial program 69.4%

                                                                                  \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                                2. Step-by-step derivation
                                                                                  1. Applied rewrites89.0%

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

                                                                                    \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                                  3. Step-by-step derivation
                                                                                    1. Applied rewrites65.6%

                                                                                      \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                                    2. Step-by-step derivation
                                                                                      1. Applied rewrites73.2%

                                                                                        \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x - z}{y}, z, y\right) \]
                                                                                      2. Taylor expanded in x around inf

                                                                                        \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x}{y}, z, y\right) \]
                                                                                      3. Step-by-step derivation
                                                                                        1. Applied rewrites45.0%

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

                                                                                        if 4e145 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 1.0000000000000001e300

                                                                                        1. Initial program 69.4%

                                                                                          \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                                        2. Step-by-step derivation
                                                                                          1. Applied rewrites89.0%

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

                                                                                            \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                                                          3. Step-by-step derivation
                                                                                            1. Applied rewrites61.6%

                                                                                              \[\leadsto 0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                                                            2. Step-by-step derivation
                                                                                              1. Applied rewrites67.1%

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

                                                                                                \[\leadsto \left(0.5 \cdot \frac{x}{y}\right) \cdot \left(z + x\right) \]
                                                                                              3. Step-by-step derivation
                                                                                                1. Applied rewrites39.1%

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

                                                                                              Alternative 8: 73.4% accurate, 0.4× speedup?

                                                                                              \[\mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{\left(\left|x\right| \cdot \left|x\right| + \left|y\right| \cdot \left|y\right|\right) - \left|z\right| \cdot \left|z\right|}{\left|y\right| \cdot 2} \leq -4 \cdot 10^{-140}:\\ \;\;\;\;\left|z\right| \cdot \left(\frac{\left|x\right| - \left|z\right|}{\left|y\right|} \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \mathsf{fma}\left(\frac{\left|x\right|}{\left|y\right|}, \left|z\right|, \left|y\right|\right)\\ \end{array} \]
                                                                                              (FPCore (x y z)
                                                                                                :precision binary64
                                                                                                :pre TRUE
                                                                                                (*
                                                                                               (copysign 1.0 y)
                                                                                               (if (<=
                                                                                                    (/
                                                                                                     (-
                                                                                                      (+ (* (fabs x) (fabs x)) (* (fabs y) (fabs y)))
                                                                                                      (* (fabs z) (fabs z)))
                                                                                                     (* (fabs y) 2.0))
                                                                                                    -4e-140)
                                                                                                 (* (fabs z) (* (/ (- (fabs x) (fabs z)) (fabs y)) 0.5))
                                                                                                 (* 0.5 (fma (/ (fabs x) (fabs y)) (fabs z) (fabs y))))))
                                                                                              double code(double x, double y, double z) {
                                                                                              	double tmp;
                                                                                              	if (((((fabs(x) * fabs(x)) + (fabs(y) * fabs(y))) - (fabs(z) * fabs(z))) / (fabs(y) * 2.0)) <= -4e-140) {
                                                                                              		tmp = fabs(z) * (((fabs(x) - fabs(z)) / fabs(y)) * 0.5);
                                                                                              	} else {
                                                                                              		tmp = 0.5 * fma((fabs(x) / fabs(y)), fabs(z), fabs(y));
                                                                                              	}
                                                                                              	return copysign(1.0, y) * tmp;
                                                                                              }
                                                                                              
                                                                                              function code(x, y, z)
                                                                                              	tmp = 0.0
                                                                                              	if (Float64(Float64(Float64(Float64(abs(x) * abs(x)) + Float64(abs(y) * abs(y))) - Float64(abs(z) * abs(z))) / Float64(abs(y) * 2.0)) <= -4e-140)
                                                                                              		tmp = Float64(abs(z) * Float64(Float64(Float64(abs(x) - abs(z)) / abs(y)) * 0.5));
                                                                                              	else
                                                                                              		tmp = Float64(0.5 * fma(Float64(abs(x) / abs(y)), abs(z), abs(y)));
                                                                                              	end
                                                                                              	return Float64(copysign(1.0, y) * tmp)
                                                                                              end
                                                                                              
                                                                                              code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[Abs[y], $MachinePrecision] * N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[y], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], -4e-140], N[(N[Abs[z], $MachinePrecision] * N[(N[(N[(N[Abs[x], $MachinePrecision] - N[Abs[z], $MachinePrecision]), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[Abs[x], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] * N[Abs[z], $MachinePrecision] + N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                                                                                              
                                                                                              \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
                                                                                              \mathbf{if}\;\frac{\left(\left|x\right| \cdot \left|x\right| + \left|y\right| \cdot \left|y\right|\right) - \left|z\right| \cdot \left|z\right|}{\left|y\right| \cdot 2} \leq -4 \cdot 10^{-140}:\\
                                                                                              \;\;\;\;\left|z\right| \cdot \left(\frac{\left|x\right| - \left|z\right|}{\left|y\right|} \cdot 0.5\right)\\
                                                                                              
                                                                                              \mathbf{else}:\\
                                                                                              \;\;\;\;0.5 \cdot \mathsf{fma}\left(\frac{\left|x\right|}{\left|y\right|}, \left|z\right|, \left|y\right|\right)\\
                                                                                              
                                                                                              
                                                                                              \end{array}
                                                                                              
                                                                                              Derivation
                                                                                              1. Split input into 2 regimes
                                                                                              2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -3.9999999999999999e-140

                                                                                                1. Initial program 69.4%

                                                                                                  \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                                                2. Step-by-step derivation
                                                                                                  1. Applied rewrites89.0%

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

                                                                                                    \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                                                                  3. Step-by-step derivation
                                                                                                    1. Applied rewrites61.6%

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

                                                                                                      \[\leadsto 0.5 \cdot \frac{z \cdot \left(x - z\right)}{y} \]
                                                                                                    3. Step-by-step derivation
                                                                                                      1. Applied rewrites36.0%

                                                                                                        \[\leadsto 0.5 \cdot \frac{z \cdot \left(x - z\right)}{y} \]
                                                                                                      2. Applied rewrites40.3%

                                                                                                        \[\leadsto z \cdot \left(\frac{x - z}{y} \cdot 0.5\right) \]

                                                                                                      if -3.9999999999999999e-140 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

                                                                                                      1. Initial program 69.4%

                                                                                                        \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                                                      2. Step-by-step derivation
                                                                                                        1. Applied rewrites89.0%

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

                                                                                                          \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                                                        3. Step-by-step derivation
                                                                                                          1. Applied rewrites65.6%

                                                                                                            \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                                                          2. Step-by-step derivation
                                                                                                            1. Applied rewrites73.2%

                                                                                                              \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x - z}{y}, z, y\right) \]
                                                                                                            2. Taylor expanded in x around inf

                                                                                                              \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x}{y}, z, y\right) \]
                                                                                                            3. Step-by-step derivation
                                                                                                              1. Applied rewrites45.0%

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

                                                                                                            Alternative 9: 72.3% accurate, 0.4× speedup?

                                                                                                            \[\mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{\left(\left|x\right| \cdot \left|x\right| + \left|y\right| \cdot \left|y\right|\right) - \left|z\right| \cdot \left|z\right|}{\left|y\right| \cdot 2} \leq -4 \cdot 10^{-140}:\\ \;\;\;\;0.5 \cdot \frac{\left|z\right| \cdot \left(\left|x\right| - \left|z\right|\right)}{\left|y\right|}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \mathsf{fma}\left(\frac{\left|x\right|}{\left|y\right|}, \left|z\right|, \left|y\right|\right)\\ \end{array} \]
                                                                                                            (FPCore (x y z)
                                                                                                              :precision binary64
                                                                                                              :pre TRUE
                                                                                                              (*
                                                                                                             (copysign 1.0 y)
                                                                                                             (if (<=
                                                                                                                  (/
                                                                                                                   (-
                                                                                                                    (+ (* (fabs x) (fabs x)) (* (fabs y) (fabs y)))
                                                                                                                    (* (fabs z) (fabs z)))
                                                                                                                   (* (fabs y) 2.0))
                                                                                                                  -4e-140)
                                                                                                               (* 0.5 (/ (* (fabs z) (- (fabs x) (fabs z))) (fabs y)))
                                                                                                               (* 0.5 (fma (/ (fabs x) (fabs y)) (fabs z) (fabs y))))))
                                                                                                            double code(double x, double y, double z) {
                                                                                                            	double tmp;
                                                                                                            	if (((((fabs(x) * fabs(x)) + (fabs(y) * fabs(y))) - (fabs(z) * fabs(z))) / (fabs(y) * 2.0)) <= -4e-140) {
                                                                                                            		tmp = 0.5 * ((fabs(z) * (fabs(x) - fabs(z))) / fabs(y));
                                                                                                            	} else {
                                                                                                            		tmp = 0.5 * fma((fabs(x) / fabs(y)), fabs(z), fabs(y));
                                                                                                            	}
                                                                                                            	return copysign(1.0, y) * tmp;
                                                                                                            }
                                                                                                            
                                                                                                            function code(x, y, z)
                                                                                                            	tmp = 0.0
                                                                                                            	if (Float64(Float64(Float64(Float64(abs(x) * abs(x)) + Float64(abs(y) * abs(y))) - Float64(abs(z) * abs(z))) / Float64(abs(y) * 2.0)) <= -4e-140)
                                                                                                            		tmp = Float64(0.5 * Float64(Float64(abs(z) * Float64(abs(x) - abs(z))) / abs(y)));
                                                                                                            	else
                                                                                                            		tmp = Float64(0.5 * fma(Float64(abs(x) / abs(y)), abs(z), abs(y)));
                                                                                                            	end
                                                                                                            	return Float64(copysign(1.0, y) * tmp)
                                                                                                            end
                                                                                                            
                                                                                                            code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[Abs[y], $MachinePrecision] * N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[y], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], -4e-140], N[(0.5 * N[(N[(N[Abs[z], $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] - N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[Abs[x], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] * N[Abs[z], $MachinePrecision] + N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                                                                                                            
                                                                                                            \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
                                                                                                            \mathbf{if}\;\frac{\left(\left|x\right| \cdot \left|x\right| + \left|y\right| \cdot \left|y\right|\right) - \left|z\right| \cdot \left|z\right|}{\left|y\right| \cdot 2} \leq -4 \cdot 10^{-140}:\\
                                                                                                            \;\;\;\;0.5 \cdot \frac{\left|z\right| \cdot \left(\left|x\right| - \left|z\right|\right)}{\left|y\right|}\\
                                                                                                            
                                                                                                            \mathbf{else}:\\
                                                                                                            \;\;\;\;0.5 \cdot \mathsf{fma}\left(\frac{\left|x\right|}{\left|y\right|}, \left|z\right|, \left|y\right|\right)\\
                                                                                                            
                                                                                                            
                                                                                                            \end{array}
                                                                                                            
                                                                                                            Derivation
                                                                                                            1. Split input into 2 regimes
                                                                                                            2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -3.9999999999999999e-140

                                                                                                              1. Initial program 69.4%

                                                                                                                \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                                                              2. Step-by-step derivation
                                                                                                                1. Applied rewrites89.0%

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

                                                                                                                  \[\leadsto \frac{1}{2} \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y} \]
                                                                                                                3. Step-by-step derivation
                                                                                                                  1. Applied rewrites61.6%

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

                                                                                                                    \[\leadsto 0.5 \cdot \frac{z \cdot \left(x - z\right)}{y} \]
                                                                                                                  3. Step-by-step derivation
                                                                                                                    1. Applied rewrites36.0%

                                                                                                                      \[\leadsto 0.5 \cdot \frac{z \cdot \left(x - z\right)}{y} \]

                                                                                                                    if -3.9999999999999999e-140 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

                                                                                                                    1. Initial program 69.4%

                                                                                                                      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                                                                    2. Step-by-step derivation
                                                                                                                      1. Applied rewrites89.0%

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

                                                                                                                        \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                                                                      3. Step-by-step derivation
                                                                                                                        1. Applied rewrites65.6%

                                                                                                                          \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                                                                        2. Step-by-step derivation
                                                                                                                          1. Applied rewrites73.2%

                                                                                                                            \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x - z}{y}, z, y\right) \]
                                                                                                                          2. Taylor expanded in x around inf

                                                                                                                            \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x}{y}, z, y\right) \]
                                                                                                                          3. Step-by-step derivation
                                                                                                                            1. Applied rewrites45.0%

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

                                                                                                                          Alternative 10: 46.4% accurate, 1.5× speedup?

                                                                                                                          \[0.5 \cdot \mathsf{fma}\left(\frac{\left|x\right|}{y}, \left|z\right|, y\right) \]
                                                                                                                          (FPCore (x y z)
                                                                                                                            :precision binary64
                                                                                                                            :pre TRUE
                                                                                                                            (* 0.5 (fma (/ (fabs x) y) (fabs z) y)))
                                                                                                                          double code(double x, double y, double z) {
                                                                                                                          	return 0.5 * fma((fabs(x) / y), fabs(z), y);
                                                                                                                          }
                                                                                                                          
                                                                                                                          function code(x, y, z)
                                                                                                                          	return Float64(0.5 * fma(Float64(abs(x) / y), abs(z), y))
                                                                                                                          end
                                                                                                                          
                                                                                                                          code[x_, y_, z_] := N[(0.5 * N[(N[(N[Abs[x], $MachinePrecision] / y), $MachinePrecision] * N[Abs[z], $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
                                                                                                                          
                                                                                                                          f(x, y, z):
                                                                                                                          	x in [-inf, +inf],
                                                                                                                          	y in [-inf, +inf],
                                                                                                                          	z in [-inf, +inf]
                                                                                                                          code: THEORY
                                                                                                                          BEGIN
                                                                                                                          f(x, y, z: real): real =
                                                                                                                          	(5e-1) * ((((abs(x)) / y) * (abs(z))) + y)
                                                                                                                          END code
                                                                                                                          0.5 \cdot \mathsf{fma}\left(\frac{\left|x\right|}{y}, \left|z\right|, y\right)
                                                                                                                          
                                                                                                                          Derivation
                                                                                                                          1. Initial program 69.4%

                                                                                                                            \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
                                                                                                                          2. Step-by-step derivation
                                                                                                                            1. Applied rewrites89.0%

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

                                                                                                                              \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                                                                            3. Step-by-step derivation
                                                                                                                              1. Applied rewrites65.6%

                                                                                                                                \[\leadsto 0.5 \cdot \left(\frac{z \cdot \left(x - z\right)}{y} + y\right) \]
                                                                                                                              2. Step-by-step derivation
                                                                                                                                1. Applied rewrites73.2%

                                                                                                                                  \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x - z}{y}, z, y\right) \]
                                                                                                                                2. Taylor expanded in x around inf

                                                                                                                                  \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x}{y}, z, y\right) \]
                                                                                                                                3. Step-by-step derivation
                                                                                                                                  1. Applied rewrites45.0%

                                                                                                                                    \[\leadsto 0.5 \cdot \mathsf{fma}\left(\frac{x}{y}, z, y\right) \]
                                                                                                                                  2. Add Preprocessing

                                                                                                                                  Alternative 11: 34.3% accurate, 5.5× speedup?

                                                                                                                                  \[0.5 \cdot y \]
                                                                                                                                  (FPCore (x y z)
                                                                                                                                    :precision binary64
                                                                                                                                    :pre TRUE
                                                                                                                                    (* 0.5 y))
                                                                                                                                  double code(double x, double y, double z) {
                                                                                                                                  	return 0.5 * y;
                                                                                                                                  }
                                                                                                                                  
                                                                                                                                  real(8) function code(x, y, z)
                                                                                                                                  use fmin_fmax_functions
                                                                                                                                      real(8), intent (in) :: x
                                                                                                                                      real(8), intent (in) :: y
                                                                                                                                      real(8), intent (in) :: z
                                                                                                                                      code = 0.5d0 * y
                                                                                                                                  end function
                                                                                                                                  
                                                                                                                                  public static double code(double x, double y, double z) {
                                                                                                                                  	return 0.5 * y;
                                                                                                                                  }
                                                                                                                                  
                                                                                                                                  def code(x, y, z):
                                                                                                                                  	return 0.5 * y
                                                                                                                                  
                                                                                                                                  function code(x, y, z)
                                                                                                                                  	return Float64(0.5 * y)
                                                                                                                                  end
                                                                                                                                  
                                                                                                                                  function tmp = code(x, y, z)
                                                                                                                                  	tmp = 0.5 * y;
                                                                                                                                  end
                                                                                                                                  
                                                                                                                                  code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
                                                                                                                                  
                                                                                                                                  f(x, y, z):
                                                                                                                                  	x in [-inf, +inf],
                                                                                                                                  	y in [-inf, +inf],
                                                                                                                                  	z in [-inf, +inf]
                                                                                                                                  code: THEORY
                                                                                                                                  BEGIN
                                                                                                                                  f(x, y, z: real): real =
                                                                                                                                  	(5e-1) * y
                                                                                                                                  END code
                                                                                                                                  0.5 \cdot y
                                                                                                                                  
                                                                                                                                  Derivation
                                                                                                                                  1. Initial program 69.4%

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

                                                                                                                                    \[\leadsto \frac{1}{2} \cdot y \]
                                                                                                                                  3. Step-by-step derivation
                                                                                                                                    1. Applied rewrites34.3%

                                                                                                                                      \[\leadsto 0.5 \cdot y \]
                                                                                                                                    2. Add Preprocessing

                                                                                                                                    Reproduce

                                                                                                                                    ?
                                                                                                                                    herbie shell --seed 2026092 
                                                                                                                                    (FPCore (x y z)
                                                                                                                                      :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
                                                                                                                                      :precision binary64
                                                                                                                                      (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))