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

Percentage Accurate: 87.7% → 99.6%
Time: 6.7s
Alternatives: 12
Speedup: 0.6×

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 12 alternatives:

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

Initial Program: 87.7% 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.6% accurate, 0.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.19999999999999978e-72 or 9.99999999999999958e-75 < z

    1. Initial program 77.8%

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

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

    if -9.19999999999999978e-72 < z < 9.99999999999999958e-75

    1. Initial program 99.9%

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

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

Alternative 2: 78.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.2 \cdot 10^{+28}:\\
\;\;\;\;y + \frac{x}{z}\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{+62} \lor \neg \left(y \leq 4.8 \cdot 10^{+216}\right):\\
\;\;\;\;x \cdot \frac{y}{-z}\\

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


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

    1. Initial program 88.5%

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

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

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

    if 2.19999999999999986e28 < y < 3.49999999999999984e62 or 4.7999999999999999e216 < y

    1. Initial program 83.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    7. Step-by-step derivation
      1. mul-1-neg68.9%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-/l*65.7%

        \[\leadsto -\color{blue}{x \cdot \frac{y}{z}} \]
      3. distribute-rgt-neg-in65.7%

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

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

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

    if 3.49999999999999984e62 < y < 4.7999999999999999e216

    1. Initial program 65.9%

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

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

        \[\leadsto \frac{\color{blue}{z \cdot y}}{z} \]
      2. associate-/l*77.9%

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

      \[\leadsto \color{blue}{z \cdot \frac{y}{z}} \]
    6. Step-by-step derivation
      1. clear-num77.8%

        \[\leadsto z \cdot \color{blue}{\frac{1}{\frac{z}{y}}} \]
      2. un-div-inv78.1%

        \[\leadsto \color{blue}{\frac{z}{\frac{z}{y}}} \]
    7. Applied egg-rr78.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.2 \cdot 10^{+28}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+62} \lor \neg \left(y \leq 4.8 \cdot 10^{+216}\right):\\ \;\;\;\;x \cdot \frac{y}{-z}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{z}{y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 78.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.6 \cdot 10^{+28}:\\
\;\;\;\;y + \frac{x}{z}\\

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

\mathbf{elif}\;y \leq 3.3 \cdot 10^{+216}:\\
\;\;\;\;\frac{z}{\frac{z}{y}}\\

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


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

    1. Initial program 88.5%

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

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

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

    if 2.6000000000000002e28 < y < 3.79999999999999984e62

    1. Initial program 86.8%

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + -1 \cdot y}{z}} \]
      2. mul-1-neg61.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot y}{z}} \]
    7. Step-by-step derivation
      1. mul-1-neg67.5%

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      2. associate-/l*61.6%

        \[\leadsto -\color{blue}{x \cdot \frac{y}{z}} \]
      3. distribute-rgt-neg-in61.6%

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

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

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

    if 3.79999999999999984e62 < y < 3.3e216

    1. Initial program 65.9%

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

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

        \[\leadsto \frac{\color{blue}{z \cdot y}}{z} \]
      2. associate-/l*77.9%

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

      \[\leadsto \color{blue}{z \cdot \frac{y}{z}} \]
    6. Step-by-step derivation
      1. clear-num77.8%

        \[\leadsto z \cdot \color{blue}{\frac{1}{\frac{z}{y}}} \]
      2. un-div-inv78.1%

        \[\leadsto \color{blue}{\frac{z}{\frac{z}{y}}} \]
    7. Applied egg-rr78.1%

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

    if 3.3e216 < y

    1. Initial program 79.1%

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

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

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

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

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

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

        \[\leadsto \left(y \cdot \left(\frac{1}{y} + \color{blue}{-1}\right)\right) \cdot \frac{x}{z} \]
      5. distribute-lft-in77.5%

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot \frac{1}{y} - y\right)} \cdot \frac{x}{z} \]
      9. rgt-mult-inverse77.5%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(1 - y\right)} \]
      11. associate-/r/70.6%

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

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

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

        \[\leadsto \frac{x}{\color{blue}{\frac{-1 \cdot z}{y}}} \]
      2. mul-1-neg70.6%

        \[\leadsto \frac{x}{\frac{\color{blue}{-z}}{y}} \]
    9. Simplified70.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.6 \cdot 10^{+28}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+62}:\\ \;\;\;\;x \cdot \frac{y}{-z}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+216}:\\ \;\;\;\;\frac{z}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{-y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+43}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\

\mathbf{elif}\;y \leq 4.2 \cdot 10^{+15}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\

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


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

    1. Initial program 66.0%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{z - x}{z}} \]
      2. div-sub99.9%

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

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

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

    if -6.00000000000000033e43 < y < 4.2e15

    1. Initial program 99.9%

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

    if 4.2e15 < y

    1. Initial program 75.5%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{z - x}{z}} \]
      2. div-sub99.9%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+43}:\\ \;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+15}:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y - y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.1% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 74.2%

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

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

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

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

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

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

    if -1 < y < 1

    1. Initial program 99.9%

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

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

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

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

Alternative 6: 84.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-71} \lor \neg \left(z \leq 6 \cdot 10^{-120}\right):\\
\;\;\;\;y + \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.49999999999999988e-71 or 6.00000000000000022e-120 < z

    1. Initial program 78.6%

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

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

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

    if -8.49999999999999988e-71 < z < 6.00000000000000022e-120

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 7: 99.1% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\

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


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

    1. Initial program 71.0%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{z - x}{z}} \]
      2. div-sub98.9%

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

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

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

    if -1 < y < 1

    1. Initial program 99.9%

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

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

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

    if 1 < y

    1. Initial program 78.3%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{z - x}{z}} \]
      2. div-sub99.4%

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

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

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

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

        \[\leadsto \color{blue}{1 \cdot y + \left(-\frac{x}{z}\right) \cdot y} \]
      3. *-un-lft-identity99.5%

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

        \[\leadsto y + \color{blue}{\frac{x}{-z}} \cdot y \]
    7. Applied egg-rr99.5%

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

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

Alternative 8: 97.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.25 \cdot 10^{-289}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\

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


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

    1. Initial program 83.5%

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

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

    if -3.24999999999999987e-289 < y

    1. Initial program 88.4%

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

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

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

Alternative 9: 62.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-7}:\\
\;\;\;\;z \cdot \frac{y}{z}\\

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

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


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

    1. Initial program 71.4%

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

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

        \[\leadsto \frac{\color{blue}{z \cdot y}}{z} \]
      2. associate-/l*66.7%

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

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

    if -3.2000000000000001e-7 < y < 2.69999999999999996e-90

    1. Initial program 99.9%

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

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

    if 2.69999999999999996e-90 < y

    1. Initial program 82.1%

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

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

Alternative 10: 61.0% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.0499999999999999e-6 or 2.5000000000000001e-90 < y

    1. Initial program 76.5%

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

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

    if -2.0499999999999999e-6 < y < 2.5000000000000001e-90

    1. Initial program 99.9%

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

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

Alternative 11: 79.0% 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 85.7%

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

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

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

Alternative 12: 41.4% 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 85.7%

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

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

Developer target: 94.2% 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 2024101 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
  :precision binary64

  :alt
  (- (+ y (/ x z)) (/ y (/ z x)))

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