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

Percentage Accurate: 68.5% → 99.9%
Time: 3.2s
Alternatives: 9
Speedup: 0.9×

Specification

?
\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
(FPCore (x y z)
  :precision binary64
  (/ (- (+ (* 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
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]
\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 9 alternatives:

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

Initial Program: 68.5% 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
  (/ (- (+ (* 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
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]
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}

Alternative 1: 99.9% accurate, 0.9× speedup?

\[y \cdot 0.5 + \frac{x - z}{y} \cdot \frac{z + x}{2} \]
(FPCore (x y z)
  :precision binary64
  (+ (* y 0.5) (* (/ (- x z) y) (/ (+ z x) 2.0))))
double code(double x, double y, double z) {
	return (y * 0.5) + (((x - z) / y) * ((z + x) / 2.0));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (y * 0.5d0) + (((x - z) / y) * ((z + x) / 2.0d0))
end function
public static double code(double x, double y, double z) {
	return (y * 0.5) + (((x - z) / y) * ((z + x) / 2.0));
}
def code(x, y, z):
	return (y * 0.5) + (((x - z) / y) * ((z + x) / 2.0))
function code(x, y, z)
	return Float64(Float64(y * 0.5) + Float64(Float64(Float64(x - z) / y) * Float64(Float64(z + x) / 2.0)))
end
function tmp = code(x, y, z)
	tmp = (y * 0.5) + (((x - z) / y) * ((z + x) / 2.0));
end
code[x_, y_, z_] := N[(N[(y * 0.5), $MachinePrecision] + N[(N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision] * N[(N[(z + x), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
y \cdot 0.5 + \frac{x - z}{y} \cdot \frac{z + x}{2}
Derivation
  1. Initial program 68.5%

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

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

      \[\leadsto \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y \cdot 2} \]
    3. div-subN/A

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

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

      \[\leadsto \frac{\color{blue}{y \cdot y + x \cdot x}}{y \cdot 2} - \frac{z \cdot z}{y \cdot 2} \]
    6. div-addN/A

      \[\leadsto \color{blue}{\left(\frac{y \cdot y}{y \cdot 2} + \frac{x \cdot x}{y \cdot 2}\right)} - \frac{z \cdot z}{y \cdot 2} \]
    7. associate--l+N/A

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

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

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

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

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

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

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

      \[\leadsto y \cdot \frac{y}{\color{blue}{2 \cdot y}} + \left(\frac{x \cdot x}{y \cdot 2} - \frac{z \cdot z}{y \cdot 2}\right) \]
    15. count-2-revN/A

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

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

      \[\leadsto y \cdot \frac{y}{y + y} + \color{blue}{\left(\frac{x \cdot x}{y \cdot 2} - \frac{z \cdot z}{y \cdot 2}\right)} \]
  3. Applied rewrites90.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto y \cdot \frac{y}{y + y} + \left(\frac{x \cdot x}{y + y} - \frac{\color{blue}{z \cdot z}}{y + y}\right) \]
    10. sub-divN/A

      \[\leadsto y \cdot \frac{y}{y + y} + \color{blue}{\frac{x \cdot x - z \cdot z}{y + y}} \]
    11. sub-negateN/A

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

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

      \[\leadsto y \cdot \frac{y}{y + y} + \frac{\mathsf{neg}\left(\left(z \cdot z - \color{blue}{x \cdot x}\right)\right)}{y + y} \]
    14. difference-of-squares-revN/A

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

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

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

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

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

      \[\leadsto y \cdot \frac{y}{y + y} + \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z - x\right)}\right)\right) \cdot \left(z + x\right)}{y + y} \]
    20. sub-negate-revN/A

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

      \[\leadsto y \cdot \frac{y}{y + y} + \frac{\left(x - z\right) \cdot \left(z + x\right)}{\color{blue}{y + y}} \]
    22. count-2N/A

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

      \[\leadsto y \cdot \frac{y}{y + y} + \frac{\left(x - z\right) \cdot \left(z + x\right)}{\color{blue}{y \cdot 2}} \]
  5. Applied rewrites99.9%

    \[\leadsto y \cdot \frac{y}{y + y} + \color{blue}{\frac{x - z}{y} \cdot \frac{z + x}{2}} \]
  6. Taylor expanded in y around 0

    \[\leadsto y \cdot \color{blue}{\frac{1}{2}} + \frac{x - z}{y} \cdot \frac{z + x}{2} \]
  7. Step-by-step derivation
    1. Applied rewrites99.9%

      \[\leadsto y \cdot \color{blue}{0.5} + \frac{x - z}{y} \cdot \frac{z + x}{2} \]
    2. Add Preprocessing

    Alternative 2: 96.2% accurate, 0.2× 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 0:\\ \;\;\;\;\left(\left|z\right| + \left|x\right|\right) \cdot \left(\frac{\left|z\right| - \left|x\right|}{\left|y\right|} \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left|y\right| \cdot 0.5 + \frac{\left|x\right| - \left|z\right|}{\left|y\right|} \cdot \left(0.5 \cdot \left|x\right|\right)\\ \end{array} \]
    (FPCore (x y z)
      :precision binary64
      (*
     (copysign 1.0 y)
     (if (<=
          (/
           (-
            (+ (* (fabs x) (fabs x)) (* (fabs y) (fabs y)))
            (* (fabs z) (fabs z)))
           (* (fabs y) 2.0))
          0.0)
       (*
        (+ (fabs z) (fabs x))
        (* (/ (- (fabs z) (fabs x)) (fabs y)) -0.5))
       (+
        (* (fabs y) 0.5)
        (* (/ (- (fabs x) (fabs z)) (fabs y)) (* 0.5 (fabs x)))))))
    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)) <= 0.0) {
    		tmp = (fabs(z) + fabs(x)) * (((fabs(z) - fabs(x)) / fabs(y)) * -0.5);
    	} else {
    		tmp = (fabs(y) * 0.5) + (((fabs(x) - fabs(z)) / fabs(y)) * (0.5 * fabs(x)));
    	}
    	return copysign(1.0, y) * tmp;
    }
    
    public static double code(double x, double y, double z) {
    	double tmp;
    	if (((((Math.abs(x) * Math.abs(x)) + (Math.abs(y) * Math.abs(y))) - (Math.abs(z) * Math.abs(z))) / (Math.abs(y) * 2.0)) <= 0.0) {
    		tmp = (Math.abs(z) + Math.abs(x)) * (((Math.abs(z) - Math.abs(x)) / Math.abs(y)) * -0.5);
    	} else {
    		tmp = (Math.abs(y) * 0.5) + (((Math.abs(x) - Math.abs(z)) / Math.abs(y)) * (0.5 * Math.abs(x)));
    	}
    	return Math.copySign(1.0, y) * tmp;
    }
    
    def code(x, y, z):
    	tmp = 0
    	if ((((math.fabs(x) * math.fabs(x)) + (math.fabs(y) * math.fabs(y))) - (math.fabs(z) * math.fabs(z))) / (math.fabs(y) * 2.0)) <= 0.0:
    		tmp = (math.fabs(z) + math.fabs(x)) * (((math.fabs(z) - math.fabs(x)) / math.fabs(y)) * -0.5)
    	else:
    		tmp = (math.fabs(y) * 0.5) + (((math.fabs(x) - math.fabs(z)) / math.fabs(y)) * (0.5 * math.fabs(x)))
    	return math.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)) <= 0.0)
    		tmp = Float64(Float64(abs(z) + abs(x)) * Float64(Float64(Float64(abs(z) - abs(x)) / abs(y)) * -0.5));
    	else
    		tmp = Float64(Float64(abs(y) * 0.5) + Float64(Float64(Float64(abs(x) - abs(z)) / abs(y)) * Float64(0.5 * abs(x))));
    	end
    	return Float64(copysign(1.0, y) * tmp)
    end
    
    function tmp_2 = code(x, y, z)
    	tmp = 0.0;
    	if (((((abs(x) * abs(x)) + (abs(y) * abs(y))) - (abs(z) * abs(z))) / (abs(y) * 2.0)) <= 0.0)
    		tmp = (abs(z) + abs(x)) * (((abs(z) - abs(x)) / abs(y)) * -0.5);
    	else
    		tmp = (abs(y) * 0.5) + (((abs(x) - abs(z)) / abs(y)) * (0.5 * abs(x)));
    	end
    	tmp_2 = (sign(y) * abs(1.0)) * 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], 0.0], N[(N[(N[Abs[z], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Abs[z], $MachinePrecision] - N[Abs[x], $MachinePrecision]), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[y], $MachinePrecision] * 0.5), $MachinePrecision] + N[(N[(N[(N[Abs[x], $MachinePrecision] - N[Abs[z], $MachinePrecision]), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[Abs[x], $MachinePrecision]), $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 0:\\
    \;\;\;\;\left(\left|z\right| + \left|x\right|\right) \cdot \left(\frac{\left|z\right| - \left|x\right|}{\left|y\right|} \cdot -0.5\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left|y\right| \cdot 0.5 + \frac{\left|x\right| - \left|z\right|}{\left|y\right|} \cdot \left(0.5 \cdot \left|x\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))) < 0.0

      1. Initial program 68.5%

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

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

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

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

          \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\left(z \cdot z - x \cdot x\right) - y \cdot y\right)}\right)}{y \cdot 2} \]
        5. sub-negateN/A

          \[\leadsto \frac{\color{blue}{y \cdot y - \left(z \cdot z - x \cdot x\right)}}{y \cdot 2} \]
        6. lower--.f64N/A

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

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

          \[\leadsto \frac{y \cdot y - \left(z \cdot z - \color{blue}{x \cdot x}\right)}{y \cdot 2} \]
        9. difference-of-squaresN/A

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

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

          \[\leadsto \frac{y \cdot y - \color{blue}{\left(z + x\right)} \cdot \left(z - x\right)}{y \cdot 2} \]
        12. lower--.f6473.7%

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

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

          \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{2 \cdot y}} \]
        15. count-2-revN/A

          \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
        16. lower-+.f6473.7%

          \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
      3. Applied rewrites73.7%

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

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

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

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

          \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
        4. lower-+.f64N/A

          \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
        5. lower--.f6461.6%

          \[\leadsto -0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
      6. Applied rewrites61.6%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y}} \]
      7. Step-by-step derivation
        1. lift-*.f64N/A

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

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

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

          \[\leadsto \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \cdot \frac{-1}{2} \]
        5. associate-/l*N/A

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

          \[\leadsto \left(\left(x + z\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
        7. +-commutativeN/A

          \[\leadsto \left(\left(z + x\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
        8. lift-+.f64N/A

          \[\leadsto \left(\left(z + x\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
        9. associate-*l*N/A

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

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

          \[\leadsto \left(z + x\right) \cdot \left(\frac{z - x}{y} \cdot \color{blue}{\frac{-1}{2}}\right) \]
        12. lower-/.f6467.0%

          \[\leadsto \left(z + x\right) \cdot \left(\frac{z - x}{y} \cdot -0.5\right) \]
      8. Applied rewrites67.0%

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

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

      1. Initial program 68.5%

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

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

          \[\leadsto \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y \cdot 2} \]
        3. div-subN/A

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

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

          \[\leadsto \frac{\color{blue}{y \cdot y + x \cdot x}}{y \cdot 2} - \frac{z \cdot z}{y \cdot 2} \]
        6. div-addN/A

          \[\leadsto \color{blue}{\left(\frac{y \cdot y}{y \cdot 2} + \frac{x \cdot x}{y \cdot 2}\right)} - \frac{z \cdot z}{y \cdot 2} \]
        7. associate--l+N/A

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

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

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

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

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

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

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

          \[\leadsto y \cdot \frac{y}{\color{blue}{2 \cdot y}} + \left(\frac{x \cdot x}{y \cdot 2} - \frac{z \cdot z}{y \cdot 2}\right) \]
        15. count-2-revN/A

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

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

          \[\leadsto y \cdot \frac{y}{y + y} + \color{blue}{\left(\frac{x \cdot x}{y \cdot 2} - \frac{z \cdot z}{y \cdot 2}\right)} \]
      3. Applied rewrites90.9%

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

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

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

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

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

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

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

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

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

          \[\leadsto y \cdot \frac{y}{y + y} + \left(\frac{x \cdot x}{y + y} - \frac{\color{blue}{z \cdot z}}{y + y}\right) \]
        10. sub-divN/A

          \[\leadsto y \cdot \frac{y}{y + y} + \color{blue}{\frac{x \cdot x - z \cdot z}{y + y}} \]
        11. sub-negateN/A

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

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

          \[\leadsto y \cdot \frac{y}{y + y} + \frac{\mathsf{neg}\left(\left(z \cdot z - \color{blue}{x \cdot x}\right)\right)}{y + y} \]
        14. difference-of-squares-revN/A

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

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

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

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

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

          \[\leadsto y \cdot \frac{y}{y + y} + \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z - x\right)}\right)\right) \cdot \left(z + x\right)}{y + y} \]
        20. sub-negate-revN/A

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

          \[\leadsto y \cdot \frac{y}{y + y} + \frac{\left(x - z\right) \cdot \left(z + x\right)}{\color{blue}{y + y}} \]
        22. count-2N/A

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

          \[\leadsto y \cdot \frac{y}{y + y} + \frac{\left(x - z\right) \cdot \left(z + x\right)}{\color{blue}{y \cdot 2}} \]
      5. Applied rewrites99.9%

        \[\leadsto y \cdot \frac{y}{y + y} + \color{blue}{\frac{x - z}{y} \cdot \frac{z + x}{2}} \]
      6. Taylor expanded in y around 0

        \[\leadsto y \cdot \color{blue}{\frac{1}{2}} + \frac{x - z}{y} \cdot \frac{z + x}{2} \]
      7. Step-by-step derivation
        1. Applied rewrites99.9%

          \[\leadsto y \cdot \color{blue}{0.5} + \frac{x - z}{y} \cdot \frac{z + x}{2} \]
        2. Taylor expanded in x around inf

          \[\leadsto y \cdot 0.5 + \frac{x - z}{y} \cdot \color{blue}{\left(\frac{1}{2} \cdot x\right)} \]
        3. Step-by-step derivation
          1. lower-*.f6473.9%

            \[\leadsto y \cdot 0.5 + \frac{x - z}{y} \cdot \left(0.5 \cdot \color{blue}{x}\right) \]
        4. Applied rewrites73.9%

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

      Alternative 3: 93.2% accurate, 0.7× speedup?

      \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 2.1 \cdot 10^{-137}:\\ \;\;\;\;y \cdot 0.5 - \frac{z}{y + y} \cdot z\\ \mathbf{elif}\;\left|x\right| \leq 1.05 \cdot 10^{+151}:\\ \;\;\;\;\left(y + \frac{\left(\left|x\right| + z\right) \cdot \left(\left|x\right| - z\right)}{y}\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(z + \left|x\right|\right) \cdot \left(\frac{z - \left|x\right|}{y} \cdot -0.5\right)\\ \end{array} \]
      (FPCore (x y z)
        :precision binary64
        (if (<= (fabs x) 2.1e-137)
        (- (* y 0.5) (* (/ z (+ y y)) z))
        (if (<= (fabs x) 1.05e+151)
          (* (+ y (/ (* (+ (fabs x) z) (- (fabs x) z)) y)) 0.5)
          (* (+ z (fabs x)) (* (/ (- z (fabs x)) y) -0.5)))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (fabs(x) <= 2.1e-137) {
      		tmp = (y * 0.5) - ((z / (y + y)) * z);
      	} else if (fabs(x) <= 1.05e+151) {
      		tmp = (y + (((fabs(x) + z) * (fabs(x) - z)) / y)) * 0.5;
      	} else {
      		tmp = (z + fabs(x)) * (((z - fabs(x)) / y) * -0.5);
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x, y, z)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8) :: tmp
          if (abs(x) <= 2.1d-137) then
              tmp = (y * 0.5d0) - ((z / (y + y)) * z)
          else if (abs(x) <= 1.05d+151) then
              tmp = (y + (((abs(x) + z) * (abs(x) - z)) / y)) * 0.5d0
          else
              tmp = (z + abs(x)) * (((z - abs(x)) / y) * (-0.5d0))
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double tmp;
      	if (Math.abs(x) <= 2.1e-137) {
      		tmp = (y * 0.5) - ((z / (y + y)) * z);
      	} else if (Math.abs(x) <= 1.05e+151) {
      		tmp = (y + (((Math.abs(x) + z) * (Math.abs(x) - z)) / y)) * 0.5;
      	} else {
      		tmp = (z + Math.abs(x)) * (((z - Math.abs(x)) / y) * -0.5);
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	tmp = 0
      	if math.fabs(x) <= 2.1e-137:
      		tmp = (y * 0.5) - ((z / (y + y)) * z)
      	elif math.fabs(x) <= 1.05e+151:
      		tmp = (y + (((math.fabs(x) + z) * (math.fabs(x) - z)) / y)) * 0.5
      	else:
      		tmp = (z + math.fabs(x)) * (((z - math.fabs(x)) / y) * -0.5)
      	return tmp
      
      function code(x, y, z)
      	tmp = 0.0
      	if (abs(x) <= 2.1e-137)
      		tmp = Float64(Float64(y * 0.5) - Float64(Float64(z / Float64(y + y)) * z));
      	elseif (abs(x) <= 1.05e+151)
      		tmp = Float64(Float64(y + Float64(Float64(Float64(abs(x) + z) * Float64(abs(x) - z)) / y)) * 0.5);
      	else
      		tmp = Float64(Float64(z + abs(x)) * Float64(Float64(Float64(z - abs(x)) / y) * -0.5));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	tmp = 0.0;
      	if (abs(x) <= 2.1e-137)
      		tmp = (y * 0.5) - ((z / (y + y)) * z);
      	elseif (abs(x) <= 1.05e+151)
      		tmp = (y + (((abs(x) + z) * (abs(x) - z)) / y)) * 0.5;
      	else
      		tmp = (z + abs(x)) * (((z - abs(x)) / y) * -0.5);
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := If[LessEqual[N[Abs[x], $MachinePrecision], 2.1e-137], N[(N[(y * 0.5), $MachinePrecision] - N[(N[(z / N[(y + y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[x], $MachinePrecision], 1.05e+151], N[(N[(y + N[(N[(N[(N[Abs[x], $MachinePrecision] + z), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(z + N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(z - N[Abs[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 2.1 \cdot 10^{-137}:\\
      \;\;\;\;y \cdot 0.5 - \frac{z}{y + y} \cdot z\\
      
      \mathbf{elif}\;\left|x\right| \leq 1.05 \cdot 10^{+151}:\\
      \;\;\;\;\left(y + \frac{\left(\left|x\right| + z\right) \cdot \left(\left|x\right| - z\right)}{y}\right) \cdot 0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(z + \left|x\right|\right) \cdot \left(\frac{z - \left|x\right|}{y} \cdot -0.5\right)\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if x < 2.0999999999999999e-137

        1. Initial program 68.5%

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

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

            \[\leadsto \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y \cdot 2} \]
          3. div-subN/A

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

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

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

            \[\leadsto \color{blue}{\frac{\frac{x \cdot x + y \cdot y}{y}}{2}} - \frac{z \cdot z}{y \cdot 2} \]
          7. mult-flipN/A

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

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

            \[\leadsto \frac{\color{blue}{x \cdot x + y \cdot y}}{y} \cdot \frac{1}{2} - \frac{z \cdot z}{y \cdot 2} \]
          10. +-commutativeN/A

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

            \[\leadsto \frac{\color{blue}{y \cdot y} + x \cdot x}{y} \cdot \frac{1}{2} - \frac{z \cdot z}{y \cdot 2} \]
          12. add-to-fraction-revN/A

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

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

            \[\leadsto \left(y + \color{blue}{\frac{x \cdot x}{y}}\right) \cdot \frac{1}{2} - \frac{z \cdot z}{y \cdot 2} \]
          15. metadata-evalN/A

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

            \[\leadsto \left(y + \frac{x \cdot x}{y}\right) \cdot \frac{1}{2} - \frac{\color{blue}{z \cdot z}}{y \cdot 2} \]
          17. associate-/l*N/A

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

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

            \[\leadsto \left(y + \frac{x \cdot x}{y}\right) \cdot \frac{1}{2} - \color{blue}{\frac{z}{y \cdot 2} \cdot z} \]
        3. Applied rewrites84.2%

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

          \[\leadsto \color{blue}{y} \cdot 0.5 - \frac{z}{y + y} \cdot z \]
        5. Step-by-step derivation
          1. Applied rewrites66.2%

            \[\leadsto \color{blue}{y} \cdot 0.5 - \frac{z}{y + y} \cdot z \]

          if 2.0999999999999999e-137 < x < 1.05e151

          1. Initial program 68.5%

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \cdot \frac{1}{2}} \]
          3. Applied rewrites88.6%

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

          if 1.05e151 < x

          1. Initial program 68.5%

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

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

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

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

              \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\left(z \cdot z - x \cdot x\right) - y \cdot y\right)}\right)}{y \cdot 2} \]
            5. sub-negateN/A

              \[\leadsto \frac{\color{blue}{y \cdot y - \left(z \cdot z - x \cdot x\right)}}{y \cdot 2} \]
            6. lower--.f64N/A

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

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

              \[\leadsto \frac{y \cdot y - \left(z \cdot z - \color{blue}{x \cdot x}\right)}{y \cdot 2} \]
            9. difference-of-squaresN/A

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

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

              \[\leadsto \frac{y \cdot y - \color{blue}{\left(z + x\right)} \cdot \left(z - x\right)}{y \cdot 2} \]
            12. lower--.f6473.7%

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

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

              \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{2 \cdot y}} \]
            15. count-2-revN/A

              \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
            16. lower-+.f6473.7%

              \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
          3. Applied rewrites73.7%

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

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

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

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

              \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
            4. lower-+.f64N/A

              \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
            5. lower--.f6461.6%

              \[\leadsto -0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
          6. Applied rewrites61.6%

            \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y}} \]
          7. Step-by-step derivation
            1. lift-*.f64N/A

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

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

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

              \[\leadsto \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \cdot \frac{-1}{2} \]
            5. associate-/l*N/A

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

              \[\leadsto \left(\left(x + z\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
            7. +-commutativeN/A

              \[\leadsto \left(\left(z + x\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
            8. lift-+.f64N/A

              \[\leadsto \left(\left(z + x\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
            9. associate-*l*N/A

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

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

              \[\leadsto \left(z + x\right) \cdot \left(\frac{z - x}{y} \cdot \color{blue}{\frac{-1}{2}}\right) \]
            12. lower-/.f6467.0%

              \[\leadsto \left(z + x\right) \cdot \left(\frac{z - x}{y} \cdot -0.5\right) \]
          8. Applied rewrites67.0%

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

        Alternative 4: 85.9% accurate, 0.9× speedup?

        \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 3.65 \cdot 10^{+61}:\\ \;\;\;\;y \cdot 0.5 - \frac{z}{y + y} \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(z + \left|x\right|\right) \cdot \left(\frac{z - \left|x\right|}{y} \cdot -0.5\right)\\ \end{array} \]
        (FPCore (x y z)
          :precision binary64
          (if (<= (fabs x) 3.65e+61)
          (- (* y 0.5) (* (/ z (+ y y)) z))
          (* (+ z (fabs x)) (* (/ (- z (fabs x)) y) -0.5))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (fabs(x) <= 3.65e+61) {
        		tmp = (y * 0.5) - ((z / (y + y)) * z);
        	} else {
        		tmp = (z + fabs(x)) * (((z - fabs(x)) / y) * -0.5);
        	}
        	return tmp;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(x, y, z)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8), intent (in) :: z
            real(8) :: tmp
            if (abs(x) <= 3.65d+61) then
                tmp = (y * 0.5d0) - ((z / (y + y)) * z)
            else
                tmp = (z + abs(x)) * (((z - abs(x)) / y) * (-0.5d0))
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (Math.abs(x) <= 3.65e+61) {
        		tmp = (y * 0.5) - ((z / (y + y)) * z);
        	} else {
        		tmp = (z + Math.abs(x)) * (((z - Math.abs(x)) / y) * -0.5);
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if math.fabs(x) <= 3.65e+61:
        		tmp = (y * 0.5) - ((z / (y + y)) * z)
        	else:
        		tmp = (z + math.fabs(x)) * (((z - math.fabs(x)) / y) * -0.5)
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (abs(x) <= 3.65e+61)
        		tmp = Float64(Float64(y * 0.5) - Float64(Float64(z / Float64(y + y)) * z));
        	else
        		tmp = Float64(Float64(z + abs(x)) * Float64(Float64(Float64(z - abs(x)) / y) * -0.5));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (abs(x) <= 3.65e+61)
        		tmp = (y * 0.5) - ((z / (y + y)) * z);
        	else
        		tmp = (z + abs(x)) * (((z - abs(x)) / y) * -0.5);
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[N[Abs[x], $MachinePrecision], 3.65e+61], N[(N[(y * 0.5), $MachinePrecision] - N[(N[(z / N[(y + y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(z + N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(z - N[Abs[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;\left|x\right| \leq 3.65 \cdot 10^{+61}:\\
        \;\;\;\;y \cdot 0.5 - \frac{z}{y + y} \cdot z\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(z + \left|x\right|\right) \cdot \left(\frac{z - \left|x\right|}{y} \cdot -0.5\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 3.6500000000000001e61

          1. Initial program 68.5%

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

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

              \[\leadsto \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y \cdot 2} \]
            3. div-subN/A

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

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

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

              \[\leadsto \color{blue}{\frac{\frac{x \cdot x + y \cdot y}{y}}{2}} - \frac{z \cdot z}{y \cdot 2} \]
            7. mult-flipN/A

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

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

              \[\leadsto \frac{\color{blue}{x \cdot x + y \cdot y}}{y} \cdot \frac{1}{2} - \frac{z \cdot z}{y \cdot 2} \]
            10. +-commutativeN/A

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

              \[\leadsto \frac{\color{blue}{y \cdot y} + x \cdot x}{y} \cdot \frac{1}{2} - \frac{z \cdot z}{y \cdot 2} \]
            12. add-to-fraction-revN/A

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

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

              \[\leadsto \left(y + \color{blue}{\frac{x \cdot x}{y}}\right) \cdot \frac{1}{2} - \frac{z \cdot z}{y \cdot 2} \]
            15. metadata-evalN/A

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

              \[\leadsto \left(y + \frac{x \cdot x}{y}\right) \cdot \frac{1}{2} - \frac{\color{blue}{z \cdot z}}{y \cdot 2} \]
            17. associate-/l*N/A

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

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

              \[\leadsto \left(y + \frac{x \cdot x}{y}\right) \cdot \frac{1}{2} - \color{blue}{\frac{z}{y \cdot 2} \cdot z} \]
          3. Applied rewrites84.2%

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

            \[\leadsto \color{blue}{y} \cdot 0.5 - \frac{z}{y + y} \cdot z \]
          5. Step-by-step derivation
            1. Applied rewrites66.2%

              \[\leadsto \color{blue}{y} \cdot 0.5 - \frac{z}{y + y} \cdot z \]

            if 3.6500000000000001e61 < x

            1. Initial program 68.5%

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

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

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

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

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\left(z \cdot z - x \cdot x\right) - y \cdot y\right)}\right)}{y \cdot 2} \]
              5. sub-negateN/A

                \[\leadsto \frac{\color{blue}{y \cdot y - \left(z \cdot z - x \cdot x\right)}}{y \cdot 2} \]
              6. lower--.f64N/A

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

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

                \[\leadsto \frac{y \cdot y - \left(z \cdot z - \color{blue}{x \cdot x}\right)}{y \cdot 2} \]
              9. difference-of-squaresN/A

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

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

                \[\leadsto \frac{y \cdot y - \color{blue}{\left(z + x\right)} \cdot \left(z - x\right)}{y \cdot 2} \]
              12. lower--.f6473.7%

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

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

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{2 \cdot y}} \]
              15. count-2-revN/A

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
              16. lower-+.f6473.7%

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
            3. Applied rewrites73.7%

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

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

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

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

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              4. lower-+.f64N/A

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              5. lower--.f6461.6%

                \[\leadsto -0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
            6. Applied rewrites61.6%

              \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y}} \]
            7. Step-by-step derivation
              1. lift-*.f64N/A

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

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

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

                \[\leadsto \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \cdot \frac{-1}{2} \]
              5. associate-/l*N/A

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

                \[\leadsto \left(\left(x + z\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
              7. +-commutativeN/A

                \[\leadsto \left(\left(z + x\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
              8. lift-+.f64N/A

                \[\leadsto \left(\left(z + x\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
              9. associate-*l*N/A

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

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

                \[\leadsto \left(z + x\right) \cdot \left(\frac{z - x}{y} \cdot \color{blue}{\frac{-1}{2}}\right) \]
              12. lower-/.f6467.0%

                \[\leadsto \left(z + x\right) \cdot \left(\frac{z - x}{y} \cdot -0.5\right) \]
            8. Applied rewrites67.0%

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

          Alternative 5: 80.8% accurate, 0.3× speedup?

          \[\mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;\left|y\right| \leq 1.1 \cdot 10^{+116}:\\ \;\;\;\;\left(z + x\right) \cdot \left(\frac{z - x}{\left|y\right|} \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left|y\right|\\ \end{array} \]
          (FPCore (x y z)
            :precision binary64
            (*
           (copysign 1.0 y)
           (if (<= (fabs y) 1.1e+116)
             (* (+ z x) (* (/ (- z x) (fabs y)) -0.5))
             (* 0.5 (fabs y)))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (fabs(y) <= 1.1e+116) {
          		tmp = (z + x) * (((z - x) / fabs(y)) * -0.5);
          	} else {
          		tmp = 0.5 * fabs(y);
          	}
          	return copysign(1.0, y) * tmp;
          }
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if (Math.abs(y) <= 1.1e+116) {
          		tmp = (z + x) * (((z - x) / Math.abs(y)) * -0.5);
          	} else {
          		tmp = 0.5 * Math.abs(y);
          	}
          	return Math.copySign(1.0, y) * tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if math.fabs(y) <= 1.1e+116:
          		tmp = (z + x) * (((z - x) / math.fabs(y)) * -0.5)
          	else:
          		tmp = 0.5 * math.fabs(y)
          	return math.copysign(1.0, y) * tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if (abs(y) <= 1.1e+116)
          		tmp = Float64(Float64(z + x) * Float64(Float64(Float64(z - x) / abs(y)) * -0.5));
          	else
          		tmp = Float64(0.5 * abs(y));
          	end
          	return Float64(copysign(1.0, y) * tmp)
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if (abs(y) <= 1.1e+116)
          		tmp = (z + x) * (((z - x) / abs(y)) * -0.5);
          	else
          		tmp = 0.5 * abs(y);
          	end
          	tmp_2 = (sign(y) * abs(1.0)) * 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[Abs[y], $MachinePrecision], 1.1e+116], N[(N[(z + x), $MachinePrecision] * N[(N[(N[(z - x), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Abs[y], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
          
          \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
          \mathbf{if}\;\left|y\right| \leq 1.1 \cdot 10^{+116}:\\
          \;\;\;\;\left(z + x\right) \cdot \left(\frac{z - x}{\left|y\right|} \cdot -0.5\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;0.5 \cdot \left|y\right|\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < 1.0999999999999999e116

            1. Initial program 68.5%

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

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

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

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

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\left(z \cdot z - x \cdot x\right) - y \cdot y\right)}\right)}{y \cdot 2} \]
              5. sub-negateN/A

                \[\leadsto \frac{\color{blue}{y \cdot y - \left(z \cdot z - x \cdot x\right)}}{y \cdot 2} \]
              6. lower--.f64N/A

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

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

                \[\leadsto \frac{y \cdot y - \left(z \cdot z - \color{blue}{x \cdot x}\right)}{y \cdot 2} \]
              9. difference-of-squaresN/A

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

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

                \[\leadsto \frac{y \cdot y - \color{blue}{\left(z + x\right)} \cdot \left(z - x\right)}{y \cdot 2} \]
              12. lower--.f6473.7%

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

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

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{2 \cdot y}} \]
              15. count-2-revN/A

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
              16. lower-+.f6473.7%

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
            3. Applied rewrites73.7%

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

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

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

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

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              4. lower-+.f64N/A

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              5. lower--.f6461.6%

                \[\leadsto -0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
            6. Applied rewrites61.6%

              \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y}} \]
            7. Step-by-step derivation
              1. lift-*.f64N/A

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

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

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

                \[\leadsto \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \cdot \frac{-1}{2} \]
              5. associate-/l*N/A

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

                \[\leadsto \left(\left(x + z\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
              7. +-commutativeN/A

                \[\leadsto \left(\left(z + x\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
              8. lift-+.f64N/A

                \[\leadsto \left(\left(z + x\right) \cdot \frac{z - x}{y}\right) \cdot \frac{-1}{2} \]
              9. associate-*l*N/A

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

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

                \[\leadsto \left(z + x\right) \cdot \left(\frac{z - x}{y} \cdot \color{blue}{\frac{-1}{2}}\right) \]
              12. lower-/.f6467.0%

                \[\leadsto \left(z + x\right) \cdot \left(\frac{z - x}{y} \cdot -0.5\right) \]
            8. Applied rewrites67.0%

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

            if 1.0999999999999999e116 < y

            1. Initial program 68.5%

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
            3. Step-by-step derivation
              1. lower-*.f6434.4%

                \[\leadsto 0.5 \cdot \color{blue}{y} \]
            4. Applied rewrites34.4%

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

          Alternative 6: 78.9% accurate, 0.3× speedup?

          \[\mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;\left|y\right| \leq 1.02 \cdot 10^{+104}:\\ \;\;\;\;-0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{\left|y\right|}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left|y\right|\\ \end{array} \]
          (FPCore (x y z)
            :precision binary64
            (*
           (copysign 1.0 y)
           (if (<= (fabs y) 1.02e+104)
             (* -0.5 (/ (* (+ x z) (- z x)) (fabs y)))
             (* 0.5 (fabs y)))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (fabs(y) <= 1.02e+104) {
          		tmp = -0.5 * (((x + z) * (z - x)) / fabs(y));
          	} else {
          		tmp = 0.5 * fabs(y);
          	}
          	return copysign(1.0, y) * tmp;
          }
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if (Math.abs(y) <= 1.02e+104) {
          		tmp = -0.5 * (((x + z) * (z - x)) / Math.abs(y));
          	} else {
          		tmp = 0.5 * Math.abs(y);
          	}
          	return Math.copySign(1.0, y) * tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if math.fabs(y) <= 1.02e+104:
          		tmp = -0.5 * (((x + z) * (z - x)) / math.fabs(y))
          	else:
          		tmp = 0.5 * math.fabs(y)
          	return math.copysign(1.0, y) * tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if (abs(y) <= 1.02e+104)
          		tmp = Float64(-0.5 * Float64(Float64(Float64(x + z) * Float64(z - x)) / abs(y)));
          	else
          		tmp = Float64(0.5 * abs(y));
          	end
          	return Float64(copysign(1.0, y) * tmp)
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if (abs(y) <= 1.02e+104)
          		tmp = -0.5 * (((x + z) * (z - x)) / abs(y));
          	else
          		tmp = 0.5 * abs(y);
          	end
          	tmp_2 = (sign(y) * abs(1.0)) * 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[Abs[y], $MachinePrecision], 1.02e+104], N[(-0.5 * N[(N[(N[(x + z), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Abs[y], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
          
          \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
          \mathbf{if}\;\left|y\right| \leq 1.02 \cdot 10^{+104}:\\
          \;\;\;\;-0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{\left|y\right|}\\
          
          \mathbf{else}:\\
          \;\;\;\;0.5 \cdot \left|y\right|\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < 1.02e104

            1. Initial program 68.5%

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

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

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

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

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\left(z \cdot z - x \cdot x\right) - y \cdot y\right)}\right)}{y \cdot 2} \]
              5. sub-negateN/A

                \[\leadsto \frac{\color{blue}{y \cdot y - \left(z \cdot z - x \cdot x\right)}}{y \cdot 2} \]
              6. lower--.f64N/A

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

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

                \[\leadsto \frac{y \cdot y - \left(z \cdot z - \color{blue}{x \cdot x}\right)}{y \cdot 2} \]
              9. difference-of-squaresN/A

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

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

                \[\leadsto \frac{y \cdot y - \color{blue}{\left(z + x\right)} \cdot \left(z - x\right)}{y \cdot 2} \]
              12. lower--.f6473.7%

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

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

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{2 \cdot y}} \]
              15. count-2-revN/A

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
              16. lower-+.f6473.7%

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
            3. Applied rewrites73.7%

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

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

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

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

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              4. lower-+.f64N/A

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              5. lower--.f6461.6%

                \[\leadsto -0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
            6. Applied rewrites61.6%

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

            if 1.02e104 < y

            1. Initial program 68.5%

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
            3. Step-by-step derivation
              1. lower-*.f6434.4%

                \[\leadsto 0.5 \cdot \color{blue}{y} \]
            4. Applied rewrites34.4%

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

          Alternative 7: 67.3% accurate, 0.2× speedup?

          \[\mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;\left|y\right| \leq 1.15 \cdot 10^{-77}:\\ \;\;\;\;-0.5 \cdot \left(\left(\left|z\right| - \left|x\right|\right) \cdot \frac{\left|z\right|}{\left|y\right|}\right)\\ \mathbf{elif}\;\left|y\right| \leq 1.35 \cdot 10^{+152}:\\ \;\;\;\;\frac{\left(\left|y\right| + \left|z\right|\right) \cdot \left(\left|y\right| - \left|z\right|\right)}{\left|y\right| + \left|y\right|}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left|y\right|\\ \end{array} \]
          (FPCore (x y z)
            :precision binary64
            (*
           (copysign 1.0 y)
           (if (<= (fabs y) 1.15e-77)
             (* -0.5 (* (- (fabs z) (fabs x)) (/ (fabs z) (fabs y))))
             (if (<= (fabs y) 1.35e+152)
               (/
                (* (+ (fabs y) (fabs z)) (- (fabs y) (fabs z)))
                (+ (fabs y) (fabs y)))
               (* 0.5 (fabs y))))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (fabs(y) <= 1.15e-77) {
          		tmp = -0.5 * ((fabs(z) - fabs(x)) * (fabs(z) / fabs(y)));
          	} else if (fabs(y) <= 1.35e+152) {
          		tmp = ((fabs(y) + fabs(z)) * (fabs(y) - fabs(z))) / (fabs(y) + fabs(y));
          	} else {
          		tmp = 0.5 * fabs(y);
          	}
          	return copysign(1.0, y) * tmp;
          }
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if (Math.abs(y) <= 1.15e-77) {
          		tmp = -0.5 * ((Math.abs(z) - Math.abs(x)) * (Math.abs(z) / Math.abs(y)));
          	} else if (Math.abs(y) <= 1.35e+152) {
          		tmp = ((Math.abs(y) + Math.abs(z)) * (Math.abs(y) - Math.abs(z))) / (Math.abs(y) + Math.abs(y));
          	} else {
          		tmp = 0.5 * Math.abs(y);
          	}
          	return Math.copySign(1.0, y) * tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if math.fabs(y) <= 1.15e-77:
          		tmp = -0.5 * ((math.fabs(z) - math.fabs(x)) * (math.fabs(z) / math.fabs(y)))
          	elif math.fabs(y) <= 1.35e+152:
          		tmp = ((math.fabs(y) + math.fabs(z)) * (math.fabs(y) - math.fabs(z))) / (math.fabs(y) + math.fabs(y))
          	else:
          		tmp = 0.5 * math.fabs(y)
          	return math.copysign(1.0, y) * tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if (abs(y) <= 1.15e-77)
          		tmp = Float64(-0.5 * Float64(Float64(abs(z) - abs(x)) * Float64(abs(z) / abs(y))));
          	elseif (abs(y) <= 1.35e+152)
          		tmp = Float64(Float64(Float64(abs(y) + abs(z)) * Float64(abs(y) - abs(z))) / Float64(abs(y) + abs(y)));
          	else
          		tmp = Float64(0.5 * abs(y));
          	end
          	return Float64(copysign(1.0, y) * tmp)
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if (abs(y) <= 1.15e-77)
          		tmp = -0.5 * ((abs(z) - abs(x)) * (abs(z) / abs(y)));
          	elseif (abs(y) <= 1.35e+152)
          		tmp = ((abs(y) + abs(z)) * (abs(y) - abs(z))) / (abs(y) + abs(y));
          	else
          		tmp = 0.5 * abs(y);
          	end
          	tmp_2 = (sign(y) * abs(1.0)) * 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[Abs[y], $MachinePrecision], 1.15e-77], N[(-0.5 * N[(N[(N[Abs[z], $MachinePrecision] - N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[z], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[y], $MachinePrecision], 1.35e+152], N[(N[(N[(N[Abs[y], $MachinePrecision] + N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[y], $MachinePrecision] - N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[y], $MachinePrecision] + N[Abs[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Abs[y], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
          
          \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
          \mathbf{if}\;\left|y\right| \leq 1.15 \cdot 10^{-77}:\\
          \;\;\;\;-0.5 \cdot \left(\left(\left|z\right| - \left|x\right|\right) \cdot \frac{\left|z\right|}{\left|y\right|}\right)\\
          
          \mathbf{elif}\;\left|y\right| \leq 1.35 \cdot 10^{+152}:\\
          \;\;\;\;\frac{\left(\left|y\right| + \left|z\right|\right) \cdot \left(\left|y\right| - \left|z\right|\right)}{\left|y\right| + \left|y\right|}\\
          
          \mathbf{else}:\\
          \;\;\;\;0.5 \cdot \left|y\right|\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if y < 1.15e-77

            1. Initial program 68.5%

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

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

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

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

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\left(z \cdot z - x \cdot x\right) - y \cdot y\right)}\right)}{y \cdot 2} \]
              5. sub-negateN/A

                \[\leadsto \frac{\color{blue}{y \cdot y - \left(z \cdot z - x \cdot x\right)}}{y \cdot 2} \]
              6. lower--.f64N/A

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

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

                \[\leadsto \frac{y \cdot y - \left(z \cdot z - \color{blue}{x \cdot x}\right)}{y \cdot 2} \]
              9. difference-of-squaresN/A

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

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

                \[\leadsto \frac{y \cdot y - \color{blue}{\left(z + x\right)} \cdot \left(z - x\right)}{y \cdot 2} \]
              12. lower--.f6473.7%

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

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

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{2 \cdot y}} \]
              15. count-2-revN/A

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
              16. lower-+.f6473.7%

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
            3. Applied rewrites73.7%

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

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

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

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

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              4. lower-+.f64N/A

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              5. lower--.f6461.6%

                \[\leadsto -0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
            6. Applied rewrites61.6%

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

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

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

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

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

                \[\leadsto \frac{-1}{2} \cdot \left(\left(\left(z - x\right) \cdot \left(x + z\right)\right) \cdot \frac{1}{y}\right) \]
              6. +-commutativeN/A

                \[\leadsto \frac{-1}{2} \cdot \left(\left(\left(z - x\right) \cdot \left(z + x\right)\right) \cdot \frac{1}{y}\right) \]
              7. lift-+.f64N/A

                \[\leadsto \frac{-1}{2} \cdot \left(\left(\left(z - x\right) \cdot \left(z + x\right)\right) \cdot \frac{1}{y}\right) \]
              8. associate-*l*N/A

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

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

                \[\leadsto \frac{-1}{2} \cdot \left(\left(z - x\right) \cdot \left(\left(z + x\right) \cdot \color{blue}{\frac{1}{y}}\right)\right) \]
              11. lower-/.f6466.9%

                \[\leadsto -0.5 \cdot \left(\left(z - x\right) \cdot \left(\left(z + x\right) \cdot \frac{1}{\color{blue}{y}}\right)\right) \]
            8. Applied rewrites66.9%

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

              \[\leadsto -0.5 \cdot \left(\left(z - x\right) \cdot \frac{z}{\color{blue}{y}}\right) \]
            10. Step-by-step derivation
              1. lower-/.f6437.3%

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

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

            if 1.15e-77 < y < 1.3500000000000001e152

            1. Initial program 68.5%

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

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

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

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

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\left(z \cdot z - x \cdot x\right) - y \cdot y\right)}\right)}{y \cdot 2} \]
              5. sub-negateN/A

                \[\leadsto \frac{\color{blue}{y \cdot y - \left(z \cdot z - x \cdot x\right)}}{y \cdot 2} \]
              6. lower--.f64N/A

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

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

                \[\leadsto \frac{y \cdot y - \left(z \cdot z - \color{blue}{x \cdot x}\right)}{y \cdot 2} \]
              9. difference-of-squaresN/A

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

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

                \[\leadsto \frac{y \cdot y - \color{blue}{\left(z + x\right)} \cdot \left(z - x\right)}{y \cdot 2} \]
              12. lower--.f6473.7%

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

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

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{2 \cdot y}} \]
              15. count-2-revN/A

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
              16. lower-+.f6473.7%

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
            3. Applied rewrites73.7%

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

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

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

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

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \color{blue}{\left(z - x\right)}}{y + y} \]
              5. difference-of-squares-revN/A

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

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

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

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

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

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

                \[\leadsto \frac{\left(y \cdot y - \color{blue}{z \cdot z}\right) + x \cdot x}{y + y} \]
              12. difference-of-squaresN/A

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

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

                \[\leadsto \frac{\color{blue}{\left(y + z\right)} \cdot \left(y - z\right) + x \cdot x}{y + y} \]
              15. lower--.f6470.0%

                \[\leadsto \frac{\left(y + z\right) \cdot \color{blue}{\left(y - z\right)} + x \cdot x}{y + y} \]
            5. Applied rewrites70.0%

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

              \[\leadsto \frac{\color{blue}{\left(y + z\right) \cdot \left(y - z\right)}}{y + y} \]
            7. Step-by-step derivation
              1. lower-*.f64N/A

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

                \[\leadsto \frac{\left(y + z\right) \cdot \left(\color{blue}{y} - z\right)}{y + y} \]
              3. lower--.f6446.2%

                \[\leadsto \frac{\left(y + z\right) \cdot \left(y - \color{blue}{z}\right)}{y + y} \]
            8. Applied rewrites46.2%

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

            if 1.3500000000000001e152 < y

            1. Initial program 68.5%

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
            3. Step-by-step derivation
              1. lower-*.f6434.4%

                \[\leadsto 0.5 \cdot \color{blue}{y} \]
            4. Applied rewrites34.4%

              \[\leadsto \color{blue}{0.5 \cdot y} \]
          3. Recombined 3 regimes into one program.
          4. Add Preprocessing

          Alternative 8: 64.9% accurate, 0.2× speedup?

          \[\begin{array}{l} t_0 := -0.5 \cdot \left(\left(\left|z\right| - \left|x\right|\right) \cdot \frac{\left|z\right|}{\left|y\right|}\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}\\ \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;0.5 \cdot \left|y\right|\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (x y z)
            :precision binary64
            (let* ((t_0 (* -0.5 (* (- (fabs z) (fabs x)) (/ (fabs z) (fabs y)))))
                 (t_1
                  (/
                   (-
                    (+ (* (fabs x) (fabs x)) (* (fabs y) (fabs y)))
                    (* (fabs z) (fabs z)))
                   (* (fabs y) 2.0))))
            (*
             (copysign 1.0 y)
             (if (<= t_1 0.0) t_0 (if (<= t_1 INFINITY) (* 0.5 (fabs y)) t_0)))))
          double code(double x, double y, double z) {
          	double t_0 = -0.5 * ((fabs(z) - fabs(x)) * (fabs(z) / fabs(y)));
          	double t_1 = (((fabs(x) * fabs(x)) + (fabs(y) * fabs(y))) - (fabs(z) * fabs(z))) / (fabs(y) * 2.0);
          	double tmp;
          	if (t_1 <= 0.0) {
          		tmp = t_0;
          	} else if (t_1 <= ((double) INFINITY)) {
          		tmp = 0.5 * fabs(y);
          	} else {
          		tmp = t_0;
          	}
          	return copysign(1.0, y) * tmp;
          }
          
          public static double code(double x, double y, double z) {
          	double t_0 = -0.5 * ((Math.abs(z) - Math.abs(x)) * (Math.abs(z) / Math.abs(y)));
          	double t_1 = (((Math.abs(x) * Math.abs(x)) + (Math.abs(y) * Math.abs(y))) - (Math.abs(z) * Math.abs(z))) / (Math.abs(y) * 2.0);
          	double tmp;
          	if (t_1 <= 0.0) {
          		tmp = t_0;
          	} else if (t_1 <= Double.POSITIVE_INFINITY) {
          		tmp = 0.5 * Math.abs(y);
          	} else {
          		tmp = t_0;
          	}
          	return Math.copySign(1.0, y) * tmp;
          }
          
          def code(x, y, z):
          	t_0 = -0.5 * ((math.fabs(z) - math.fabs(x)) * (math.fabs(z) / math.fabs(y)))
          	t_1 = (((math.fabs(x) * math.fabs(x)) + (math.fabs(y) * math.fabs(y))) - (math.fabs(z) * math.fabs(z))) / (math.fabs(y) * 2.0)
          	tmp = 0
          	if t_1 <= 0.0:
          		tmp = t_0
          	elif t_1 <= math.inf:
          		tmp = 0.5 * math.fabs(y)
          	else:
          		tmp = t_0
          	return math.copysign(1.0, y) * tmp
          
          function code(x, y, z)
          	t_0 = Float64(-0.5 * Float64(Float64(abs(z) - abs(x)) * Float64(abs(z) / 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))
          	tmp = 0.0
          	if (t_1 <= 0.0)
          		tmp = t_0;
          	elseif (t_1 <= Inf)
          		tmp = Float64(0.5 * abs(y));
          	else
          		tmp = t_0;
          	end
          	return Float64(copysign(1.0, y) * tmp)
          end
          
          function tmp_2 = code(x, y, z)
          	t_0 = -0.5 * ((abs(z) - abs(x)) * (abs(z) / abs(y)));
          	t_1 = (((abs(x) * abs(x)) + (abs(y) * abs(y))) - (abs(z) * abs(z))) / (abs(y) * 2.0);
          	tmp = 0.0;
          	if (t_1 <= 0.0)
          		tmp = t_0;
          	elseif (t_1 <= Inf)
          		tmp = 0.5 * abs(y);
          	else
          		tmp = t_0;
          	end
          	tmp_2 = (sign(y) * abs(1.0)) * tmp;
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(-0.5 * N[(N[(N[Abs[z], $MachinePrecision] - N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[z], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]), $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]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, Infinity], N[(0.5 * N[Abs[y], $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]]
          
          \begin{array}{l}
          t_0 := -0.5 \cdot \left(\left(\left|z\right| - \left|x\right|\right) \cdot \frac{\left|z\right|}{\left|y\right|}\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}\\
          \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
          \mathbf{if}\;t\_1 \leq 0:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;t\_1 \leq \infty:\\
          \;\;\;\;0.5 \cdot \left|y\right|\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \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))) < 0.0 or +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

            1. Initial program 68.5%

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

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

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

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

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\left(z \cdot z - x \cdot x\right) - y \cdot y\right)}\right)}{y \cdot 2} \]
              5. sub-negateN/A

                \[\leadsto \frac{\color{blue}{y \cdot y - \left(z \cdot z - x \cdot x\right)}}{y \cdot 2} \]
              6. lower--.f64N/A

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

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

                \[\leadsto \frac{y \cdot y - \left(z \cdot z - \color{blue}{x \cdot x}\right)}{y \cdot 2} \]
              9. difference-of-squaresN/A

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

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

                \[\leadsto \frac{y \cdot y - \color{blue}{\left(z + x\right)} \cdot \left(z - x\right)}{y \cdot 2} \]
              12. lower--.f6473.7%

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

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

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{2 \cdot y}} \]
              15. count-2-revN/A

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
              16. lower-+.f6473.7%

                \[\leadsto \frac{y \cdot y - \left(z + x\right) \cdot \left(z - x\right)}{\color{blue}{y + y}} \]
            3. Applied rewrites73.7%

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

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

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

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

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              4. lower-+.f64N/A

                \[\leadsto \frac{-1}{2} \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
              5. lower--.f6461.6%

                \[\leadsto -0.5 \cdot \frac{\left(x + z\right) \cdot \left(z - x\right)}{y} \]
            6. Applied rewrites61.6%

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

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

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

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

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

                \[\leadsto \frac{-1}{2} \cdot \left(\left(\left(z - x\right) \cdot \left(x + z\right)\right) \cdot \frac{1}{y}\right) \]
              6. +-commutativeN/A

                \[\leadsto \frac{-1}{2} \cdot \left(\left(\left(z - x\right) \cdot \left(z + x\right)\right) \cdot \frac{1}{y}\right) \]
              7. lift-+.f64N/A

                \[\leadsto \frac{-1}{2} \cdot \left(\left(\left(z - x\right) \cdot \left(z + x\right)\right) \cdot \frac{1}{y}\right) \]
              8. associate-*l*N/A

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

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

                \[\leadsto \frac{-1}{2} \cdot \left(\left(z - x\right) \cdot \left(\left(z + x\right) \cdot \color{blue}{\frac{1}{y}}\right)\right) \]
              11. lower-/.f6466.9%

                \[\leadsto -0.5 \cdot \left(\left(z - x\right) \cdot \left(\left(z + x\right) \cdot \frac{1}{\color{blue}{y}}\right)\right) \]
            8. Applied rewrites66.9%

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

              \[\leadsto -0.5 \cdot \left(\left(z - x\right) \cdot \frac{z}{\color{blue}{y}}\right) \]
            10. Step-by-step derivation
              1. lower-/.f6437.3%

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

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

            if 0.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0

            1. Initial program 68.5%

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
            3. Step-by-step derivation
              1. lower-*.f6434.4%

                \[\leadsto 0.5 \cdot \color{blue}{y} \]
            4. Applied rewrites34.4%

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

          Alternative 9: 34.4% accurate, 6.3× speedup?

          \[0.5 \cdot y \]
          (FPCore (x y z)
            :precision binary64
            (* 0.5 y))
          double code(double x, double y, double z) {
          	return 0.5 * y;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x, y, z)
          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]
          
          0.5 \cdot y
          
          Derivation
          1. Initial program 68.5%

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

            \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
          3. Step-by-step derivation
            1. lower-*.f6434.4%

              \[\leadsto 0.5 \cdot \color{blue}{y} \]
          4. Applied rewrites34.4%

            \[\leadsto \color{blue}{0.5 \cdot y} \]
          5. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025258 
          (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)))