Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3

Percentage Accurate: 88.4% → 99.5%
Time: 7.2s
Alternatives: 9
Speedup: 0.6×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
	return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
	return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z):
	return (x * ((y - z) + 1.0)) / z
function code(x, y, z)
	return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z)
end
function tmp = code(x, y, z)
	tmp = (x * ((y - z) + 1.0)) / z;
end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 88.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
	return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
	return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z):
	return (x * ((y - z) + 1.0)) / z
function code(x, y, z)
	return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z)
end
function tmp = code(x, y, z)
	tmp = (x * ((y - z) + 1.0)) / z;
end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y - z\right) + 1\\ \mathbf{if}\;z \leq -2 \cdot 10^{+73} \lor \neg \left(z \leq 8200000000\right):\\ \;\;\;\;x \cdot \frac{t\_0}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (- y z) 1.0)))
   (if (or (<= z -2e+73) (not (<= z 8200000000.0)))
     (* x (/ t_0 z))
     (* t_0 (/ x z)))))
double code(double x, double y, double z) {
	double t_0 = (y - z) + 1.0;
	double tmp;
	if ((z <= -2e+73) || !(z <= 8200000000.0)) {
		tmp = x * (t_0 / z);
	} else {
		tmp = t_0 * (x / z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    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) + 1.0d0
    if ((z <= (-2d+73)) .or. (.not. (z <= 8200000000.0d0))) then
        tmp = x * (t_0 / z)
    else
        tmp = t_0 * (x / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (y - z) + 1.0;
	double tmp;
	if ((z <= -2e+73) || !(z <= 8200000000.0)) {
		tmp = x * (t_0 / z);
	} else {
		tmp = t_0 * (x / z);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (y - z) + 1.0
	tmp = 0
	if (z <= -2e+73) or not (z <= 8200000000.0):
		tmp = x * (t_0 / z)
	else:
		tmp = t_0 * (x / z)
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(y - z) + 1.0)
	tmp = 0.0
	if ((z <= -2e+73) || !(z <= 8200000000.0))
		tmp = Float64(x * Float64(t_0 / z));
	else
		tmp = Float64(t_0 * Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (y - z) + 1.0;
	tmp = 0.0;
	if ((z <= -2e+73) || ~((z <= 8200000000.0)))
		tmp = x * (t_0 / z);
	else
		tmp = t_0 * (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[Or[LessEqual[z, -2e+73], N[Not[LessEqual[z, 8200000000.0]], $MachinePrecision]], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;z \leq -2 \cdot 10^{+73} \lor \neg \left(z \leq 8200000000\right):\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.99999999999999997e73 or 8.2e9 < z

    1. Initial program 67.6%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing

    if -1.99999999999999997e73 < z < 8.2e9

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*91.4%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(\left(1 + y\right) - z\right)}{z}} \]
    6. Step-by-step derivation
      1. associate--l+99.9%

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

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

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

        \[\leadsto \frac{x}{z} \cdot \color{blue}{\left(1 + \left(y - z\right)\right)} \]
    7. Simplified99.9%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(1 + \left(y - z\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+73} \lor \neg \left(z \leq 8200000000\right):\\ \;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y - z\right) + 1\right) \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 64.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -1.8 \cdot 10^{+43}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-82}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-77}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+64}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -1.8e+43)
     (- x)
     (if (<= z -2e-82)
       t_0
       (if (<= z 1.02e-77) (/ x z) (if (<= z 1.25e+64) t_0 (- x)))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -1.8e+43) {
		tmp = -x;
	} else if (z <= -2e-82) {
		tmp = t_0;
	} else if (z <= 1.02e-77) {
		tmp = x / z;
	} else if (z <= 1.25e+64) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    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 * (x / z)
    if (z <= (-1.8d+43)) then
        tmp = -x
    else if (z <= (-2d-82)) then
        tmp = t_0
    else if (z <= 1.02d-77) then
        tmp = x / z
    else if (z <= 1.25d+64) then
        tmp = t_0
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -1.8e+43) {
		tmp = -x;
	} else if (z <= -2e-82) {
		tmp = t_0;
	} else if (z <= 1.02e-77) {
		tmp = x / z;
	} else if (z <= 1.25e+64) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -1.8e+43:
		tmp = -x
	elif z <= -2e-82:
		tmp = t_0
	elif z <= 1.02e-77:
		tmp = x / z
	elif z <= 1.25e+64:
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -1.8e+43)
		tmp = Float64(-x);
	elseif (z <= -2e-82)
		tmp = t_0;
	elseif (z <= 1.02e-77)
		tmp = Float64(x / z);
	elseif (z <= 1.25e+64)
		tmp = t_0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (x / z);
	tmp = 0.0;
	if (z <= -1.8e+43)
		tmp = -x;
	elseif (z <= -2e-82)
		tmp = t_0;
	elseif (z <= 1.02e-77)
		tmp = x / z;
	elseif (z <= 1.25e+64)
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.8e+43], (-x), If[LessEqual[z, -2e-82], t$95$0, If[LessEqual[z, 1.02e-77], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.25e+64], t$95$0, (-x)]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1.8 \cdot 10^{+43}:\\
\;\;\;\;-x\\

\mathbf{elif}\;z \leq -2 \cdot 10^{-82}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.02 \cdot 10^{-77}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 1.25 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;-x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.80000000000000005e43 or 1.25e64 < z

    1. Initial program 65.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*100.0%

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 83.6%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-183.6%

        \[\leadsto \color{blue}{-x} \]
    7. Simplified83.6%

      \[\leadsto \color{blue}{-x} \]

    if -1.80000000000000005e43 < z < -2e-82 or 1.02e-77 < z < 1.25e64

    1. Initial program 96.4%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*96.2%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(\left(1 + y\right) - z\right)}{z}} \]
    6. Step-by-step derivation
      1. associate--l+96.4%

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

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

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

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

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

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

    if -2e-82 < z < 1.02e-77

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*89.7%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + y\right)}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*89.7%

        \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    7. Simplified89.7%

      \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    8. Taylor expanded in y around 0 66.3%

      \[\leadsto \color{blue}{\frac{x}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{+43}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-82}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-77}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+64}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 63.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{+43}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-82}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-72}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+72}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ y z))))
   (if (<= z -2.8e+43)
     (- x)
     (if (<= z -1.25e-82)
       t_0
       (if (<= z 4.3e-72) (/ x z) (if (<= z 1.45e+72) t_0 (- x)))))))
double code(double x, double y, double z) {
	double t_0 = x * (y / z);
	double tmp;
	if (z <= -2.8e+43) {
		tmp = -x;
	} else if (z <= -1.25e-82) {
		tmp = t_0;
	} else if (z <= 4.3e-72) {
		tmp = x / z;
	} else if (z <= 1.45e+72) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x * (y / z)
    if (z <= (-2.8d+43)) then
        tmp = -x
    else if (z <= (-1.25d-82)) then
        tmp = t_0
    else if (z <= 4.3d-72) then
        tmp = x / z
    else if (z <= 1.45d+72) then
        tmp = t_0
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (y / z);
	double tmp;
	if (z <= -2.8e+43) {
		tmp = -x;
	} else if (z <= -1.25e-82) {
		tmp = t_0;
	} else if (z <= 4.3e-72) {
		tmp = x / z;
	} else if (z <= 1.45e+72) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y / z)
	tmp = 0
	if z <= -2.8e+43:
		tmp = -x
	elif z <= -1.25e-82:
		tmp = t_0
	elif z <= 4.3e-72:
		tmp = x / z
	elif z <= 1.45e+72:
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(y / z))
	tmp = 0.0
	if (z <= -2.8e+43)
		tmp = Float64(-x);
	elseif (z <= -1.25e-82)
		tmp = t_0;
	elseif (z <= 4.3e-72)
		tmp = Float64(x / z);
	elseif (z <= 1.45e+72)
		tmp = t_0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (y / z);
	tmp = 0.0;
	if (z <= -2.8e+43)
		tmp = -x;
	elseif (z <= -1.25e-82)
		tmp = t_0;
	elseif (z <= 4.3e-72)
		tmp = x / z;
	elseif (z <= 1.45e+72)
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.8e+43], (-x), If[LessEqual[z, -1.25e-82], t$95$0, If[LessEqual[z, 4.3e-72], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.45e+72], t$95$0, (-x)]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -2.8 \cdot 10^{+43}:\\
\;\;\;\;-x\\

\mathbf{elif}\;z \leq -1.25 \cdot 10^{-82}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 4.3 \cdot 10^{-72}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 1.45 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;-x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.80000000000000019e43 or 1.45000000000000009e72 < z

    1. Initial program 65.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*100.0%

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 84.2%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-184.2%

        \[\leadsto \color{blue}{-x} \]
    7. Simplified84.2%

      \[\leadsto \color{blue}{-x} \]

    if -2.80000000000000019e43 < z < -1.25e-82 or 4.2999999999999999e-72 < z < 1.45000000000000009e72

    1. Initial program 96.5%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*96.3%

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 53.8%

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*53.6%

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    7. Simplified53.6%

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

    if -1.25e-82 < z < 4.2999999999999999e-72

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*89.7%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + y\right)}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*89.7%

        \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    7. Simplified89.7%

      \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    8. Taylor expanded in y around 0 66.3%

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

Alternative 4: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-29} \lor \neg \left(z \leq 7.2 \cdot 10^{-25}\right):\\ \;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1e-29) (not (<= z 7.2e-25)))
   (* x (/ (+ (- y z) 1.0) z))
   (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1e-29) || !(z <= 7.2e-25)) {
		tmp = x * (((y - z) + 1.0) / z);
	} else {
		tmp = (x * (y + 1.0)) / z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-1d-29)) .or. (.not. (z <= 7.2d-25))) then
        tmp = x * (((y - z) + 1.0d0) / z)
    else
        tmp = (x * (y + 1.0d0)) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1e-29) || !(z <= 7.2e-25)) {
		tmp = x * (((y - z) + 1.0) / z);
	} else {
		tmp = (x * (y + 1.0)) / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1e-29) or not (z <= 7.2e-25):
		tmp = x * (((y - z) + 1.0) / z)
	else:
		tmp = (x * (y + 1.0)) / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1e-29) || !(z <= 7.2e-25))
		tmp = Float64(x * Float64(Float64(Float64(y - z) + 1.0) / z));
	else
		tmp = Float64(Float64(x * Float64(y + 1.0)) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1e-29) || ~((z <= 7.2e-25)))
		tmp = x * (((y - z) + 1.0) / z);
	else
		tmp = (x * (y + 1.0)) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-29], N[Not[LessEqual[z, 7.2e-25]], $MachinePrecision]], N[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-29} \lor \neg \left(z \leq 7.2 \cdot 10^{-25}\right):\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.99999999999999943e-30 or 7.1999999999999998e-25 < z

    1. Initial program 74.3%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing

    if -9.99999999999999943e-30 < z < 7.1999999999999998e-25

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*89.3%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + y\right)}{z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-29} \lor \neg \left(z \leq 7.2 \cdot 10^{-25}\right):\\ \;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 84.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9.4 \cdot 10^{+51} \lor \neg \left(y \leq 3 \cdot 10^{+42}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -9.4e+51) (not (<= y 3e+42))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -9.4e+51) || !(y <= 3e+42)) {
		tmp = y * (x / z);
	} else {
		tmp = (x / z) - x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-9.4d+51)) .or. (.not. (y <= 3d+42))) then
        tmp = y * (x / z)
    else
        tmp = (x / z) - x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -9.4e+51) || !(y <= 3e+42)) {
		tmp = y * (x / z);
	} else {
		tmp = (x / z) - x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -9.4e+51) or not (y <= 3e+42):
		tmp = y * (x / z)
	else:
		tmp = (x / z) - x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -9.4e+51) || !(y <= 3e+42))
		tmp = Float64(y * Float64(x / z));
	else
		tmp = Float64(Float64(x / z) - x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -9.4e+51) || ~((y <= 3e+42)))
		tmp = y * (x / z);
	else
		tmp = (x / z) - x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.4e+51], N[Not[LessEqual[y, 3e+42]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.4 \cdot 10^{+51} \lor \neg \left(y \leq 3 \cdot 10^{+42}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.4000000000000005e51 or 3.00000000000000029e42 < y

    1. Initial program 81.7%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*89.3%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(\left(1 + y\right) - z\right)}{z}} \]
    6. Step-by-step derivation
      1. associate--l+81.7%

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

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(\left(y - z\right) + 1\right)} \]
      4. +-commutative93.0%

        \[\leadsto \frac{x}{z} \cdot \color{blue}{\left(1 + \left(y - z\right)\right)} \]
    7. Simplified93.0%

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

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

    if -9.4000000000000005e51 < y < 3.00000000000000029e42

    1. Initial program 88.7%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*98.6%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(\left(1 + y\right) - z\right)}{z}} \]
    6. Step-by-step derivation
      1. associate--l+88.7%

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(1 + \left(y - z\right)\right)} \]
    8. Step-by-step derivation
      1. *-commutative89.1%

        \[\leadsto \color{blue}{\left(1 + \left(y - z\right)\right) \cdot \frac{x}{z}} \]
      2. clear-num88.4%

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

        \[\leadsto \color{blue}{\frac{1 + \left(y - z\right)}{\frac{z}{x}}} \]
      4. associate-+r-88.6%

        \[\leadsto \frac{\color{blue}{\left(1 + y\right) - z}}{\frac{z}{x}} \]
      5. +-commutative88.6%

        \[\leadsto \frac{\color{blue}{\left(y + 1\right)} - z}{\frac{z}{x}} \]
      6. associate--l+88.6%

        \[\leadsto \frac{\color{blue}{y + \left(1 - z\right)}}{\frac{z}{x}} \]
    9. Applied egg-rr88.6%

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 - z\right)}{z}} \]
    11. Step-by-step derivation
      1. associate-/l*94.0%

        \[\leadsto \color{blue}{x \cdot \frac{1 - z}{z}} \]
      2. div-sub94.0%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} - \frac{z}{z}\right)} \]
      3. *-inverses94.0%

        \[\leadsto x \cdot \left(\frac{1}{z} - \color{blue}{1}\right) \]
      4. sub-neg94.0%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      5. metadata-eval94.0%

        \[\leadsto x \cdot \left(\frac{1}{z} + \color{blue}{-1}\right) \]
      6. distribute-lft-out94.0%

        \[\leadsto \color{blue}{x \cdot \frac{1}{z} + x \cdot -1} \]
      7. *-commutative94.0%

        \[\leadsto x \cdot \frac{1}{z} + \color{blue}{-1 \cdot x} \]
      8. neg-mul-194.0%

        \[\leadsto x \cdot \frac{1}{z} + \color{blue}{\left(-x\right)} \]
      9. associate-*r/94.2%

        \[\leadsto \color{blue}{\frac{x \cdot 1}{z}} + \left(-x\right) \]
      10. *-rgt-identity94.2%

        \[\leadsto \frac{\color{blue}{x}}{z} + \left(-x\right) \]
      11. unsub-neg94.2%

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    12. Simplified94.2%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.4 \cdot 10^{+51} \lor \neg \left(y \leq 3 \cdot 10^{+42}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 94.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y - z\right) + 1\\ \mathbf{if}\;x \leq 2 \cdot 10^{-20}:\\ \;\;\;\;\frac{x \cdot t\_0}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t\_0}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (- y z) 1.0)))
   (if (<= x 2e-20) (/ (* x t_0) z) (* x (/ t_0 z)))))
double code(double x, double y, double z) {
	double t_0 = (y - z) + 1.0;
	double tmp;
	if (x <= 2e-20) {
		tmp = (x * t_0) / z;
	} else {
		tmp = x * (t_0 / z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    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) + 1.0d0
    if (x <= 2d-20) then
        tmp = (x * t_0) / z
    else
        tmp = x * (t_0 / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (y - z) + 1.0;
	double tmp;
	if (x <= 2e-20) {
		tmp = (x * t_0) / z;
	} else {
		tmp = x * (t_0 / z);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (y - z) + 1.0
	tmp = 0
	if x <= 2e-20:
		tmp = (x * t_0) / z
	else:
		tmp = x * (t_0 / z)
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(y - z) + 1.0)
	tmp = 0.0
	if (x <= 2e-20)
		tmp = Float64(Float64(x * t_0) / z);
	else
		tmp = Float64(x * Float64(t_0 / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (y - z) + 1.0;
	tmp = 0.0;
	if (x <= 2e-20)
		tmp = (x * t_0) / z;
	else
		tmp = x * (t_0 / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, 2e-20], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;x \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.99999999999999989e-20

    1. Initial program 90.4%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Add Preprocessing

    if 1.99999999999999989e-20 < x

    1. Initial program 71.3%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

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

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

Alternative 7: 63.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.0) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		tmp = -x;
	} else {
		tmp = x / z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
        tmp = -x
    else
        tmp = x / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.0)) {
		tmp = -x;
	} else {
		tmp = x / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 1.0):
		tmp = -x
	else:
		tmp = x / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 1.0))
		tmp = Float64(-x);
	else
		tmp = Float64(x / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.0) || ~((z <= 1.0)))
		tmp = -x;
	else
		tmp = x / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1 or 1 < z

    1. Initial program 72.4%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 73.5%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-173.5%

        \[\leadsto \color{blue}{-x} \]
    7. Simplified73.5%

      \[\leadsto \color{blue}{-x} \]

    if -1 < z < 1

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*90.1%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + y\right)}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*88.5%

        \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    7. Simplified88.5%

      \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    8. Taylor expanded in y around 0 60.2%

      \[\leadsto \color{blue}{\frac{x}{z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 38.2% accurate, 4.5× speedup?

\[\begin{array}{l} \\ -x \end{array} \]
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
	return -x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = -x
end function
public static double code(double x, double y, double z) {
	return -x;
}
def code(x, y, z):
	return -x
function code(x, y, z)
	return Float64(-x)
end
function tmp = code(x, y, z)
	tmp = -x;
end
code[x_, y_, z_] := (-x)
\begin{array}{l}

\\
-x
\end{array}
Derivation
  1. Initial program 86.0%

    \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
  2. Step-by-step derivation
    1. associate-/l*95.0%

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

    \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 38.5%

    \[\leadsto \color{blue}{-1 \cdot x} \]
  6. Step-by-step derivation
    1. neg-mul-138.5%

      \[\leadsto \color{blue}{-x} \]
  7. Simplified38.5%

    \[\leadsto \color{blue}{-x} \]
  8. Add Preprocessing

Alternative 9: 3.0% accurate, 9.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
	return x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x
end function
public static double code(double x, double y, double z) {
	return x;
}
def code(x, y, z):
	return x
function code(x, y, z)
	return x
end
function tmp = code(x, y, z)
	tmp = x;
end
code[x_, y_, z_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 86.0%

    \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
  2. Step-by-step derivation
    1. associate-/l*95.0%

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

    \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 38.5%

    \[\leadsto \color{blue}{-1 \cdot x} \]
  6. Step-by-step derivation
    1. neg-mul-138.5%

      \[\leadsto \color{blue}{-x} \]
  7. Simplified38.5%

    \[\leadsto \color{blue}{-x} \]
  8. Step-by-step derivation
    1. neg-sub038.5%

      \[\leadsto \color{blue}{0 - x} \]
    2. sub-neg38.5%

      \[\leadsto \color{blue}{0 + \left(-x\right)} \]
    3. add-sqr-sqrt20.3%

      \[\leadsto 0 + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}} \]
    4. sqrt-unprod18.8%

      \[\leadsto 0 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \]
    5. sqr-neg18.8%

      \[\leadsto 0 + \sqrt{\color{blue}{x \cdot x}} \]
    6. sqrt-unprod1.5%

      \[\leadsto 0 + \color{blue}{\sqrt{x} \cdot \sqrt{x}} \]
    7. add-sqr-sqrt2.9%

      \[\leadsto 0 + \color{blue}{x} \]
  9. Applied egg-rr2.9%

    \[\leadsto \color{blue}{0 + x} \]
  10. Taylor expanded in x around 0 2.9%

    \[\leadsto \color{blue}{x} \]
  11. Add Preprocessing

Developer Target 1: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\ \mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\ \;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
   (if (< x -2.71483106713436e-162)
     t_0
     (if (< x 3.874108816439546e-197)
       (* (* x (+ (- y z) 1.0)) (/ 1.0 z))
       t_0))))
double code(double x, double y, double z) {
	double t_0 = ((1.0 + y) * (x / z)) - x;
	double tmp;
	if (x < -2.71483106713436e-162) {
		tmp = t_0;
	} else if (x < 3.874108816439546e-197) {
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((1.0d0 + y) * (x / z)) - x
    if (x < (-2.71483106713436d-162)) then
        tmp = t_0
    else if (x < 3.874108816439546d-197) then
        tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = ((1.0 + y) * (x / z)) - x;
	double tmp;
	if (x < -2.71483106713436e-162) {
		tmp = t_0;
	} else if (x < 3.874108816439546e-197) {
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = ((1.0 + y) * (x / z)) - x
	tmp = 0
	if x < -2.71483106713436e-162:
		tmp = t_0
	elif x < 3.874108816439546e-197:
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x)
	tmp = 0.0
	if (x < -2.71483106713436e-162)
		tmp = t_0;
	elseif (x < 3.874108816439546e-197)
		tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = ((1.0 + y) * (x / z)) - x;
	tmp = 0.0;
	if (x < -2.71483106713436e-162)
		tmp = t_0;
	elseif (x < 3.874108816439546e-197)
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024131 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))

  (/ (* x (+ (- y z) 1.0)) z))