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

Percentage Accurate: 88.1% → 97.5%
Time: 7.9s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 88.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: 97.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;y + x \cdot \frac{1 - y}{z}\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+264}:\\ \;\;\;\;y + \left(\frac{x}{z} - \frac{x \cdot y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (+ x (* y (- z x))) z)))
   (if (<= t_0 (- INFINITY))
     (+ y (* x (/ (- 1.0 y) z)))
     (if (<= t_0 5e+264)
       (+ y (- (/ x z) (/ (* x y) z)))
       (* y (- 1.0 (/ x z)))))))
double code(double x, double y, double z) {
	double t_0 = (x + (y * (z - x))) / z;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = y + (x * ((1.0 - y) / z));
	} else if (t_0 <= 5e+264) {
		tmp = y + ((x / z) - ((x * y) / z));
	} else {
		tmp = y * (1.0 - (x / z));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = (x + (y * (z - x))) / z;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = y + (x * ((1.0 - y) / z));
	} else if (t_0 <= 5e+264) {
		tmp = y + ((x / z) - ((x * y) / z));
	} else {
		tmp = y * (1.0 - (x / z));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x + (y * (z - x))) / z
	tmp = 0
	if t_0 <= -math.inf:
		tmp = y + (x * ((1.0 - y) / z))
	elif t_0 <= 5e+264:
		tmp = y + ((x / z) - ((x * y) / z))
	else:
		tmp = y * (1.0 - (x / z))
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x + Float64(y * Float64(z - x))) / z)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z)));
	elseif (t_0 <= 5e+264)
		tmp = Float64(y + Float64(Float64(x / z) - Float64(Float64(x * y) / z)));
	else
		tmp = Float64(y * Float64(1.0 - Float64(x / z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x + (y * (z - x))) / z;
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = y + (x * ((1.0 - y) / z));
	elseif (t_0 <= 5e+264)
		tmp = y + ((x / z) - ((x * y) / z));
	else
		tmp = y * (1.0 - (x / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+264], N[(y + N[(N[(x / z), $MachinePrecision] - N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+264}:\\
\;\;\;\;y + \left(\frac{x}{z} - \frac{x \cdot y}{z}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < -inf.0

    1. Initial program 74.3%

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 5.00000000000000033e264

    1. Initial program 99.8%

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

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

    if 5.00000000000000033e264 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z)

    1. Initial program 53.0%

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

      \[\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-sub100.0%

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

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

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

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

Alternative 2: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -56000000000000 \lor \neg \left(y \leq 9.4 \cdot 10^{+23}\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 -56000000000000.0) (not (<= y 9.4e+23)))
   (* y (- 1.0 (/ x z)))
   (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -56000000000000.0) || !(y <= 9.4e+23)) {
		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 <= (-56000000000000.0d0)) .or. (.not. (y <= 9.4d+23))) 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 <= -56000000000000.0) || !(y <= 9.4e+23)) {
		tmp = y * (1.0 - (x / z));
	} else {
		tmp = (x + (y * (z - x))) / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -56000000000000.0) or not (y <= 9.4e+23):
		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 <= -56000000000000.0) || !(y <= 9.4e+23))
		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 <= -56000000000000.0) || ~((y <= 9.4e+23)))
		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, -56000000000000.0], N[Not[LessEqual[y, 9.4e+23]], $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 -56000000000000 \lor \neg \left(y \leq 9.4 \cdot 10^{+23}\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 < -5.6e13 or 9.3999999999999994e23 < y

    1. Initial program 74.5%

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

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

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

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

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

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

    if -5.6e13 < y < 9.3999999999999994e23

    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 -56000000000000 \lor \neg \left(y \leq 9.4 \cdot 10^{+23}\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 3: 84.6% accurate, 0.5× speedup?

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

    1. Initial program 89.3%

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

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

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

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

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

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

    if -5.8e-21 < x < 9.79999999999999934e-6

    1. Initial program 84.7%

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

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

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

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

Alternative 4: 98.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 76.6%

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

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

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

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

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

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

    if -1 < y < 2.44999999999999997e-14

    1. Initial program 99.9%

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

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

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

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

Alternative 5: 97.9% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1e-27

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \frac{1}{\frac{z}{\mathsf{fma}\left(\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}, y, x\right)}} \]
      13. sqr-neg69.2%

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

        \[\leadsto y + \frac{1}{\frac{z}{\mathsf{fma}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}, y, x\right)}} \]
      15. add-sqr-sqrt63.2%

        \[\leadsto y + \frac{1}{\frac{z}{\mathsf{fma}\left(\color{blue}{x}, y, x\right)}} \]
    8. Applied egg-rr63.2%

      \[\leadsto y + \color{blue}{\frac{1}{\frac{z}{\mathsf{fma}\left(x, y, x\right)}}} \]
    9. Step-by-step derivation
      1. /-rgt-identity63.2%

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

        \[\leadsto y + \frac{1}{\color{blue}{\frac{1}{\frac{1}{\frac{z}{\mathsf{fma}\left(x, y, x\right)}}}}} \]
      3. associate-/r/63.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \frac{1}{\frac{1}{\frac{x}{z} \cdot 1 + \left(-\color{blue}{\left(\frac{1}{z} \cdot x\right) \cdot y}\right)}} \]
    10. Applied egg-rr98.0%

      \[\leadsto y + \frac{1}{\color{blue}{z \cdot \frac{\frac{1}{1 - y}}{x}}} \]
    11. Step-by-step derivation
      1. associate-/l/97.9%

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

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

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

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

    if 1e-27 < z

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

Alternative 6: 97.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+65}:\\ \;\;\;\;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 -2e+65) (* y (- 1.0 (/ x z))) (+ y (* x (/ (- 1.0 y) z)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e+65) {
		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 <= (-2d+65)) 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 <= -2e+65) {
		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 <= -2e+65:
		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 <= -2e+65)
		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 <= -2e+65)
		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, -2e+65], 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 -2 \cdot 10^{+65}:\\
\;\;\;\;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 < -2e65

    1. Initial program 77.4%

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

      \[\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-sub100.0%

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

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

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

    if -2e65 < y

    1. Initial program 89.7%

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

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

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

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

Alternative 7: 57.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.1 \cdot 10^{-27} \lor \neg \left(x \leq 1.5 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.0999999999999999e-27 or 1.49999999999999987e-8 < x

    1. Initial program 89.0%

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

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

    if -6.0999999999999999e-27 < x < 1.49999999999999987e-8

    1. Initial program 84.8%

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

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

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

Alternative 8: 80.9% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 93.0%

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

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

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

    if 2.44999999999999997e-14 < y

    1. Initial program 73.8%

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

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

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

        \[\leadsto y + \frac{x}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      2. sqrt-unprod62.5%

        \[\leadsto y + \frac{x}{\color{blue}{\sqrt{z \cdot z}}} \]
      3. sqr-neg62.5%

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

        \[\leadsto y + \frac{x}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \]
      5. add-sqr-sqrt72.3%

        \[\leadsto y + \frac{x}{\color{blue}{-z}} \]
      6. distribute-neg-frac272.3%

        \[\leadsto y + \color{blue}{\left(-\frac{x}{z}\right)} \]
      7. sub-neg72.3%

        \[\leadsto \color{blue}{y - \frac{x}{z}} \]
    6. Applied egg-rr72.3%

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

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

Alternative 9: 78.1% accurate, 1.8× speedup?

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

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

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

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

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

    \[\leadsto y + \frac{x}{z} \]
  6. Add Preprocessing

Alternative 10: 39.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.1%

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

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

    \[\leadsto y \]
  5. Add Preprocessing

Developer target: 94.2% accurate, 0.8× speedup?

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

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

Reproduce

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

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

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