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

Percentage Accurate: 87.9% → 99.9%
Time: 2.6s
Alternatives: 10
Speedup: 1.1×

Specification

?
\[\frac{x + y \cdot \left(z - x\right)}{z} \]
(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]
\frac{x + y \cdot \left(z - x\right)}{z}

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

\[\frac{x + y \cdot \left(z - x\right)}{z} \]
(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]
\frac{x + y \cdot \left(z - x\right)}{z}

Alternative 1: 99.9% accurate, 1.1× speedup?

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

    \[\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. lower-/.f64N/A

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

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

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

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

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

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

      \[\leadsto y + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, x\right)}}{z} \]
    22. lower-neg.f6496.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{x}{z}, \color{blue}{1 - y}, y\right) \]
    17. lower--.f6499.9%

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

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

Alternative 2: 99.7% accurate, 0.6× speedup?

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

\mathbf{elif}\;y \leq 5 \cdot 10^{+25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z - x, y, x\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.99999999999999979e27 or 5.00000000000000024e25 < y

    1. Initial program 87.9%

      \[\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--.f6454.5%

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

      \[\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. associate-/l*N/A

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

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

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

        \[\leadsto \frac{z - x}{z} \cdot y \]
      8. lift--.f6468.6%

        \[\leadsto \frac{z - x}{z} \cdot y \]
    6. Applied rewrites68.6%

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

    if -4.99999999999999979e27 < y < 5.00000000000000024e25

    1. Initial program 87.9%

      \[\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.0%

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

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

Alternative 3: 98.8% accurate, 0.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.4e12 or 1.1e8 < y

    1. Initial program 87.9%

      \[\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--.f6454.5%

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

      \[\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. associate-/l*N/A

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

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

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

        \[\leadsto \frac{z - x}{z} \cdot y \]
      8. lift--.f6468.6%

        \[\leadsto \frac{z - x}{z} \cdot y \]
    6. Applied rewrites68.6%

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

    if -1.4e12 < y < 1.1e8

    1. Initial program 87.9%

      \[\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. lower-/.f64N/A

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

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

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

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

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

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

        \[\leadsto y + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, x\right)}}{z} \]
      22. lower-neg.f6496.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{x}{z}, \color{blue}{1 - y}, y\right) \]
      17. lower--.f6499.9%

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

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

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

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

    Alternative 4: 97.3% accurate, 0.8× speedup?

    \[\begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{+122}:\\ \;\;\;\;\frac{z - x}{z} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{1 - y}{z}, y\right)\\ \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (if (<= y -2.4e+122) (* (/ (- z x) z) y) (fma x (/ (- 1.0 y) z) y)))
    double code(double x, double y, double z) {
    	double tmp;
    	if (y <= -2.4e+122) {
    		tmp = ((z - x) / z) * y;
    	} else {
    		tmp = fma(x, ((1.0 - y) / z), y);
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	tmp = 0.0
    	if (y <= -2.4e+122)
    		tmp = Float64(Float64(Float64(z - 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, -2.4e+122], N[(N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision] + y), $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;y \leq -2.4 \cdot 10^{+122}:\\
    \;\;\;\;\frac{z - x}{z} \cdot y\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(x, \frac{1 - y}{z}, y\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -2.4000000000000002e122

      1. Initial program 87.9%

        \[\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--.f6454.5%

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

        \[\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. associate-/l*N/A

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

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

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

          \[\leadsto \frac{z - x}{z} \cdot y \]
        8. lift--.f6468.6%

          \[\leadsto \frac{z - x}{z} \cdot y \]
      6. Applied rewrites68.6%

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

      if -2.4000000000000002e122 < y

      1. Initial program 87.9%

        \[\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. lower-/.f64N/A

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

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

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

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

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

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

          \[\leadsto y + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, x\right)}}{z} \]
        22. lower-neg.f6496.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 94.9% accurate, 0.7× speedup?

    \[\begin{array}{l} t_0 := \frac{y}{z} \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -1400000000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 110000000:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1, y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* (/ y z) (- z x))))
       (if (<= y -1400000000000.0)
         t_0
         (if (<= y 110000000.0) (fma (/ x z) 1.0 y) t_0))))
    double code(double x, double y, double z) {
    	double t_0 = (y / z) * (z - x);
    	double tmp;
    	if (y <= -1400000000000.0) {
    		tmp = t_0;
    	} else if (y <= 110000000.0) {
    		tmp = fma((x / z), 1.0, y);
    	} 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 <= -1400000000000.0)
    		tmp = t_0;
    	elseif (y <= 110000000.0)
    		tmp = fma(Float64(x / z), 1.0, y);
    	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, -1400000000000.0], t$95$0, If[LessEqual[y, 110000000.0], N[(N[(x / z), $MachinePrecision] * 1.0 + y), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    t_0 := \frac{y}{z} \cdot \left(z - x\right)\\
    \mathbf{if}\;y \leq -1400000000000:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq 110000000:\\
    \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1, y\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -1.4e12 or 1.1e8 < y

      1. Initial program 87.9%

        \[\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--.f6454.5%

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

        \[\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. *-commutativeN/A

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

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

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

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

          \[\leadsto \frac{y}{z} \cdot \left(\color{blue}{z} - x\right) \]
        9. lift--.f6457.0%

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

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

      if -1.4e12 < y < 1.1e8

      1. Initial program 87.9%

        \[\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. lower-/.f64N/A

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

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

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

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

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

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

          \[\leadsto y + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, x\right)}}{z} \]
        22. lower-neg.f6496.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{x}{z}, \color{blue}{1 - y}, y\right) \]
        17. lower--.f6499.9%

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

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

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

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

      Alternative 6: 78.9% accurate, 1.0× speedup?

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

        1. Initial program 87.9%

          \[\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. lower-/.f64N/A

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

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

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

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

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

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

            \[\leadsto y + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, x\right)}}{z} \]
          22. lower-neg.f6496.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{x}{z}, \color{blue}{1 - y}, y\right) \]
          17. lower--.f6499.9%

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

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

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

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

          if 1.50000000000000003e25 < y

          1. Initial program 87.9%

            \[\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--.f6454.5%

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

            \[\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. *-commutativeN/A

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

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

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

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

              \[\leadsto \frac{y}{z} \cdot \left(\color{blue}{z} - x\right) \]
            9. lift--.f6457.0%

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

            \[\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 2 regimes into one program.
          10. Add Preprocessing

          Alternative 7: 76.4% accurate, 0.7× speedup?

          \[\begin{array}{l} t_0 := \frac{y}{z} \cdot z\\ \mathbf{if}\;y \leq -1.75 \cdot 10^{+164}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+25}:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (let* ((t_0 (* (/ y z) z)))
             (if (<= y -1.75e+164) t_0 (if (<= y 1.5e+25) (/ (fma z y x) z) t_0))))
          double code(double x, double y, double z) {
          	double t_0 = (y / z) * z;
          	double tmp;
          	if (y <= -1.75e+164) {
          		tmp = t_0;
          	} else if (y <= 1.5e+25) {
          		tmp = fma(z, y, x) / z;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	t_0 = Float64(Float64(y / z) * z)
          	tmp = 0.0
          	if (y <= -1.75e+164)
          		tmp = t_0;
          	elseif (y <= 1.5e+25)
          		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] * z), $MachinePrecision]}, If[LessEqual[y, -1.75e+164], t$95$0, If[LessEqual[y, 1.5e+25], N[(N[(z * y + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          t_0 := \frac{y}{z} \cdot z\\
          \mathbf{if}\;y \leq -1.75 \cdot 10^{+164}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;y \leq 1.5 \cdot 10^{+25}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(z, y, x\right)}{z}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -1.7499999999999999e164 or 1.50000000000000003e25 < y

            1. Initial program 87.9%

              \[\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--.f6454.5%

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

              \[\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. *-commutativeN/A

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

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

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

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

                \[\leadsto \frac{y}{z} \cdot \left(\color{blue}{z} - x\right) \]
              9. lift--.f6457.0%

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

              \[\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 \]

              if -1.7499999999999999e164 < y < 1.50000000000000003e25

              1. Initial program 87.9%

                \[\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 rewrites68.3%

                  \[\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. lift-*.f64N/A

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

                    \[\leadsto \frac{\color{blue}{z \cdot y} + x}{z} \]
                  5. lower-fma.f6468.3%

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

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

              Alternative 8: 60.1% accurate, 0.8× speedup?

              \[\begin{array}{l} t_0 := \frac{y}{z} \cdot z\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{-111}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 110000000:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (let* ((t_0 (* (/ y z) z)))
                 (if (<= y -1.25e-111) t_0 (if (<= y 110000000.0) (/ x z) t_0))))
              double code(double x, double y, double z) {
              	double t_0 = (y / z) * z;
              	double tmp;
              	if (y <= -1.25e-111) {
              		tmp = t_0;
              	} else if (y <= 110000000.0) {
              		tmp = x / z;
              	} else {
              		tmp = t_0;
              	}
              	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) :: t_0
                  real(8) :: tmp
                  t_0 = (y / z) * z
                  if (y <= (-1.25d-111)) then
                      tmp = t_0
                  else if (y <= 110000000.0d0) then
                      tmp = x / z
                  else
                      tmp = t_0
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y, double z) {
              	double t_0 = (y / z) * z;
              	double tmp;
              	if (y <= -1.25e-111) {
              		tmp = t_0;
              	} else if (y <= 110000000.0) {
              		tmp = x / z;
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              def code(x, y, z):
              	t_0 = (y / z) * z
              	tmp = 0
              	if y <= -1.25e-111:
              		tmp = t_0
              	elif y <= 110000000.0:
              		tmp = x / z
              	else:
              		tmp = t_0
              	return tmp
              
              function code(x, y, z)
              	t_0 = Float64(Float64(y / z) * z)
              	tmp = 0.0
              	if (y <= -1.25e-111)
              		tmp = t_0;
              	elseif (y <= 110000000.0)
              		tmp = Float64(x / z);
              	else
              		tmp = t_0;
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y, z)
              	t_0 = (y / z) * z;
              	tmp = 0.0;
              	if (y <= -1.25e-111)
              		tmp = t_0;
              	elseif (y <= 110000000.0)
              		tmp = x / z;
              	else
              		tmp = t_0;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[y, -1.25e-111], t$95$0, If[LessEqual[y, 110000000.0], N[(x / z), $MachinePrecision], t$95$0]]]
              
              \begin{array}{l}
              t_0 := \frac{y}{z} \cdot z\\
              \mathbf{if}\;y \leq -1.25 \cdot 10^{-111}:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;y \leq 110000000:\\
              \;\;\;\;\frac{x}{z}\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_0\\
              
              
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if y < -1.2500000000000001e-111 or 1.1e8 < y

                1. Initial program 87.9%

                  \[\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--.f6454.5%

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

                  \[\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. *-commutativeN/A

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

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

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

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

                    \[\leadsto \frac{y}{z} \cdot \left(\color{blue}{z} - x\right) \]
                  9. lift--.f6457.0%

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

                  \[\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 \]

                  if -1.2500000000000001e-111 < y < 1.1e8

                  1. Initial program 87.9%

                    \[\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-/.f6439.4%

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

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

                Alternative 9: 58.7% accurate, 1.1× speedup?

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

                  1. Initial program 87.9%

                    \[\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.0%

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

                    if -1.2500000000000001e-111 < y < 1.1e8

                    1. Initial program 87.9%

                      \[\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-/.f6439.4%

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

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

                  Alternative 10: 41.0% accurate, 12.7× speedup?

                  \[y \]
                  (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
                  
                  y
                  
                  Derivation
                  1. Initial program 87.9%

                    \[\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.0%

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

                    Reproduce

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