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

Percentage Accurate: 88.2% → 99.5%
Time: 8.9s
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: 88.2% 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.5% accurate, 0.5× speedup?

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

    1. Initial program 75.0%

      \[\frac{x + y \cdot \left(z - x\right)}{z} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 75.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. sub-neg99.9%

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

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

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

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

    if -9.99999999999999914e28 < y < 0.00339999999999999981

    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}\;y \leq -1 \cdot 10^{+29} \lor \neg \left(y \leq 0.0034\right):\\ \;\;\;\;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: 99.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -820000000000 \lor \neg \left(y \leq 0.0034\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 -820000000000.0) (not (<= y 0.0034)))
   (* y (- 1.0 (/ x z)))
   (+ y (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -820000000000.0) || !(y <= 0.0034)) {
		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 <= (-820000000000.0d0)) .or. (.not. (y <= 0.0034d0))) 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 <= -820000000000.0) || !(y <= 0.0034)) {
		tmp = y * (1.0 - (x / z));
	} else {
		tmp = y + (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -820000000000.0) or not (y <= 0.0034):
		tmp = y * (1.0 - (x / z))
	else:
		tmp = y + (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -820000000000.0) || !(y <= 0.0034))
		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 <= -820000000000.0) || ~((y <= 0.0034)))
		tmp = y * (1.0 - (x / z));
	else
		tmp = y + (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -820000000000.0], N[Not[LessEqual[y, 0.0034]], $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 -820000000000 \lor \neg \left(y \leq 0.0034\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 < -8.2e11 or 0.00339999999999999981 < y

    1. Initial program 75.2%

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

      \[\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. sub-neg99.9%

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

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

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

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

    if -8.2e11 < y < 0.00339999999999999981

    1. Initial program 99.9%

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

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

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

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

Alternative 3: 85.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9.8 \cdot 10^{+117} \lor \neg \left(x \leq 4.4 \cdot 10^{+111}\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 -9.8e+117) (not (<= x 4.4e+111)))
   (* x (/ (- 1.0 y) z))
   (+ y (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -9.8e+117) || !(x <= 4.4e+111)) {
		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 <= (-9.8d+117)) .or. (.not. (x <= 4.4d+111))) 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 <= -9.8e+117) || !(x <= 4.4e+111)) {
		tmp = x * ((1.0 - y) / z);
	} else {
		tmp = y + (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -9.8e+117) or not (x <= 4.4e+111):
		tmp = x * ((1.0 - y) / z)
	else:
		tmp = y + (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -9.8e+117) || !(x <= 4.4e+111))
		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 <= -9.8e+117) || ~((x <= 4.4e+111)))
		tmp = x * ((1.0 - y) / z);
	else
		tmp = y + (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.8e+117], N[Not[LessEqual[x, 4.4e+111]], $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 -9.8 \cdot 10^{+117} \lor \neg \left(x \leq 4.4 \cdot 10^{+111}\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 < -9.8000000000000002e117 or 4.39999999999999997e111 < x

    1. Initial program 89.5%

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

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

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

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

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

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

    if -9.8000000000000002e117 < x < 4.39999999999999997e111

    1. Initial program 86.7%

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

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

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

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

Alternative 4: 77.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+183} \lor \neg \left(y \leq 1.25 \cdot 10^{+211}\right):\\
\;\;\;\;-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 < -6.49999999999999983e183 or 1.2499999999999999e211 < y

    1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.49999999999999983e183 < y < 1.2499999999999999e211

    1. Initial program 90.4%

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

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

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

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

Alternative 5: 77.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{+184} \lor \neg \left(y \leq 1.1 \cdot 10^{+215}\right):\\
\;\;\;\;x \cdot \frac{y}{-z}\\

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


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

    1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

    if -2.3e184 < y < 1.1000000000000001e215

    1. Initial program 90.4%

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

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

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

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

Alternative 6: 77.3% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 70.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{y \cdot x}}{z} \]
      3. distribute-frac-neg269.1%

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

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

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

    if -1.99999999999999989e183 < y < 2.70000000000000009e214

    1. Initial program 90.4%

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

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

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

    if 2.70000000000000009e214 < y

    1. Initial program 80.3%

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

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

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

        \[\leadsto \frac{\color{blue}{-x \cdot y}}{z} \]
      2. distribute-lft-neg-out70.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+183}:\\ \;\;\;\;-y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+214}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{-z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 97.9% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 87.3%

      \[\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 1.80000000000000003e-281 < y

    1. Initial program 87.8%

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

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

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

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

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

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

        \[\leadsto y + x \cdot \color{blue}{\frac{1 - y}{z}} \]
    6. Simplified97.0%

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

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

Alternative 8: 62.7% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 76.8%

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

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

    if -2.6999999999999999e-14 < y < 1.1400000000000001e-4

    1. Initial program 99.9%

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

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

    if 1.1400000000000001e-4 < y

    1. Initial program 75.0%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \frac{y}{z}} \]
    6. Applied egg-rr63.1%

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

Alternative 9: 98.0% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

    if -6.7999999999999996e47 < y

    1. Initial program 90.5%

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

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

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

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

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

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

        \[\leadsto y + x \cdot \color{blue}{\frac{1 - y}{z}} \]
    6. Simplified97.9%

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

Alternative 10: 60.8% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.5000000000000002e-14 or 4.5e-78 < y

    1. Initial program 78.7%

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

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

    if -3.5000000000000002e-14 < y < 4.5e-78

    1. Initial program 100.0%

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

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

Alternative 11: 79.2% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 89.1%

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

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

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

    if 3.19999999999999985e172 < y

    1. Initial program 77.0%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \frac{y}{z}} \]
    6. Applied egg-rr57.0%

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

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

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

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

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

  :alt
  (! :herbie-platform default (- (+ y (/ x z)) (/ y (/ z x))))

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