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

Percentage Accurate: 88.7% → 99.7%
Time: 8.0s
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.7% 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.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+66} \lor \neg \left(y \leq 30000\right):\\
\;\;\;\;y \cdot \frac{z - x}{z}\\

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


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

    1. Initial program 75.3%

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

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

    if -4.99999999999999991e66 < y < 3e4

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.3% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 76.4%

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

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

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

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

    if -4.20000000000000009e36 < y < 1

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 85.6% accurate, 0.5× speedup?

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

    1. Initial program 89.2%

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

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

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

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

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

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

    if -1.04999999999999996e-17 < x < 9.60000000000000004e120

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.3% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 75.7%

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

      \[\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}} \]
    5. Simplified99.8%

      \[\leadsto \color{blue}{y \cdot \frac{z - x}{z}} \]
    6. Step-by-step derivation
      1. clear-num99.8%

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

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

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

    if -4.20000000000000009e36 < y < 1

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

    if 1 < y

    1. Initial program 76.9%

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

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

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

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

Alternative 5: 58.5% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.80000000000000007e82 or 2.15e-39 < y

    1. Initial program 77.4%

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

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

    if -1.80000000000000007e82 < y < 2.15e-39

    1. Initial program 98.6%

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

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

Alternative 6: 77.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 3.69999999999999998e239

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

    if 3.69999999999999998e239 < x

    1. Initial program 77.9%

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

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

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

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

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{z - x}}} \]
      2. un-div-inv88.1%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{z - x}}} \]
    7. Applied egg-rr88.1%

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

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

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

        \[\leadsto \frac{y}{\frac{\color{blue}{-z}}{x}} \]
    10. Simplified86.3%

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

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

Alternative 7: 77.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 8.6000000000000008e239

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

    if 8.6000000000000008e239 < x

    1. Initial program 77.9%

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

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

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

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

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

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

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

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

Alternative 8: 77.4% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 3.10000000000000001e239

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

    if 3.10000000000000001e239 < x

    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 81.6% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 93.6%

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

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

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

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

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

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

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

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

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

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

    if 1 < y

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto y + \color{blue}{\frac{x}{z}} \]
    8. Step-by-step derivation
      1. frac-2neg54.6%

        \[\leadsto y + \color{blue}{\frac{-x}{-z}} \]
      2. div-inv54.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{y - x \cdot \frac{1}{z}} \]
      9. div-inv65.3%

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

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

Alternative 10: 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 89.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto y + \color{blue}{\frac{x}{z}} \]
  8. Add Preprocessing

Alternative 11: 40.5% 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 89.4%

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

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

Developer Target 1: 93.9% 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 2024182 
(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))