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

Percentage Accurate: 88.2% → 99.7%
Time: 7.8s
Alternatives: 12
Speedup: 0.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 88.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% 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 \lor \neg \left(t\_0 \leq 10^{+294}\right):\\ \;\;\;\;y + x \cdot \frac{1 - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} + 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 (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+294)))
     (+ y (* x (/ (- 1.0 y) z)))
     (+ (/ x 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)) || !(t_0 <= 1e+294)) {
		tmp = y + (x * ((1.0 - y) / z));
	} else {
		tmp = (x / z) + (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) || !(t_0 <= 1e+294)) {
		tmp = y + (x * ((1.0 - y) / z));
	} else {
		tmp = (x / z) + (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) or not (t_0 <= 1e+294):
		tmp = y + (x * ((1.0 - y) / z))
	else:
		tmp = (x / z) + (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)) || !(t_0 <= 1e+294))
		tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z)));
	else
		tmp = Float64(Float64(x / z) + 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) || ~((t_0 <= 1e+294)))
		tmp = y + (x * ((1.0 - y) / z));
	else
		tmp = (x / z) + (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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e+294]], $MachinePrecision]], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $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 \lor \neg \left(t\_0 \leq 10^{+294}\right):\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\

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


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

    1. Initial program 72.5%

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

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

      \[\leadsto \color{blue}{y + 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 \color{blue}{y + x \cdot \frac{1 - y}{z}} \]

    if -inf.0 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 1.00000000000000007e294

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{y \cdot \left(1 - \frac{x}{z}\right) + \frac{x}{z}} \]
  3. Recombined 2 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 \lor \neg \left(\frac{x + y \cdot \left(z - x\right)}{z} \leq 10^{+294}\right):\\ \;\;\;\;y + x \cdot \frac{1 - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+28} \lor \neg \left(y \leq 880\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 < -1.9499999999999999e28 or 880 < y

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

    if -1.9499999999999999e28 < y < 880

    1. Initial program 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.95 \cdot 10^{+28} \lor \neg \left(y \leq 880\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: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+50} \lor \neg \left(y \leq 880\right):\\ \;\;\;\;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 (or (<= y -5e+50) (not (<= y 880.0)))
   (* y (- 1.0 (/ x z)))
   (+ y (* x (/ (- 1.0 y) z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5e+50) || !(y <= 880.0)) {
		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 <= (-5d+50)) .or. (.not. (y <= 880.0d0))) 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 <= -5e+50) || !(y <= 880.0)) {
		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 <= -5e+50) or not (y <= 880.0):
		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 <= -5e+50) || !(y <= 880.0))
		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 <= -5e+50) || ~((y <= 880.0)))
		tmp = y * (1.0 - (x / z));
	else
		tmp = y + (x * ((1.0 - y) / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -5e+50], N[Not[LessEqual[y, 880.0]], $MachinePrecision]], 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 -5 \cdot 10^{+50} \lor \neg \left(y \leq 880\right):\\
\;\;\;\;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 < -5e50 or 880 < y

    1. Initial program 81.6%

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

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

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

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

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

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

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

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

    if -5e50 < y < 880

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

Alternative 4: 99.1% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 83.3%

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

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

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

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

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

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

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

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

    if -1 < y < 1

    1. Initial program 99.9%

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

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

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

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

Alternative 5: 84.8% accurate, 0.5× speedup?

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

    1. Initial program 91.2%

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

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

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

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

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

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

    if -8.00000000000000046e84 < x < 2.3499999999999999e-29

    1. Initial program 91.6%

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

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

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

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

Alternative 6: 62.8% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.4499999999999999e-10 or 7.99999999999999952e-11 < y

    1. Initial program 83.9%

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

      \[\leadsto \frac{x + \color{blue}{y \cdot z}}{z} \]
    4. Taylor expanded in x around 0 36.4%

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

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

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

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

    if -1.4499999999999999e-10 < y < 7.99999999999999952e-11

    1. Initial program 99.9%

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

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

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

Alternative 7: 75.6% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 89.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.99999999999999958e29 < y < 900

    1. Initial program 99.9%

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

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

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

    if 900 < y

    1. Initial program 75.8%

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

      \[\leadsto \frac{x + \color{blue}{y \cdot z}}{z} \]
    4. Taylor expanded in x around inf 36.3%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot y}{x}} \]
    9. Applied egg-rr65.0%

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

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

Alternative 8: 74.6% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 89.8%

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

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

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

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

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

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

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

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

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

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

    if -2.32e30 < y < 900

    1. Initial program 99.9%

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

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

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

    if 900 < y

    1. Initial program 75.8%

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

      \[\leadsto \frac{x + \color{blue}{y \cdot z}}{z} \]
    4. Taylor expanded in x around inf 36.3%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot y}{x}} \]
    9. Applied egg-rr65.0%

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

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

Alternative 9: 61.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{-13}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.1e-13) y (if (<= y 9e-11) (/ x z) y)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.1e-13) {
		tmp = y;
	} else if (y <= 9e-11) {
		tmp = x / z;
	} else {
		tmp = y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-3.1d-13)) then
        tmp = y
    else if (y <= 9d-11) then
        tmp = x / z
    else
        tmp = y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.1e-13) {
		tmp = y;
	} else if (y <= 9e-11) {
		tmp = x / z;
	} else {
		tmp = y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -3.1e-13:
		tmp = y
	elif y <= 9e-11:
		tmp = x / z
	else:
		tmp = y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.1e-13)
		tmp = y;
	elseif (y <= 9e-11)
		tmp = Float64(x / z);
	else
		tmp = y;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -3.1e-13)
		tmp = y;
	elseif (y <= 9e-11)
		tmp = x / z;
	else
		tmp = y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -3.1e-13], y, If[LessEqual[y, 9e-11], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.0999999999999999e-13 or 8.9999999999999999e-11 < y

    1. Initial program 83.9%

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

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

    if -3.0999999999999999e-13 < y < 8.9999999999999999e-11

    1. Initial program 99.9%

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

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

Alternative 10: 79.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 900:\\
\;\;\;\;y + \frac{x}{z}\\

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


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

    1. Initial program 96.9%

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

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

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

    if 900 < y

    1. Initial program 75.8%

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

      \[\leadsto \frac{x + \color{blue}{y \cdot z}}{z} \]
    4. Taylor expanded in x around inf 36.3%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot y}{x}} \]
    9. Applied egg-rr65.0%

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

Alternative 11: 79.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;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 < 1

    1. Initial program 96.9%

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

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

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

    if 1 < y

    1. Initial program 76.2%

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

      \[\leadsto \frac{x + \color{blue}{y \cdot z}}{z} \]
    4. Taylor expanded in x around 0 37.8%

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

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

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

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

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

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

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

Developer Target 1: 94.1% accurate, 0.8× speedup?

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

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

Reproduce

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

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

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