Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3

Percentage Accurate: 88.1% → 99.8%
Time: 4.5s
Alternatives: 12
Speedup: 0.8×

Specification

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

\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}

Alternative 1: 99.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+22}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-x}{z}, y, y\right)\\ \mathbf{elif}\;y \leq 410:\\ \;\;\;\;\frac{\mathsf{fma}\left(z - x, y, x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z} \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -7e+22)
   (fma (/ (- x) z) y y)
   (if (<= y 410.0) (/ (fma (- z x) y x) z) (- y (* (/ x z) y)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -7e+22) {
		tmp = fma((-x / z), y, y);
	} else if (y <= 410.0) {
		tmp = fma((z - x), y, x) / z;
	} else {
		tmp = y - ((x / z) * y);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -7e+22)
		tmp = fma(Float64(Float64(-x) / z), y, y);
	elseif (y <= 410.0)
		tmp = Float64(fma(Float64(z - x), y, x) / z);
	else
		tmp = Float64(y - Float64(Float64(x / z) * y));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -7e+22], N[(N[((-x) / z), $MachinePrecision] * y + y), $MachinePrecision], If[LessEqual[y, 410.0], N[(N[(N[(z - x), $MachinePrecision] * y + x), $MachinePrecision] / z), $MachinePrecision], N[(y - N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 410:\\
\;\;\;\;\frac{\mathsf{fma}\left(z - x, y, x\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z} \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7e22

    1. Initial program 88.1%

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

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

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

        \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
      3. lower--.f6453.6

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y \cdot z + \left(\mathsf{neg}\left(y \cdot x\right)\right)}{z} \]
      10. add-to-fraction-revN/A

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{y}{z} + y \]
      18. mult-flipN/A

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

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \left(\frac{1}{z} \cdot y\right) + y \]
      20. associate-*r*N/A

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

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{z}\right)\right) \cdot y + y \]
      22. mult-flipN/A

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\frac{x}{z}\right), \color{blue}{y}, y\right) \]
    6. Applied rewrites67.1%

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

    if -7e22 < y < 410

    1. Initial program 88.1%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z - x\right) \cdot y} + x}{z} \]
      5. lower-fma.f6488.1

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

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

    if 410 < y

    1. Initial program 88.1%

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

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

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

        \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
      3. lower--.f6453.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \left(\mathsf{neg}\left(\frac{y \cdot \left(\mathsf{neg}\left(x\right)\right)}{z}\right)\right) \]
      16. distribute-rgt-neg-inN/A

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

        \[\leadsto y - \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y \cdot x\right)}{z}\right)\right) \]
      18. distribute-neg-fracN/A

        \[\leadsto y - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{y \cdot x}{z}\right)\right)\right)\right) \]
      19. distribute-neg-frac2N/A

        \[\leadsto y - \left(\mathsf{neg}\left(\frac{y \cdot x}{\mathsf{neg}\left(z\right)}\right)\right) \]
      20. distribute-frac-negN/A

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

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

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

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

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

        \[\leadsto y - y \cdot \frac{x}{\color{blue}{z}} \]
      26. *-commutativeN/A

        \[\leadsto y - \frac{x}{z} \cdot \color{blue}{y} \]
      27. lower-*.f6467.1

        \[\leadsto y - \frac{x}{z} \cdot \color{blue}{y} \]
    6. Applied rewrites67.1%

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

Alternative 2: 99.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4 \cdot 10^{-269}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - x}{z}, y, \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{1 - y}{z}, y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 4e-269) (fma (/ (- z x) z) y (/ x z)) (fma x (/ (- 1.0 y) z) y)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 4e-269) {
		tmp = fma(((z - x) / z), y, (x / z));
	} else {
		tmp = fma(x, ((1.0 - y) / z), y);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= 4e-269)
		tmp = fma(Float64(Float64(z - x) / z), y, Float64(x / z));
	else
		tmp = fma(x, Float64(Float64(1.0 - y) / z), y);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, 4e-269], N[(N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision] * y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{1 - y}{z}, y\right)\\


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

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

    if 3.9999999999999998e-269 < y

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y \cdot z + \left(y \cdot \left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x\right)\right)\right)}}{z} \]
      13. add-to-fraction-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \color{blue}{\frac{x - y \cdot x}{z}} \]
      3. add-to-fractionN/A

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

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

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

        \[\leadsto \frac{\color{blue}{x - y \cdot x}}{z} + \frac{y \cdot z}{z} \]
      7. div-subN/A

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

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

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

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

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

        \[\leadsto \left(x \cdot \frac{1}{z} - x \cdot \color{blue}{\frac{y}{z}}\right) + \frac{y \cdot z}{z} \]
      13. distribute-lft-out--N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, \frac{1}{z} - \color{blue}{\frac{y}{z}}, y\right) \]
      19. sub-divN/A

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

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

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

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

Alternative 3: 99.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+50}:\\ \;\;\;\;y - \frac{x}{z} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{1 - y}{z}, y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1e+50) (- y (* (/ x z) y)) (fma x (/ (- 1.0 y) z) y)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1e+50) {
		tmp = y - ((x / z) * y);
	} else {
		tmp = fma(x, ((1.0 - y) / z), y);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -1e+50)
		tmp = Float64(y - Float64(Float64(x / z) * y));
	else
		tmp = fma(x, Float64(Float64(1.0 - y) / z), y);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -1e+50], N[(y - N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+50}:\\
\;\;\;\;y - \frac{x}{z} \cdot y\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{1 - y}{z}, y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.0000000000000001e50

    1. Initial program 88.1%

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

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

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

        \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
      3. lower--.f6453.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \left(\mathsf{neg}\left(\frac{y \cdot \left(\mathsf{neg}\left(x\right)\right)}{z}\right)\right) \]
      16. distribute-rgt-neg-inN/A

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

        \[\leadsto y - \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y \cdot x\right)}{z}\right)\right) \]
      18. distribute-neg-fracN/A

        \[\leadsto y - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{y \cdot x}{z}\right)\right)\right)\right) \]
      19. distribute-neg-frac2N/A

        \[\leadsto y - \left(\mathsf{neg}\left(\frac{y \cdot x}{\mathsf{neg}\left(z\right)}\right)\right) \]
      20. distribute-frac-negN/A

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

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

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

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

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

        \[\leadsto y - y \cdot \frac{x}{\color{blue}{z}} \]
      26. *-commutativeN/A

        \[\leadsto y - \frac{x}{z} \cdot \color{blue}{y} \]
      27. lower-*.f6467.1

        \[\leadsto y - \frac{x}{z} \cdot \color{blue}{y} \]
    6. Applied rewrites67.1%

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

    if -1.0000000000000001e50 < y

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y \cdot z + \left(y \cdot \left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x\right)\right)\right)}}{z} \]
      13. add-to-fraction-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \color{blue}{\frac{x - y \cdot x}{z}} \]
      3. add-to-fractionN/A

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

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

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

        \[\leadsto \frac{\color{blue}{x - y \cdot x}}{z} + \frac{y \cdot z}{z} \]
      7. div-subN/A

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

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

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

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

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

        \[\leadsto \left(x \cdot \frac{1}{z} - x \cdot \color{blue}{\frac{y}{z}}\right) + \frac{y \cdot z}{z} \]
      13. distribute-lft-out--N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, \frac{1}{z} - \color{blue}{\frac{y}{z}}, y\right) \]
      19. sub-divN/A

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

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

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

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

Alternative 4: 97.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.88:\\ \;\;\;\;\mathsf{fma}\left(\frac{-x}{z}, y, y\right)\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z} \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -0.88)
   (fma (/ (- x) z) y y)
   (if (<= y 1.0) (/ (fma z y x) z) (- y (* (/ x z) y)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -0.88) {
		tmp = fma((-x / z), y, y);
	} else if (y <= 1.0) {
		tmp = fma(z, y, x) / z;
	} else {
		tmp = y - ((x / z) * y);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -0.88)
		tmp = fma(Float64(Float64(-x) / z), y, y);
	elseif (y <= 1.0)
		tmp = Float64(fma(z, y, x) / z);
	else
		tmp = Float64(y - Float64(Float64(x / z) * y));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -0.88], N[(N[((-x) / z), $MachinePrecision] * y + y), $MachinePrecision], If[LessEqual[y, 1.0], N[(N[(z * y + x), $MachinePrecision] / z), $MachinePrecision], N[(y - N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.88:\\
\;\;\;\;\mathsf{fma}\left(\frac{-x}{z}, y, y\right)\\

\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z} \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -0.880000000000000004

    1. Initial program 88.1%

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

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

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

        \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
      3. lower--.f6453.6

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y \cdot z + \left(\mathsf{neg}\left(y \cdot x\right)\right)}{z} \]
      10. add-to-fraction-revN/A

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{y}{z} + y \]
      18. mult-flipN/A

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

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \left(\frac{1}{z} \cdot y\right) + y \]
      20. associate-*r*N/A

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

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{z}\right)\right) \cdot y + y \]
      22. mult-flipN/A

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\frac{x}{z}\right), \color{blue}{y}, y\right) \]
    6. Applied rewrites67.1%

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

    if -0.880000000000000004 < y < 1

    1. Initial program 88.1%

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

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

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

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

          \[\leadsto \frac{\color{blue}{y \cdot z + x}}{z} \]
        3. add-flipN/A

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

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

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

          \[\leadsto \frac{\color{blue}{z \cdot y} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}{z} \]
        7. remove-double-negN/A

          \[\leadsto \frac{z \cdot y + \color{blue}{x}}{z} \]
        8. lower-fma.f6469.7

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(z, y, x\right)}}{z} \]
      3. Applied rewrites69.7%

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

      if 1 < y

      1. Initial program 88.1%

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

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

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

          \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
        3. lower--.f6453.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto y - \left(\mathsf{neg}\left(\frac{y \cdot \left(\mathsf{neg}\left(x\right)\right)}{z}\right)\right) \]
        16. distribute-rgt-neg-inN/A

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

          \[\leadsto y - \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y \cdot x\right)}{z}\right)\right) \]
        18. distribute-neg-fracN/A

          \[\leadsto y - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{y \cdot x}{z}\right)\right)\right)\right) \]
        19. distribute-neg-frac2N/A

          \[\leadsto y - \left(\mathsf{neg}\left(\frac{y \cdot x}{\mathsf{neg}\left(z\right)}\right)\right) \]
        20. distribute-frac-negN/A

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

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

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

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

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

          \[\leadsto y - y \cdot \frac{x}{\color{blue}{z}} \]
        26. *-commutativeN/A

          \[\leadsto y - \frac{x}{z} \cdot \color{blue}{y} \]
        27. lower-*.f6467.1

          \[\leadsto y - \frac{x}{z} \cdot \color{blue}{y} \]
      6. Applied rewrites67.1%

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

    Alternative 5: 97.6% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := y - \frac{x}{z} \cdot y\\ \mathbf{if}\;y \leq -0.88:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (- y (* (/ x z) y))))
       (if (<= y -0.88) t_0 (if (<= y 1.0) (/ (fma z y x) z) t_0))))
    double code(double x, double y, double z) {
    	double t_0 = y - ((x / z) * y);
    	double tmp;
    	if (y <= -0.88) {
    		tmp = t_0;
    	} else if (y <= 1.0) {
    		tmp = fma(z, y, x) / z;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	t_0 = Float64(y - Float64(Float64(x / z) * y))
    	tmp = 0.0
    	if (y <= -0.88)
    		tmp = t_0;
    	elseif (y <= 1.0)
    		tmp = Float64(fma(z, y, x) / z);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(y - N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.88], t$95$0, If[LessEqual[y, 1.0], N[(N[(z * y + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := y - \frac{x}{z} \cdot y\\
    \mathbf{if}\;y \leq -0.88:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq 1:\\
    \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -0.880000000000000004 or 1 < y

      1. Initial program 88.1%

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

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

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

          \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
        3. lower--.f6453.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto y - \left(\mathsf{neg}\left(\frac{y \cdot \left(\mathsf{neg}\left(x\right)\right)}{z}\right)\right) \]
        16. distribute-rgt-neg-inN/A

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

          \[\leadsto y - \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y \cdot x\right)}{z}\right)\right) \]
        18. distribute-neg-fracN/A

          \[\leadsto y - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{y \cdot x}{z}\right)\right)\right)\right) \]
        19. distribute-neg-frac2N/A

          \[\leadsto y - \left(\mathsf{neg}\left(\frac{y \cdot x}{\mathsf{neg}\left(z\right)}\right)\right) \]
        20. distribute-frac-negN/A

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

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

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

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

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

          \[\leadsto y - y \cdot \frac{x}{\color{blue}{z}} \]
        26. *-commutativeN/A

          \[\leadsto y - \frac{x}{z} \cdot \color{blue}{y} \]
        27. lower-*.f6467.1

          \[\leadsto y - \frac{x}{z} \cdot \color{blue}{y} \]
      6. Applied rewrites67.1%

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

      if -0.880000000000000004 < y < 1

      1. Initial program 88.1%

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

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

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

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

            \[\leadsto \frac{\color{blue}{y \cdot z + x}}{z} \]
          3. add-flipN/A

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

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

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

            \[\leadsto \frac{\color{blue}{z \cdot y} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}{z} \]
          7. remove-double-negN/A

            \[\leadsto \frac{z \cdot y + \color{blue}{x}}{z} \]
          8. lower-fma.f6469.7

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(z, y, x\right)}}{z} \]
        3. Applied rewrites69.7%

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

      Alternative 6: 95.4% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{z} \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* (/ y z) (- z x))))
         (if (<= y -1.0) t_0 (if (<= y 1.0) (/ (fma z y x) z) t_0))))
      double code(double x, double y, double z) {
      	double t_0 = (y / z) * (z - x);
      	double tmp;
      	if (y <= -1.0) {
      		tmp = t_0;
      	} else if (y <= 1.0) {
      		tmp = fma(z, y, x) / z;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = Float64(Float64(y / z) * Float64(z - x))
      	tmp = 0.0
      	if (y <= -1.0)
      		tmp = t_0;
      	elseif (y <= 1.0)
      		tmp = Float64(fma(z, y, x) / z);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 1.0], N[(N[(z * y + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{y}{z} \cdot \left(z - x\right)\\
      \mathbf{if}\;y \leq -1:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq 1:\\
      \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -1 or 1 < y

        1. Initial program 88.1%

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

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

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

            \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
          3. lower--.f6453.6

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

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

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

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

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

            \[\leadsto \frac{y}{z} \cdot \left(\color{blue}{z} - x\right) \]
          5. lower-*.f6456.1

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

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

        if -1 < y < 1

        1. Initial program 88.1%

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

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

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

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

              \[\leadsto \frac{\color{blue}{y \cdot z + x}}{z} \]
            3. add-flipN/A

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

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

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

              \[\leadsto \frac{\color{blue}{z \cdot y} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}{z} \]
            7. remove-double-negN/A

              \[\leadsto \frac{z \cdot y + \color{blue}{x}}{z} \]
            8. lower-fma.f6469.7

              \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(z, y, x\right)}}{z} \]
          3. Applied rewrites69.7%

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

        Alternative 7: 86.0% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{1 - y}{z}\\ \mathbf{if}\;x \leq -2.4 \cdot 10^{+66}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+38}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{1}{z}, y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (* x (/ (- 1.0 y) z))))
           (if (<= x -2.4e+66) t_0 (if (<= x 3e+38) (fma x (/ 1.0 z) y) t_0))))
        double code(double x, double y, double z) {
        	double t_0 = x * ((1.0 - y) / z);
        	double tmp;
        	if (x <= -2.4e+66) {
        		tmp = t_0;
        	} else if (x <= 3e+38) {
        		tmp = fma(x, (1.0 / z), y);
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(x, y, z)
        	t_0 = Float64(x * Float64(Float64(1.0 - y) / z))
        	tmp = 0.0
        	if (x <= -2.4e+66)
        		tmp = t_0;
        	elseif (x <= 3e+38)
        		tmp = fma(x, Float64(1.0 / z), y);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.4e+66], t$95$0, If[LessEqual[x, 3e+38], N[(x * N[(1.0 / z), $MachinePrecision] + y), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := x \cdot \frac{1 - y}{z}\\
        \mathbf{if}\;x \leq -2.4 \cdot 10^{+66}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;x \leq 3 \cdot 10^{+38}:\\
        \;\;\;\;\mathsf{fma}\left(x, \frac{1}{z}, y\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < -2.4000000000000002e66 or 3.0000000000000001e38 < x

          1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{y \cdot z + \left(y \cdot \left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x\right)\right)\right)}}{z} \]
            13. add-to-fraction-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto y + \color{blue}{\frac{x - y \cdot x}{z}} \]
            3. add-to-fractionN/A

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

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

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

              \[\leadsto \frac{\color{blue}{x - y \cdot x}}{z} + \frac{y \cdot z}{z} \]
            7. div-subN/A

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

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

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

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

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

              \[\leadsto \left(x \cdot \frac{1}{z} - x \cdot \color{blue}{\frac{y}{z}}\right) + \frac{y \cdot z}{z} \]
            13. distribute-lft-out--N/A

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(x, \frac{1}{z} - \color{blue}{\frac{y}{z}}, y\right) \]
            19. sub-divN/A

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

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

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

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

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

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

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

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

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

              \[\leadsto x \cdot \left(\left(\frac{1}{z} + \frac{y}{x}\right) - \frac{y}{z}\right) \]
            6. lower-/.f6487.8

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

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

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

              \[\leadsto x \cdot \frac{1 - y}{z} \]
            2. lower--.f6458.8

              \[\leadsto x \cdot \frac{1 - y}{z} \]
          11. Applied rewrites58.8%

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

          if -2.4000000000000002e66 < x < 3.0000000000000001e38

          1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{y \cdot z + \left(y \cdot \left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x\right)\right)\right)}}{z} \]
            13. add-to-fraction-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto y + \color{blue}{\frac{x - y \cdot x}{z}} \]
            3. add-to-fractionN/A

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

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

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

              \[\leadsto \frac{\color{blue}{x - y \cdot x}}{z} + \frac{y \cdot z}{z} \]
            7. div-subN/A

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

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

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

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

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

              \[\leadsto \left(x \cdot \frac{1}{z} - x \cdot \color{blue}{\frac{y}{z}}\right) + \frac{y \cdot z}{z} \]
            13. distribute-lft-out--N/A

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(x, \frac{1}{z} - \color{blue}{\frac{y}{z}}, y\right) \]
            19. sub-divN/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{1}}{z}, y\right) \]
          7. Step-by-step derivation
            1. Applied rewrites78.8%

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

          Alternative 8: 78.8% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7.8 \cdot 10^{+127}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot z\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= y -7.8e+127) y (if (<= y 1.0) (/ (fma z y x) z) (* (/ y z) z))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= -7.8e+127) {
          		tmp = y;
          	} else if (y <= 1.0) {
          		tmp = fma(z, y, x) / z;
          	} else {
          		tmp = (y / z) * z;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if (y <= -7.8e+127)
          		tmp = y;
          	elseif (y <= 1.0)
          		tmp = Float64(fma(z, y, x) / z);
          	else
          		tmp = Float64(Float64(y / z) * z);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[LessEqual[y, -7.8e+127], y, If[LessEqual[y, 1.0], N[(N[(z * y + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * z), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -7.8 \cdot 10^{+127}:\\
          \;\;\;\;y\\
          
          \mathbf{elif}\;y \leq 1:\\
          \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{y}{z} \cdot z\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if y < -7.79999999999999962e127

            1. Initial program 88.1%

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

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

                \[\leadsto \color{blue}{y} \]

              if -7.79999999999999962e127 < y < 1

              1. Initial program 88.1%

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

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

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

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

                    \[\leadsto \frac{\color{blue}{y \cdot z + x}}{z} \]
                  3. add-flipN/A

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

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

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

                    \[\leadsto \frac{\color{blue}{z \cdot y} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}{z} \]
                  7. remove-double-negN/A

                    \[\leadsto \frac{z \cdot y + \color{blue}{x}}{z} \]
                  8. lower-fma.f6469.7

                    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(z, y, x\right)}}{z} \]
                3. Applied rewrites69.7%

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

                if 1 < y

                1. Initial program 88.1%

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

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

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

                    \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
                  3. lower--.f6453.6

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

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

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

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

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

                    \[\leadsto \frac{y}{z} \cdot \left(\color{blue}{z} - x\right) \]
                  5. lower-*.f6456.1

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

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

                  \[\leadsto \frac{y}{z} \cdot z \]
                8. Step-by-step derivation
                  1. Applied rewrites37.4%

                    \[\leadsto \frac{y}{z} \cdot z \]
                9. Recombined 3 regimes into one program.
                10. Add Preprocessing

                Alternative 9: 77.3% accurate, 1.4× speedup?

                \[\begin{array}{l} \\ \mathsf{fma}\left(x, \frac{1}{z}, y\right) \end{array} \]
                (FPCore (x y z) :precision binary64 (fma x (/ 1.0 z) y))
                double code(double x, double y, double z) {
                	return fma(x, (1.0 / z), y);
                }
                
                function code(x, y, z)
                	return fma(x, Float64(1.0 / z), y)
                end
                
                code[x_, y_, z_] := N[(x * N[(1.0 / z), $MachinePrecision] + y), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                \mathsf{fma}\left(x, \frac{1}{z}, y\right)
                \end{array}
                
                Derivation
                1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\color{blue}{y \cdot z + \left(y \cdot \left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x\right)\right)\right)}}{z} \]
                  13. add-to-fraction-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto y + \color{blue}{\frac{x - y \cdot x}{z}} \]
                  3. add-to-fractionN/A

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

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

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

                    \[\leadsto \frac{\color{blue}{x - y \cdot x}}{z} + \frac{y \cdot z}{z} \]
                  7. div-subN/A

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

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

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

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

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

                    \[\leadsto \left(x \cdot \frac{1}{z} - x \cdot \color{blue}{\frac{y}{z}}\right) + \frac{y \cdot z}{z} \]
                  13. distribute-lft-out--N/A

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(x, \frac{1}{z} - \color{blue}{\frac{y}{z}}, y\right) \]
                  19. sub-divN/A

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{1}}{z}, y\right) \]
                7. Step-by-step derivation
                  1. Applied rewrites78.8%

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

                  Alternative 10: 62.2% accurate, 0.8× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.000245:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-37}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot z\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (if (<= y -0.000245) y (if (<= y 1.25e-37) (/ x z) (* (/ y z) z))))
                  double code(double x, double y, double z) {
                  	double tmp;
                  	if (y <= -0.000245) {
                  		tmp = y;
                  	} else if (y <= 1.25e-37) {
                  		tmp = x / z;
                  	} else {
                  		tmp = (y / z) * z;
                  	}
                  	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 (y <= (-0.000245d0)) then
                          tmp = y
                      else if (y <= 1.25d-37) then
                          tmp = x / z
                      else
                          tmp = (y / z) * z
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y, double z) {
                  	double tmp;
                  	if (y <= -0.000245) {
                  		tmp = y;
                  	} else if (y <= 1.25e-37) {
                  		tmp = x / z;
                  	} else {
                  		tmp = (y / z) * z;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z):
                  	tmp = 0
                  	if y <= -0.000245:
                  		tmp = y
                  	elif y <= 1.25e-37:
                  		tmp = x / z
                  	else:
                  		tmp = (y / z) * z
                  	return tmp
                  
                  function code(x, y, z)
                  	tmp = 0.0
                  	if (y <= -0.000245)
                  		tmp = y;
                  	elseif (y <= 1.25e-37)
                  		tmp = Float64(x / z);
                  	else
                  		tmp = Float64(Float64(y / z) * z);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z)
                  	tmp = 0.0;
                  	if (y <= -0.000245)
                  		tmp = y;
                  	elseif (y <= 1.25e-37)
                  		tmp = x / z;
                  	else
                  		tmp = (y / z) * z;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_] := If[LessEqual[y, -0.000245], y, If[LessEqual[y, 1.25e-37], N[(x / z), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * z), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;y \leq -0.000245:\\
                  \;\;\;\;y\\
                  
                  \mathbf{elif}\;y \leq 1.25 \cdot 10^{-37}:\\
                  \;\;\;\;\frac{x}{z}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{y}{z} \cdot z\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if y < -2.4499999999999999e-4

                    1. Initial program 88.1%

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

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

                        \[\leadsto \color{blue}{y} \]

                      if -2.4499999999999999e-4 < y < 1.2499999999999999e-37

                      1. Initial program 88.1%

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

                        \[\leadsto \color{blue}{\frac{x}{z}} \]
                      3. Step-by-step derivation
                        1. lower-/.f6440.2

                          \[\leadsto \frac{x}{\color{blue}{z}} \]
                      4. Applied rewrites40.2%

                        \[\leadsto \color{blue}{\frac{x}{z}} \]

                      if 1.2499999999999999e-37 < y

                      1. Initial program 88.1%

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

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

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

                          \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
                        3. lower--.f6453.6

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

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

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

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

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

                          \[\leadsto \frac{y}{z} \cdot \left(\color{blue}{z} - x\right) \]
                        5. lower-*.f6456.1

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

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

                        \[\leadsto \frac{y}{z} \cdot z \]
                      8. Step-by-step derivation
                        1. Applied rewrites37.4%

                          \[\leadsto \frac{y}{z} \cdot z \]
                      9. Recombined 3 regimes into one program.
                      10. Add Preprocessing

                      Alternative 11: 61.5% accurate, 1.1× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.000245:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-37}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
                      (FPCore (x y z)
                       :precision binary64
                       (if (<= y -0.000245) y (if (<= y 1.25e-37) (/ x z) y)))
                      double code(double x, double y, double z) {
                      	double tmp;
                      	if (y <= -0.000245) {
                      		tmp = y;
                      	} else if (y <= 1.25e-37) {
                      		tmp = x / z;
                      	} else {
                      		tmp = y;
                      	}
                      	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 (y <= (-0.000245d0)) then
                              tmp = y
                          else if (y <= 1.25d-37) then
                              tmp = x / z
                          else
                              tmp = y
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double x, double y, double z) {
                      	double tmp;
                      	if (y <= -0.000245) {
                      		tmp = y;
                      	} else if (y <= 1.25e-37) {
                      		tmp = x / z;
                      	} else {
                      		tmp = y;
                      	}
                      	return tmp;
                      }
                      
                      def code(x, y, z):
                      	tmp = 0
                      	if y <= -0.000245:
                      		tmp = y
                      	elif y <= 1.25e-37:
                      		tmp = x / z
                      	else:
                      		tmp = y
                      	return tmp
                      
                      function code(x, y, z)
                      	tmp = 0.0
                      	if (y <= -0.000245)
                      		tmp = y;
                      	elseif (y <= 1.25e-37)
                      		tmp = Float64(x / z);
                      	else
                      		tmp = y;
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(x, y, z)
                      	tmp = 0.0;
                      	if (y <= -0.000245)
                      		tmp = y;
                      	elseif (y <= 1.25e-37)
                      		tmp = x / z;
                      	else
                      		tmp = y;
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[x_, y_, z_] := If[LessEqual[y, -0.000245], y, If[LessEqual[y, 1.25e-37], N[(x / z), $MachinePrecision], y]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;y \leq -0.000245:\\
                      \;\;\;\;y\\
                      
                      \mathbf{elif}\;y \leq 1.25 \cdot 10^{-37}:\\
                      \;\;\;\;\frac{x}{z}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;y\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if y < -2.4499999999999999e-4 or 1.2499999999999999e-37 < y

                        1. Initial program 88.1%

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

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

                            \[\leadsto \color{blue}{y} \]

                          if -2.4499999999999999e-4 < y < 1.2499999999999999e-37

                          1. Initial program 88.1%

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

                            \[\leadsto \color{blue}{\frac{x}{z}} \]
                          3. Step-by-step derivation
                            1. lower-/.f6440.2

                              \[\leadsto \frac{x}{\color{blue}{z}} \]
                          4. Applied rewrites40.2%

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

                        Alternative 12: 41.2% accurate, 12.7× speedup?

                        \[\begin{array}{l} \\ y \end{array} \]
                        (FPCore (x y z) :precision binary64 y)
                        double code(double x, double y, double z) {
                        	return 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 = y
                        end function
                        
                        public static double code(double x, double y, double z) {
                        	return y;
                        }
                        
                        def code(x, y, z):
                        	return y
                        
                        function code(x, y, z)
                        	return y
                        end
                        
                        function tmp = code(x, y, z)
                        	tmp = y;
                        end
                        
                        code[x_, y_, z_] := y
                        
                        \begin{array}{l}
                        
                        \\
                        y
                        \end{array}
                        
                        Derivation
                        1. Initial program 88.1%

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

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

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

                          Reproduce

                          ?
                          herbie shell --seed 2025143 
                          (FPCore (x y z)
                            :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
                            :precision binary64
                            (/ (+ x (* y (- z x))) z))