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

Percentage Accurate: 88.8% → 99.8%
Time: 7.6s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

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

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

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

Alternative 1: 99.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.15 \cdot 10^{+15} \lor \neg \left(y \leq 420000000\right):\\
\;\;\;\;y - y \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.15e15 or 4.2e8 < y

    1. Initial program 77.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(1 + -1 \cdot \frac{x}{z}\right)} \]
    7. Step-by-step derivation
      1. distribute-lft-in99.9%

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

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

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

        \[\leadsto \color{blue}{y \cdot 1 - y \cdot \frac{x}{z}} \]
      5. *-rgt-identity99.9%

        \[\leadsto \color{blue}{y} - y \cdot \frac{x}{z} \]
    8. Simplified99.9%

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

    if -3.15e15 < y < 4.2e8

    1. Initial program 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.15 \cdot 10^{+15} \lor \neg \left(y \leq 420000000\right):\\ \;\;\;\;y - y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \end{array} \]

Alternative 2: 61.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -2.25 \cdot 10^{-20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-81}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-46}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-27}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+242}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (/ y z))))
   (if (<= y -2.25e-20)
     t_0
     (if (<= y 2.9e-81)
       (/ x z)
       (if (<= y 1.45e-46)
         y
         (if (<= y 7.2e-27) (/ x z) (if (<= y 2.5e+242) t_0 y)))))))
double code(double x, double y, double z) {
	double t_0 = z * (y / z);
	double tmp;
	if (y <= -2.25e-20) {
		tmp = t_0;
	} else if (y <= 2.9e-81) {
		tmp = x / z;
	} else if (y <= 1.45e-46) {
		tmp = y;
	} else if (y <= 7.2e-27) {
		tmp = x / z;
	} else if (y <= 2.5e+242) {
		tmp = t_0;
	} else {
		tmp = y;
	}
	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 = z * (y / z)
    if (y <= (-2.25d-20)) then
        tmp = t_0
    else if (y <= 2.9d-81) then
        tmp = x / z
    else if (y <= 1.45d-46) then
        tmp = y
    else if (y <= 7.2d-27) then
        tmp = x / z
    else if (y <= 2.5d+242) then
        tmp = t_0
    else
        tmp = y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * (y / z);
	double tmp;
	if (y <= -2.25e-20) {
		tmp = t_0;
	} else if (y <= 2.9e-81) {
		tmp = x / z;
	} else if (y <= 1.45e-46) {
		tmp = y;
	} else if (y <= 7.2e-27) {
		tmp = x / z;
	} else if (y <= 2.5e+242) {
		tmp = t_0;
	} else {
		tmp = y;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * (y / z)
	tmp = 0
	if y <= -2.25e-20:
		tmp = t_0
	elif y <= 2.9e-81:
		tmp = x / z
	elif y <= 1.45e-46:
		tmp = y
	elif y <= 7.2e-27:
		tmp = x / z
	elif y <= 2.5e+242:
		tmp = t_0
	else:
		tmp = y
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(y / z))
	tmp = 0.0
	if (y <= -2.25e-20)
		tmp = t_0;
	elseif (y <= 2.9e-81)
		tmp = Float64(x / z);
	elseif (y <= 1.45e-46)
		tmp = y;
	elseif (y <= 7.2e-27)
		tmp = Float64(x / z);
	elseif (y <= 2.5e+242)
		tmp = t_0;
	else
		tmp = y;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * (y / z);
	tmp = 0.0;
	if (y <= -2.25e-20)
		tmp = t_0;
	elseif (y <= 2.9e-81)
		tmp = x / z;
	elseif (y <= 1.45e-46)
		tmp = y;
	elseif (y <= 7.2e-27)
		tmp = x / z;
	elseif (y <= 2.5e+242)
		tmp = t_0;
	else
		tmp = y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.25e-20], t$95$0, If[LessEqual[y, 2.9e-81], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.45e-46], y, If[LessEqual[y, 7.2e-27], N[(x / z), $MachinePrecision], If[LessEqual[y, 2.5e+242], t$95$0, y]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -2.25 \cdot 10^{-20}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 2.9 \cdot 10^{-81}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;y \leq 1.45 \cdot 10^{-46}:\\
\;\;\;\;y\\

\mathbf{elif}\;y \leq 7.2 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;y \leq 2.5 \cdot 10^{+242}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.2500000000000001e-20 or 7.1999999999999997e-27 < y < 2.5000000000000002e242

    1. Initial program 82.1%

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

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

      \[\leadsto \frac{\color{blue}{y \cdot z}}{z} \]
    4. Step-by-step derivation
      1. *-commutative40.6%

        \[\leadsto \frac{\color{blue}{z \cdot y}}{z} \]
    5. Simplified40.6%

      \[\leadsto \frac{\color{blue}{z \cdot y}}{z} \]
    6. Step-by-step derivation
      1. *-un-lft-identity40.6%

        \[\leadsto \frac{z \cdot y}{\color{blue}{1 \cdot z}} \]
      2. times-frac58.9%

        \[\leadsto \color{blue}{\frac{z}{1} \cdot \frac{y}{z}} \]
      3. /-rgt-identity58.9%

        \[\leadsto \color{blue}{z} \cdot \frac{y}{z} \]
    7. Applied egg-rr58.9%

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

    if -2.2500000000000001e-20 < y < 2.89999999999999989e-81 or 1.45000000000000002e-46 < y < 7.1999999999999997e-27

    1. Initial program 99.9%

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

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

    if 2.89999999999999989e-81 < y < 1.45000000000000002e-46 or 2.5000000000000002e242 < y

    1. Initial program 80.9%

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

      \[\leadsto \color{blue}{y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.25 \cdot 10^{-20}:\\ \;\;\;\;z \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-81}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-46}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-27}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+242}:\\ \;\;\;\;z \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]

Alternative 3: 85.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{+67} \lor \neg \left(x \leq 3.9 \cdot 10^{+40}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.49999999999999988e67 or 3.9000000000000001e40 < x

    1. Initial program 91.3%

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

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

        \[\leadsto \color{blue}{\frac{1 + -1 \cdot y}{\frac{z}{x}}} \]
      2. associate-/r/87.7%

        \[\leadsto \color{blue}{\frac{1 + -1 \cdot y}{z} \cdot x} \]
      3. mul-1-neg87.7%

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

        \[\leadsto \frac{\color{blue}{1 - y}}{z} \cdot x \]
    4. Simplified87.7%

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

    if -2.49999999999999988e67 < x < 3.9000000000000001e40

    1. Initial program 88.6%

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

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

      \[\leadsto \color{blue}{y + \frac{x}{z}} \]
    4. Step-by-step derivation
      1. +-commutative90.6%

        \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    5. Simplified90.6%

      \[\leadsto \color{blue}{\frac{x}{z} + y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+67} \lor \neg \left(x \leq 3.9 \cdot 10^{+40}\right):\\ \;\;\;\;x \cdot \frac{1 - y}{z}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]

Alternative 4: 99.0% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 78.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(1 + -1 \cdot \frac{x}{z}\right)} \]
    7. Step-by-step derivation
      1. distribute-lft-in99.2%

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

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

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

        \[\leadsto \color{blue}{y \cdot 1 - y \cdot \frac{x}{z}} \]
      5. *-rgt-identity99.2%

        \[\leadsto \color{blue}{y} - y \cdot \frac{x}{z} \]
    8. Simplified99.2%

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

    if -235000 < y < 1

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{y + \frac{x}{z}} \]
    4. Step-by-step derivation
      1. +-commutative99.7%

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

      \[\leadsto \color{blue}{\frac{x}{z} + y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -235000 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y - y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]

Alternative 5: 81.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 40000000000:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+50}:\\ \;\;\;\;x \cdot \frac{-y}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 40000000000.0)
   (+ y (/ x z))
   (if (<= y 2.6e+50) (* x (/ (- y) z)) (- y (/ x z)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 40000000000.0) {
		tmp = y + (x / z);
	} else if (y <= 2.6e+50) {
		tmp = x * (-y / z);
	} else {
		tmp = y - (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 (y <= 40000000000.0d0) then
        tmp = y + (x / z)
    else if (y <= 2.6d+50) then
        tmp = x * (-y / z)
    else
        tmp = y - (x / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 40000000000.0) {
		tmp = y + (x / z);
	} else if (y <= 2.6e+50) {
		tmp = x * (-y / z);
	} else {
		tmp = y - (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 40000000000.0:
		tmp = y + (x / z)
	elif y <= 2.6e+50:
		tmp = x * (-y / z)
	else:
		tmp = y - (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 40000000000.0)
		tmp = Float64(y + Float64(x / z));
	elseif (y <= 2.6e+50)
		tmp = Float64(x * Float64(Float64(-y) / z));
	else
		tmp = Float64(y - Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 40000000000.0)
		tmp = y + (x / z);
	elseif (y <= 2.6e+50)
		tmp = x * (-y / z);
	else
		tmp = y - (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 40000000000.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+50], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 40000000000:\\
\;\;\;\;y + \frac{x}{z}\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+50}:\\
\;\;\;\;x \cdot \frac{-y}{z}\\

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


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

    1. Initial program 94.4%

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

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

      \[\leadsto \color{blue}{y + \frac{x}{z}} \]
    4. Step-by-step derivation
      1. +-commutative90.9%

        \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    5. Simplified90.9%

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

    if 4e10 < y < 2.6000000000000002e50

    1. Initial program 99.7%

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

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

        \[\leadsto \color{blue}{\frac{1 + -1 \cdot y}{\frac{z}{x}}} \]
      2. associate-/r/78.4%

        \[\leadsto \color{blue}{\frac{1 + -1 \cdot y}{z} \cdot x} \]
      3. mul-1-neg78.4%

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

        \[\leadsto \frac{\color{blue}{1 - y}}{z} \cdot x \]
    4. Simplified78.4%

      \[\leadsto \color{blue}{\frac{1 - y}{z} \cdot x} \]
    5. Taylor expanded in y around inf 78.4%

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{y}{z}\right)} \cdot x \]
    6. Step-by-step derivation
      1. neg-mul-178.4%

        \[\leadsto \color{blue}{\left(-\frac{y}{z}\right)} \cdot x \]
      2. distribute-neg-frac78.4%

        \[\leadsto \color{blue}{\frac{-y}{z}} \cdot x \]
    7. Simplified78.4%

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

    if 2.6000000000000002e50 < y

    1. Initial program 72.4%

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

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

      \[\leadsto \color{blue}{y + \frac{x}{z}} \]
    4. Step-by-step derivation
      1. +-commutative60.4%

        \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    5. Simplified60.4%

      \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    6. Step-by-step derivation
      1. +-commutative60.4%

        \[\leadsto \color{blue}{y + \frac{x}{z}} \]
      2. add-cube-cbrt59.1%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, \frac{x}{z}\right)} \]
      4. frac-2neg59.1%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, \color{blue}{\frac{-x}{-z}}\right) \]
      5. distribute-frac-neg59.1%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, \color{blue}{-\frac{x}{-z}}\right) \]
      6. add-sqr-sqrt27.3%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\frac{x}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}\right) \]
      7. sqrt-unprod61.4%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\frac{x}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}\right) \]
      8. sqr-neg61.4%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\frac{x}{\sqrt{\color{blue}{z \cdot z}}}\right) \]
      9. sqrt-unprod34.4%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\frac{x}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}\right) \]
      10. add-sqr-sqrt65.5%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\frac{x}{\color{blue}{z}}\right) \]
      11. fma-neg65.5%

        \[\leadsto \color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y} - \frac{x}{z}} \]
      12. add-cube-cbrt66.8%

        \[\leadsto \color{blue}{y} - \frac{x}{z} \]
    7. Applied egg-rr66.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 40000000000:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+50}:\\ \;\;\;\;x \cdot \frac{-y}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \]

Alternative 6: 96.2% accurate, 1.0× speedup?

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

\\
y + \frac{\left(1 - y\right) \cdot x}{z}
\end{array}
Derivation
  1. Initial program 89.7%

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

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

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

Alternative 7: 59.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{-22}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-81}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.8e-22) y (if (<= y 2.8e-81) (/ x z) y)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.8e-22) {
		tmp = y;
	} else if (y <= 2.8e-81) {
		tmp = x / z;
	} else {
		tmp = y;
	}
	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 <= (-3.8d-22)) then
        tmp = y
    else if (y <= 2.8d-81) 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 <= -3.8e-22) {
		tmp = y;
	} else if (y <= 2.8e-81) {
		tmp = x / z;
	} else {
		tmp = y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -3.8e-22:
		tmp = y
	elif y <= 2.8e-81:
		tmp = x / z
	else:
		tmp = y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.8e-22)
		tmp = y;
	elseif (y <= 2.8e-81)
		tmp = Float64(x / z);
	else
		tmp = y;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -3.8e-22)
		tmp = y;
	elseif (y <= 2.8e-81)
		tmp = x / z;
	else
		tmp = y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -3.8e-22], y, If[LessEqual[y, 2.8e-81], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{-22}:\\
\;\;\;\;y\\

\mathbf{elif}\;y \leq 2.8 \cdot 10^{-81}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.80000000000000023e-22 or 2.7999999999999999e-81 < y

    1. Initial program 82.7%

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

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

    if -3.80000000000000023e-22 < y < 2.7999999999999999e-81

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{-22}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-81}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]

Alternative 8: 81.5% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.0) {
		tmp = y + (x / z);
	} else {
		tmp = y - (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 (y <= 1.0d0) then
        tmp = y + (x / z)
    else
        tmp = y - (x / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.0) {
		tmp = y + (x / z);
	} else {
		tmp = y - (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 1.0:
		tmp = y + (x / z)
	else:
		tmp = y - (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 1.0)
		tmp = Float64(y + Float64(x / z));
	else
		tmp = Float64(y - Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 1.0)
		tmp = y + (x / z);
	else
		tmp = y - (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\

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


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

    1. Initial program 94.3%

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

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

      \[\leadsto \color{blue}{y + \frac{x}{z}} \]
    4. Step-by-step derivation
      1. +-commutative91.3%

        \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    5. Simplified91.3%

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

    if 1 < y

    1. Initial program 78.0%

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

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

      \[\leadsto \color{blue}{y + \frac{x}{z}} \]
    4. Step-by-step derivation
      1. +-commutative53.8%

        \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    5. Simplified53.8%

      \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    6. Step-by-step derivation
      1. +-commutative53.8%

        \[\leadsto \color{blue}{y + \frac{x}{z}} \]
      2. add-cube-cbrt52.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, \frac{x}{z}\right)} \]
      4. frac-2neg52.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, \color{blue}{\frac{-x}{-z}}\right) \]
      5. distribute-frac-neg52.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, \color{blue}{-\frac{x}{-z}}\right) \]
      6. add-sqr-sqrt25.8%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\frac{x}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}\right) \]
      7. sqrt-unprod56.5%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\frac{x}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}\right) \]
      8. sqr-neg56.5%

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

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{y} \cdot \sqrt[3]{y}, \sqrt[3]{y}, -\frac{x}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}\right) \]
      10. add-sqr-sqrt60.1%

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y} - \frac{x}{z}} \]
      12. add-cube-cbrt61.2%

        \[\leadsto \color{blue}{y} - \frac{x}{z} \]
    7. Applied egg-rr61.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \]

Alternative 9: 78.3% accurate, 1.8× speedup?

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

\\
y + \frac{x}{z}
\end{array}
Derivation
  1. Initial program 89.7%

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

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

    \[\leadsto \color{blue}{y + \frac{x}{z}} \]
  4. Step-by-step derivation
    1. +-commutative80.6%

      \[\leadsto \color{blue}{\frac{x}{z} + y} \]
  5. Simplified80.6%

    \[\leadsto \color{blue}{\frac{x}{z} + y} \]
  6. Final simplification80.6%

    \[\leadsto y + \frac{x}{z} \]

Alternative 10: 40.7% accurate, 9.0× speedup?

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

\\
y
\end{array}
Derivation
  1. Initial program 89.7%

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

    \[\leadsto \color{blue}{y} \]
  3. Final simplification43.2%

    \[\leadsto y \]

Developer target: 94.5% accurate, 0.8× speedup?

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

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

Reproduce

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

  :herbie-target
  (- (+ y (/ x z)) (/ y (/ z x)))

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