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

Percentage Accurate: 88.1% → 99.9%
Time: 8.5s
Alternatives: 13
Speedup: 0.8×

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 13 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.1% 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, 0.7× speedup?

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

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

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

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


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

    1. Initial program 85.9%

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

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

    if -2.0000000000000001e-209 < y < 8.4e11

    1. Initial program 99.9%

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

    if 8.4e11 < y

    1. Initial program 74.3%

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

      \[\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}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-209}:\\ \;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\ \mathbf{elif}\;y \leq 840000000000:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \end{array} \]

Alternative 2: 59.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+155}:\\
\;\;\;\;y\\

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

\mathbf{elif}\;y \leq -1.85 \cdot 10^{-13}:\\
\;\;\;\;y\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.50000000000000046e155 or -1.9000000000000001e79 < y < -1.84999999999999994e-13

    1. Initial program 65.9%

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

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

    if -6.50000000000000046e155 < y < -1.9000000000000001e79 or -1.84999999999999994e-13 < y < 5.8e-4

    1. Initial program 99.9%

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

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

    if 5.8e-4 < y

    1. Initial program 75.6%

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

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

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot z} \]
    4. Applied egg-rr49.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+155}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -1.9 \cdot 10^{+79}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq -1.85 \cdot 10^{-13}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 0.00058:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{z}\\ \end{array} \]

Alternative 3: 99.8% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 68.7%

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

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

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

    if -3.4e19 < y < 8.4e11

    1. Initial program 99.9%

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

    if 8.4e11 < y

    1. Initial program 74.3%

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

      \[\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}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.4 \cdot 10^{+19}:\\ \;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\ \mathbf{elif}\;y \leq 840000000000:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \end{array} \]

Alternative 4: 98.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\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 -1e-309)
   (+ (/ 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 <= -1e-309) {
		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 <= (-1d-309)) 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 <= -1e-309) {
		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 <= -1e-309:
		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 <= -1e-309)
		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 <= -1e-309)
		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, -1e-309], 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 -1 \cdot 10^{-309}:\\
\;\;\;\;\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 < -1.000000000000002e-309

    1. Initial program 88.6%

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

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

    if -1.000000000000002e-309 < y

    1. Initial program 88.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\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} \]

Alternative 5: 76.5% accurate, 0.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.2000000000000004e156 or -3.80000000000000011e87 < y < 1.6499999999999999e122

    1. Initial program 91.8%

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

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

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

    if -6.2000000000000004e156 < y < -3.80000000000000011e87 or 1.6499999999999999e122 < y

    1. Initial program 75.6%

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

      \[\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 68.9%

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

        \[\leadsto \frac{y}{\color{blue}{-\frac{z}{x}}} \]
      2. distribute-neg-frac68.9%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{+156} \lor \neg \left(y \leq -3.8 \cdot 10^{+87}\right) \land y \leq 1.65 \cdot 10^{+122}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{-x}{z}\\ \end{array} \]

Alternative 6: 76.5% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;y \leq 1.12 \cdot 10^{+121}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.1e157 or -1.95000000000000005e89 < y < 1.12e121

    1. Initial program 91.8%

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

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

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

    if -2.1e157 < y < -1.95000000000000005e89

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.12e121 < y

    1. Initial program 67.7%

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

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

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

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

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

        \[\leadsto \frac{y}{\color{blue}{-\frac{z}{x}}} \]
      2. distribute-neg-frac63.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+157}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq -1.95 \cdot 10^{+89}:\\ \;\;\;\;y \cdot \frac{-x}{z}\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{+121}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{-z}{x}}\\ \end{array} \]

Alternative 7: 58.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+155}:\\
\;\;\;\;y\\

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

\mathbf{elif}\;y \leq -5.2 \cdot 10^{-13}:\\
\;\;\;\;y\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.50000000000000046e155 or -2.1000000000000001e78 < y < -5.2000000000000001e-13 or 7.5000000000000002e-4 < y

    1. Initial program 71.4%

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

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

    if -6.50000000000000046e155 < y < -2.1000000000000001e78 or -5.2000000000000001e-13 < y < 7.5000000000000002e-4

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+155}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -2.1 \cdot 10^{+78}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-13}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 0.00075:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]

Alternative 8: 85.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+145} \lor \neg \left(x \leq 3.1 \cdot 10^{+68}\right):\\
\;\;\;\;\frac{x}{z} \cdot \left(1 - y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.7e145 or 3.0999999999999998e68 < x

    1. Initial program 87.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 - y}{\frac{z}{x}}} \]
    5. Step-by-step derivation
      1. div-inv93.1%

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

        \[\leadsto \left(1 - y\right) \cdot \color{blue}{\frac{x}{z}} \]
    6. Applied egg-rr93.2%

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

    if -1.7e145 < x < 3.0999999999999998e68

    1. Initial program 89.2%

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

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

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

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

Alternative 9: 99.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.52 \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.52) (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.52) || !(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.52d0)) .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.52) || !(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.52) 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.52) || !(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.52) || ~((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.52], 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.52 \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.52 or 1 < y

    1. Initial program 73.5%

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

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

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

    if -1.52 < y < 1

    1. Initial program 99.9%

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

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

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

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

Alternative 10: 99.2% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 72.2%

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

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

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

    if -1.52 < y < 1

    1. Initial program 99.9%

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

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

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

    if 1 < y

    1. Initial program 74.7%

      \[\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. associate-/l*99.0%

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

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

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

Alternative 11: 78.9% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.4 \cdot 10^{+146}:\\
\;\;\;\;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 < 6.3999999999999999e146

    1. Initial program 91.3%

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

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

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

    if 6.3999999999999999e146 < y

    1. Initial program 67.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6.4 \cdot 10^{+146}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{z}\\ \end{array} \]

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

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

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

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

    if 1 < y

    1. Initial program 74.7%

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

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

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

        \[\leadsto \color{blue}{y + \frac{x}{z}} \]
      2. *-un-lft-identity43.3%

        \[\leadsto \color{blue}{1 \cdot y} + \frac{x}{z} \]
      3. fma-def43.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{1 \cdot y - \frac{x}{z}} \]
      12. *-un-lft-identity57.8%

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

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

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

Alternative 13: 40.9% 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 88.7%

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

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

    \[\leadsto y \]

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 2023240 
(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))