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

Percentage Accurate: 88.2% → 99.5%
Time: 9.1s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 88.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{+30} \lor \neg \left(y \leq 2.2 \cdot 10^{-6}\right):\\ \;\;\;\;y - y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -1.02e+30) (not (<= y 2.2e-6)))
   (- y (* y (/ x z)))
   (/ (fma y (- z x) x) z)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.02e+30) || !(y <= 2.2e-6)) {
		tmp = y - (y * (x / z));
	} else {
		tmp = fma(y, (z - x), x) / z;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1.02e+30) || !(y <= 2.2e-6))
		tmp = Float64(y - Float64(y * Float64(x / z)));
	else
		tmp = Float64(fma(y, Float64(z - x), x) / z);
	end
	return tmp
end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.02e+30], N[Not[LessEqual[y, 2.2e-6]], $MachinePrecision]], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(z - x), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.02 \cdot 10^{+30} \lor \neg \left(y \leq 2.2 \cdot 10^{-6}\right):\\
\;\;\;\;y - y \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.02e30 or 2.2000000000000001e-6 < y

    1. Initial program 74.2%

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(\frac{z}{z} - \frac{x}{z}\right)} \]
      3. *-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)} \]
    6. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

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

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

        \[\leadsto y \cdot 1 + \color{blue}{1 \cdot \frac{x \cdot y}{-z}} \]
      7. *-commutative89.9%

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

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

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

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

        \[\leadsto \color{blue}{y - \frac{x \cdot y}{z}} \]
      12. *-commutative89.9%

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

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

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

    if -1.02e30 < y < 2.2000000000000001e-6

    1. Initial program 99.9%

      \[\frac{x + y \cdot \left(z - x\right)}{z} \]
    2. Step-by-step derivation
      1. +-commutative99.9%

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, z - x, x\right)}}{z} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{+30} \lor \neg \left(y \leq 2.2 \cdot 10^{-6}\right):\\ \;\;\;\;y - y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.5% accurate, 0.5× speedup?

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

\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.9999999999999999e31 or 2.2000000000000001e-6 < y

    1. Initial program 74.2%

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(\frac{z}{z} - \frac{x}{z}\right)} \]
      3. *-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)} \]
    6. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

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

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

        \[\leadsto y \cdot 1 + \color{blue}{1 \cdot \frac{x \cdot y}{-z}} \]
      7. *-commutative89.9%

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

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

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

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

        \[\leadsto \color{blue}{y - \frac{x \cdot y}{z}} \]
      12. *-commutative89.9%

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

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

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

    if -1.9999999999999999e31 < y < 2.2000000000000001e-6

    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 -2 \cdot 10^{+31} \lor \neg \left(y \leq 2.2 \cdot 10^{-6}\right):\\ \;\;\;\;y - y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.0% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.6e9 or 2.2000000000000001e-6 < y

    1. Initial program 75.1%

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

      \[\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. *-inverses99.5%

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

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

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

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

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

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

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

        \[\leadsto y \cdot 1 + \color{blue}{1 \cdot \frac{x \cdot y}{-z}} \]
      7. *-commutative89.9%

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

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

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

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

        \[\leadsto \color{blue}{y - \frac{x \cdot y}{z}} \]
      12. *-commutative89.9%

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

        \[\leadsto y - \color{blue}{y \cdot \frac{x}{z}} \]
    7. Applied egg-rr99.5%

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

    if -1.6e9 < y < 2.2000000000000001e-6

    1. Initial program 99.9%

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

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

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

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

Alternative 4: 99.0% accurate, 0.5× speedup?

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

    1. Initial program 75.1%

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

      \[\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. *-inverses99.5%

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

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

    if -1.6e9 < y < 2.2000000000000001e-6

    1. Initial program 99.9%

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

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

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

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

Alternative 5: 84.4% accurate, 0.5× speedup?

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

    1. Initial program 88.3%

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

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

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

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

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

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

    if -4.3999999999999999e112 < x < 2.4e-78

    1. Initial program 84.8%

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

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

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

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

Alternative 6: 79.6% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y \leq 1.8 \cdot 10^{+84}:\\
\;\;\;\;y \cdot \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.5e5

    1. Initial program 92.9%

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

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

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

    if 6.5e5 < y < 1.8e84

    1. Initial program 80.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8e84 < y

    1. Initial program 66.6%

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

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

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

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

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

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

Alternative 7: 79.6% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 92.9%

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

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

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

    if 1.6e13 < y < 1.7499999999999999e84

    1. Initial program 80.8%

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

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

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

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

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

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

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

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

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

    if 1.7499999999999999e84 < y

    1. Initial program 66.6%

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

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

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

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

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

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

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

Alternative 8: 61.4% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 80.2%

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

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

    if -1.41999999999999998e-8 < y < 1.11999999999999996e-100

    1. Initial program 100.0%

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

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

    if 1.11999999999999996e-100 < y

    1. Initial program 76.3%

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - x\right)}{z}} \]
    4. Taylor expanded in z around inf 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*59.2%

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

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

Alternative 9: 60.7% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.00000000000000012e-9 or 8.6000000000000005e-110 < y

    1. Initial program 78.3%

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

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

    if -2.00000000000000012e-9 < y < 8.6000000000000005e-110

    1. Initial program 100.0%

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

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

Alternative 10: 79.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+57}:\\
\;\;\;\;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 < 2.0000000000000001e57

    1. Initial program 92.2%

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

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

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

    if 2.0000000000000001e57 < y

    1. Initial program 68.3%

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

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

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

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

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

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

Alternative 11: 41.0% 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 86.4%

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

    \[\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 2024160 
(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))