Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3

Percentage Accurate: 84.0% → 97.5%
Time: 2.6s
Alternatives: 6
Speedup: 0.4×

Specification

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 6 alternatives:

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

Initial Program: 84.0% accurate, 1.0× speedup?

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

Alternative 1: 97.5% accurate, 0.4× speedup?

\[\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 2.9 \cdot 10^{+84}:\\ \;\;\;\;\left|x\right| - \frac{z \cdot \left|x\right|}{y}\\ \mathbf{else}:\\ \;\;\;\;\left|x\right| - \frac{z}{y} \cdot \left|x\right|\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (*
  (copysign 1.0 x)
  (if (<= (fabs x) 2.9e+84)
    (- (fabs x) (/ (* z (fabs x)) y))
    (- (fabs x) (* (/ z y) (fabs x))))))
double code(double x, double y, double z) {
	double tmp;
	if (fabs(x) <= 2.9e+84) {
		tmp = fabs(x) - ((z * fabs(x)) / y);
	} else {
		tmp = fabs(x) - ((z / y) * fabs(x));
	}
	return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (Math.abs(x) <= 2.9e+84) {
		tmp = Math.abs(x) - ((z * Math.abs(x)) / y);
	} else {
		tmp = Math.abs(x) - ((z / y) * Math.abs(x));
	}
	return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z):
	tmp = 0
	if math.fabs(x) <= 2.9e+84:
		tmp = math.fabs(x) - ((z * math.fabs(x)) / y)
	else:
		tmp = math.fabs(x) - ((z / y) * math.fabs(x))
	return math.copysign(1.0, x) * tmp
function code(x, y, z)
	tmp = 0.0
	if (abs(x) <= 2.9e+84)
		tmp = Float64(abs(x) - Float64(Float64(z * abs(x)) / y));
	else
		tmp = Float64(abs(x) - Float64(Float64(z / y) * abs(x)));
	end
	return Float64(copysign(1.0, x) * tmp)
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (abs(x) <= 2.9e+84)
		tmp = abs(x) - ((z * abs(x)) / y);
	else
		tmp = abs(x) - ((z / y) * abs(x));
	end
	tmp_2 = (sign(x) * abs(1.0)) * tmp;
end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 2.9e+84], N[(N[Abs[x], $MachinePrecision] - N[(N[(z * N[Abs[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] - N[(N[(z / y), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2.9 \cdot 10^{+84}:\\
\;\;\;\;\left|x\right| - \frac{z \cdot \left|x\right|}{y}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.89999999999999989e84

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \left(z \cdot x\right) \cdot \color{blue}{\frac{1}{y}} \]
      3. mult-flip-revN/A

        \[\leadsto x - \color{blue}{\frac{z \cdot x}{y}} \]
      4. lower-/.f6494.0%

        \[\leadsto x - \color{blue}{\frac{z \cdot x}{y}} \]
    5. Applied rewrites94.0%

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

    if 2.89999999999999989e84 < x

    1. Initial program 84.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{y} \cdot x + \frac{\mathsf{neg}\left(z\right)}{y} \cdot x} \]
      8. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\frac{z}{y} \cdot x} \]
      15. lower-/.f6495.8%

        \[\leadsto x - \color{blue}{\frac{z}{y}} \cdot x \]
    3. Applied rewrites95.8%

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

Alternative 2: 96.7% accurate, 0.3× speedup?

\[\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{\left|x\right| \cdot \left(y - z\right)}{y} \leq -2 \cdot 10^{-34}:\\ \;\;\;\;\frac{\left|x\right|}{y} \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;\left|x\right| - \frac{z}{y} \cdot \left|x\right|\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (*
  (copysign 1.0 x)
  (if (<= (/ (* (fabs x) (- y z)) y) -2e-34)
    (* (/ (fabs x) y) (- y z))
    (- (fabs x) (* (/ z y) (fabs x))))))
double code(double x, double y, double z) {
	double tmp;
	if (((fabs(x) * (y - z)) / y) <= -2e-34) {
		tmp = (fabs(x) / y) * (y - z);
	} else {
		tmp = fabs(x) - ((z / y) * fabs(x));
	}
	return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (((Math.abs(x) * (y - z)) / y) <= -2e-34) {
		tmp = (Math.abs(x) / y) * (y - z);
	} else {
		tmp = Math.abs(x) - ((z / y) * Math.abs(x));
	}
	return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z):
	tmp = 0
	if ((math.fabs(x) * (y - z)) / y) <= -2e-34:
		tmp = (math.fabs(x) / y) * (y - z)
	else:
		tmp = math.fabs(x) - ((z / y) * math.fabs(x))
	return math.copysign(1.0, x) * tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(Float64(abs(x) * Float64(y - z)) / y) <= -2e-34)
		tmp = Float64(Float64(abs(x) / y) * Float64(y - z));
	else
		tmp = Float64(abs(x) - Float64(Float64(z / y) * abs(x)));
	end
	return Float64(copysign(1.0, x) * tmp)
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((abs(x) * (y - z)) / y) <= -2e-34)
		tmp = (abs(x) / y) * (y - z);
	else
		tmp = abs(x) - ((z / y) * abs(x));
	end
	tmp_2 = (sign(x) * abs(1.0)) * tmp;
end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(N[Abs[x], $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], -2e-34], N[(N[(N[Abs[x], $MachinePrecision] / y), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] - N[(N[(z / y), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left|x\right| \cdot \left(y - z\right)}{y} \leq -2 \cdot 10^{-34}:\\
\;\;\;\;\frac{\left|x\right|}{y} \cdot \left(y - z\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -1.99999999999999986e-34

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(y - z\right) \]
      9. lower-/.f6484.7%

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

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

    if -1.99999999999999986e-34 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 84.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{y} \cdot x + \frac{\mathsf{neg}\left(z\right)}{y} \cdot x} \]
      8. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\frac{z}{y} \cdot x} \]
      15. lower-/.f6495.8%

        \[\leadsto x - \color{blue}{\frac{z}{y}} \cdot x \]
    3. Applied rewrites95.8%

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

Alternative 3: 91.4% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \frac{\left|x\right|}{y} \cdot \left(y - z\right)\\ t_1 := \frac{\left|x\right| \cdot \left(y - z\right)}{y}\\ \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-118}:\\ \;\;\;\;\frac{\left|x\right| \cdot y}{y}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ (fabs x) y) (- y z))) (t_1 (/ (* (fabs x) (- y z)) y)))
   (*
    (copysign 1.0 x)
    (if (<= t_1 0.0) t_0 (if (<= t_1 2e-118) (/ (* (fabs x) y) y) t_0)))))
double code(double x, double y, double z) {
	double t_0 = (fabs(x) / y) * (y - z);
	double t_1 = (fabs(x) * (y - z)) / y;
	double tmp;
	if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 2e-118) {
		tmp = (fabs(x) * y) / y;
	} else {
		tmp = t_0;
	}
	return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = (Math.abs(x) / y) * (y - z);
	double t_1 = (Math.abs(x) * (y - z)) / y;
	double tmp;
	if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 2e-118) {
		tmp = (Math.abs(x) * y) / y;
	} else {
		tmp = t_0;
	}
	return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z):
	t_0 = (math.fabs(x) / y) * (y - z)
	t_1 = (math.fabs(x) * (y - z)) / y
	tmp = 0
	if t_1 <= 0.0:
		tmp = t_0
	elif t_1 <= 2e-118:
		tmp = (math.fabs(x) * y) / y
	else:
		tmp = t_0
	return math.copysign(1.0, x) * tmp
function code(x, y, z)
	t_0 = Float64(Float64(abs(x) / y) * Float64(y - z))
	t_1 = Float64(Float64(abs(x) * Float64(y - z)) / y)
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 2e-118)
		tmp = Float64(Float64(abs(x) * y) / y);
	else
		tmp = t_0;
	end
	return Float64(copysign(1.0, x) * tmp)
end
function tmp_2 = code(x, y, z)
	t_0 = (abs(x) / y) * (y - z);
	t_1 = (abs(x) * (y - z)) / y;
	tmp = 0.0;
	if (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 2e-118)
		tmp = (abs(x) * y) / y;
	else
		tmp = t_0;
	end
	tmp_2 = (sign(x) * abs(1.0)) * tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] / y), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Abs[x], $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 2e-118], N[(N[(N[Abs[x], $MachinePrecision] * y), $MachinePrecision] / y), $MachinePrecision], t$95$0]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{\left|x\right|}{y} \cdot \left(y - z\right)\\
t_1 := \frac{\left|x\right| \cdot \left(y - z\right)}{y}\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-118}:\\
\;\;\;\;\frac{\left|x\right| \cdot y}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -0.0 or 1.99999999999999997e-118 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(y - z\right) \]
      9. lower-/.f6484.7%

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

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

    if -0.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.99999999999999997e-118

    1. Initial program 84.0%

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

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

        \[\leadsto \frac{x \cdot \color{blue}{y}}{y} \]
    4. Applied rewrites39.1%

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

Alternative 4: 69.9% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \frac{-\left|x\right|}{y} \cdot z\\ t_1 := \frac{\left|x\right| \cdot \left(y - z\right)}{y}\\ \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+289}:\\ \;\;\;\;\frac{\left|x\right| \cdot y}{y}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ (- (fabs x)) y) z)) (t_1 (/ (* (fabs x) (- y z)) y)))
   (*
    (copysign 1.0 x)
    (if (<= t_1 0.0) t_0 (if (<= t_1 2e+289) (/ (* (fabs x) y) y) t_0)))))
double code(double x, double y, double z) {
	double t_0 = (-fabs(x) / y) * z;
	double t_1 = (fabs(x) * (y - z)) / y;
	double tmp;
	if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 2e+289) {
		tmp = (fabs(x) * y) / y;
	} else {
		tmp = t_0;
	}
	return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = (-Math.abs(x) / y) * z;
	double t_1 = (Math.abs(x) * (y - z)) / y;
	double tmp;
	if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 2e+289) {
		tmp = (Math.abs(x) * y) / y;
	} else {
		tmp = t_0;
	}
	return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z):
	t_0 = (-math.fabs(x) / y) * z
	t_1 = (math.fabs(x) * (y - z)) / y
	tmp = 0
	if t_1 <= 0.0:
		tmp = t_0
	elif t_1 <= 2e+289:
		tmp = (math.fabs(x) * y) / y
	else:
		tmp = t_0
	return math.copysign(1.0, x) * tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(-abs(x)) / y) * z)
	t_1 = Float64(Float64(abs(x) * Float64(y - z)) / y)
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 2e+289)
		tmp = Float64(Float64(abs(x) * y) / y);
	else
		tmp = t_0;
	end
	return Float64(copysign(1.0, x) * tmp)
end
function tmp_2 = code(x, y, z)
	t_0 = (-abs(x) / y) * z;
	t_1 = (abs(x) * (y - z)) / y;
	tmp = 0.0;
	if (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 2e+289)
		tmp = (abs(x) * y) / y;
	else
		tmp = t_0;
	end
	tmp_2 = (sign(x) * abs(1.0)) * tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[((-N[Abs[x], $MachinePrecision]) / y), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Abs[x], $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 2e+289], N[(N[(N[Abs[x], $MachinePrecision] * y), $MachinePrecision] / y), $MachinePrecision], t$95$0]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{-\left|x\right|}{y} \cdot z\\
t_1 := \frac{\left|x\right| \cdot \left(y - z\right)}{y}\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+289}:\\
\;\;\;\;\frac{\left|x\right| \cdot y}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -0.0 or 2.0000000000000001e289 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{1}{y} \cdot \left(-x\right)\right) \cdot \color{blue}{z} \]
    5. Step-by-step derivation
      1. Applied rewrites47.5%

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

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

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

          \[\leadsto \left(\left(-x\right) \cdot \color{blue}{\frac{1}{y}}\right) \cdot z \]
        4. mult-flip-revN/A

          \[\leadsto \color{blue}{\frac{-x}{y}} \cdot z \]
        5. lower-/.f6447.5%

          \[\leadsto \color{blue}{\frac{-x}{y}} \cdot z \]
      3. Applied rewrites47.5%

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

      if -0.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2.0000000000000001e289

      1. Initial program 84.0%

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

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

          \[\leadsto \frac{x \cdot \color{blue}{y}}{y} \]
      4. Applied rewrites39.1%

        \[\leadsto \frac{\color{blue}{x \cdot y}}{y} \]
    6. Recombined 2 regimes into one program.
    7. Add Preprocessing

    Alternative 5: 69.8% accurate, 0.2× speedup?

    \[\begin{array}{l} t_0 := \frac{z}{-y} \cdot \left|x\right|\\ t_1 := \frac{\left|x\right| \cdot \left(y - z\right)}{y}\\ \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+289}:\\ \;\;\;\;\frac{\left|x\right| \cdot y}{y}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* (/ z (- y)) (fabs x))) (t_1 (/ (* (fabs x) (- y z)) y)))
       (*
        (copysign 1.0 x)
        (if (<= t_1 0.0) t_0 (if (<= t_1 2e+289) (/ (* (fabs x) y) y) t_0)))))
    double code(double x, double y, double z) {
    	double t_0 = (z / -y) * fabs(x);
    	double t_1 = (fabs(x) * (y - z)) / y;
    	double tmp;
    	if (t_1 <= 0.0) {
    		tmp = t_0;
    	} else if (t_1 <= 2e+289) {
    		tmp = (fabs(x) * y) / y;
    	} else {
    		tmp = t_0;
    	}
    	return copysign(1.0, x) * tmp;
    }
    
    public static double code(double x, double y, double z) {
    	double t_0 = (z / -y) * Math.abs(x);
    	double t_1 = (Math.abs(x) * (y - z)) / y;
    	double tmp;
    	if (t_1 <= 0.0) {
    		tmp = t_0;
    	} else if (t_1 <= 2e+289) {
    		tmp = (Math.abs(x) * y) / y;
    	} else {
    		tmp = t_0;
    	}
    	return Math.copySign(1.0, x) * tmp;
    }
    
    def code(x, y, z):
    	t_0 = (z / -y) * math.fabs(x)
    	t_1 = (math.fabs(x) * (y - z)) / y
    	tmp = 0
    	if t_1 <= 0.0:
    		tmp = t_0
    	elif t_1 <= 2e+289:
    		tmp = (math.fabs(x) * y) / y
    	else:
    		tmp = t_0
    	return math.copysign(1.0, x) * tmp
    
    function code(x, y, z)
    	t_0 = Float64(Float64(z / Float64(-y)) * abs(x))
    	t_1 = Float64(Float64(abs(x) * Float64(y - z)) / y)
    	tmp = 0.0
    	if (t_1 <= 0.0)
    		tmp = t_0;
    	elseif (t_1 <= 2e+289)
    		tmp = Float64(Float64(abs(x) * y) / y);
    	else
    		tmp = t_0;
    	end
    	return Float64(copysign(1.0, x) * tmp)
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = (z / -y) * abs(x);
    	t_1 = (abs(x) * (y - z)) / y;
    	tmp = 0.0;
    	if (t_1 <= 0.0)
    		tmp = t_0;
    	elseif (t_1 <= 2e+289)
    		tmp = (abs(x) * y) / y;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = (sign(x) * abs(1.0)) * tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z / (-y)), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Abs[x], $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 2e+289], N[(N[(N[Abs[x], $MachinePrecision] * y), $MachinePrecision] / y), $MachinePrecision], t$95$0]]), $MachinePrecision]]]
    
    \begin{array}{l}
    t_0 := \frac{z}{-y} \cdot \left|x\right|\\
    t_1 := \frac{\left|x\right| \cdot \left(y - z\right)}{y}\\
    \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
    \mathbf{if}\;t\_1 \leq 0:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+289}:\\
    \;\;\;\;\frac{\left|x\right| \cdot y}{y}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -0.0 or 2.0000000000000001e289 < (/.f64 (*.f64 x (-.f64 y z)) y)

      1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{y} \cdot \left(-x\right)\right) \cdot \color{blue}{z} \]
      5. Step-by-step derivation
        1. Applied rewrites47.5%

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

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

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

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

            \[\leadsto \left(\left(-x\right) \cdot \color{blue}{\frac{1}{y}}\right) \cdot z \]
          5. mult-flip-revN/A

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

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

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

            \[\leadsto \frac{\color{blue}{z \cdot \left(-x\right)}}{y} \]
          9. lower-*.f6447.7%

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

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

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

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

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

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

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

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

            \[\leadsto z \cdot \color{blue}{\frac{-1 \cdot x}{y}} \]
          8. associate-*l/N/A

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{z}{\mathsf{neg}\left(y\right)}} \cdot x \]
          17. lower-neg.f6447.2%

            \[\leadsto \frac{z}{\color{blue}{-y}} \cdot x \]
        5. Applied rewrites47.2%

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

        if -0.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2.0000000000000001e289

        1. Initial program 84.0%

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

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

            \[\leadsto \frac{x \cdot \color{blue}{y}}{y} \]
        4. Applied rewrites39.1%

          \[\leadsto \frac{\color{blue}{x \cdot y}}{y} \]
      6. Recombined 2 regimes into one program.
      7. Add Preprocessing

      Alternative 6: 39.1% accurate, 1.4× speedup?

      \[\frac{x \cdot y}{y} \]
      (FPCore (x y z) :precision binary64 (/ (* x y) y))
      double code(double x, double y, double z) {
      	return (x * y) / 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 = (x * y) / y
      end function
      
      public static double code(double x, double y, double z) {
      	return (x * y) / y;
      }
      
      def code(x, y, z):
      	return (x * y) / y
      
      function code(x, y, z)
      	return Float64(Float64(x * y) / y)
      end
      
      function tmp = code(x, y, z)
      	tmp = (x * y) / y;
      end
      
      code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision]
      
      \frac{x \cdot y}{y}
      
      Derivation
      1. Initial program 84.0%

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

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

          \[\leadsto \frac{x \cdot \color{blue}{y}}{y} \]
      4. Applied rewrites39.1%

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

      Reproduce

      ?
      herbie shell --seed 2025188 
      (FPCore (x y z)
        :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
        :precision binary64
        (/ (* x (- y z)) y))