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

Percentage Accurate: 87.6% → 99.9%
Time: 9.6s
Alternatives: 11
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 11 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.6% 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.9% accurate, 1.0× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{y - \frac{y \cdot x + -1 \cdot x}{z}} \]
    3. distribute-rgt-out95.9%

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

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

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

    \[\leadsto \color{blue}{y - \frac{x}{\frac{z}{-1 + y}}} \]
  6. Taylor expanded in x around 0 95.9%

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

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

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

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

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

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

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

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

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

Alternative 2: 85.6% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.0999999999999999e-15 or 7.8000000000000007e-62 < z

    1. Initial program 76.4%

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

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

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

    if -3.0999999999999999e-15 < z < 7.8000000000000007e-62

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \color{blue}{y - \frac{y \cdot x + -1 \cdot x}{z}} \]
      3. distribute-rgt-out99.9%

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

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

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

      \[\leadsto \color{blue}{y - \frac{x}{\frac{z}{-1 + y}}} \]
    6. Taylor expanded in x around 0 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{z} \cdot \color{blue}{\left(\left(0 - -1\right) - y\right)} \]
      10. metadata-eval89.8%

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

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

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

Alternative 3: 99.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y \cdot \frac{z - x}{z}\\ \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 (/ (- z x) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.0) || !(y <= 1.0)) {
		tmp = y * ((z - 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 * ((z - 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 * ((z - 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 * ((z - 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(Float64(z - 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 * ((z - 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[(N[(z - x), $MachinePrecision] / z), $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 \frac{z - x}{z}\\

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

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

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

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

        \[\leadsto \color{blue}{\frac{z - x}{\frac{z}{y}}} \]
      3. associate-/r/99.2%

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

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

    if -1 < y < 1

    1. Initial program 99.9%

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

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

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

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

Alternative 4: 75.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+122} \lor \neg \left(y \leq 4.9 \cdot 10^{+225}\right):\\
\;\;\;\;\frac{y}{z} \cdot \left(-x\right)\\

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


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

    1. Initial program 79.9%

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

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

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

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

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

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

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

    if -7.7999999999999999e122 < y < 4.90000000000000032e225

    1. Initial program 90.2%

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

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

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

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

Alternative 5: 75.5% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;y \leq 1.1 \cdot 10^{+225}:\\
\;\;\;\;y + \frac{x}{z}\\

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


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

    1. Initial program 83.0%

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

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

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

        \[\leadsto \color{blue}{\frac{z - x}{\frac{z}{y}}} \]
      3. associate-/r/99.9%

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

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

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

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

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

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

    if -3.59999999999999998e123 < y < 1.10000000000000007e225

    1. Initial program 90.2%

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

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

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

    if 1.10000000000000007e225 < y

    1. Initial program 71.4%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{+123}:\\ \;\;\;\;y \cdot \left(-\frac{x}{z}\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+225}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \left(-x\right)\\ \end{array} \]

Alternative 6: 75.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.06 \cdot 10^{+123}:\\
\;\;\;\;\frac{y}{\frac{-z}{x}}\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{+225}:\\
\;\;\;\;y + \frac{x}{z}\\

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


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

    1. Initial program 83.0%

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

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

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

      \[\leadsto \color{blue}{\frac{y}{\frac{z}{z - x}}} \]
    5. Taylor expanded in z around 0 66.0%

      \[\leadsto \frac{y}{\color{blue}{-1 \cdot \frac{z}{x}}} \]
    6. Step-by-step derivation
      1. mul-1-neg66.0%

        \[\leadsto \frac{y}{\color{blue}{-\frac{z}{x}}} \]
    7. Simplified66.0%

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

    if -1.06e123 < y < 1.30000000000000002e225

    1. Initial program 90.2%

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

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

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

    if 1.30000000000000002e225 < y

    1. Initial program 71.4%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.06 \cdot 10^{+123}:\\ \;\;\;\;\frac{y}{\frac{-z}{x}}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+225}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \left(-x\right)\\ \end{array} \]

Alternative 7: 63.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{-34} \lor \neg \left(y \leq 0.0029\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\

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


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

    1. Initial program 76.3%

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{z}}} \]
      2. associate-/r/55.3%

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

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

    if -3.60000000000000008e-34 < y < 0.0029

    1. Initial program 99.9%

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

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

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

Alternative 8: 61.5% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 76.3%

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

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

    if -3.1999999999999998e-35 < y < 0.0025999999999999999

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{-35}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 0.0026:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]

Alternative 9: 81.7% 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 93.1%

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

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

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

    if 1 < y

    1. Initial program 65.4%

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

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

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

        \[\leadsto y + \color{blue}{x \cdot \frac{1}{z}} \]
      2. add-sqr-sqrt28.9%

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

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

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

        \[\leadsto y + \color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot \frac{1}{z} \]
      6. add-sqr-sqrt56.2%

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

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

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

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

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

Alternative 10: 78.1% 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 87.8%

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

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

    \[\leadsto \color{blue}{y} + \frac{x}{z} \]
  4. Final simplification77.1%

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

Alternative 11: 40.5% 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 87.8%

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

    \[\leadsto \color{blue}{y} \]
  3. Final simplification35.8%

    \[\leadsto y \]

Developer target: 94.1% 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 2023182 
(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))