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

Percentage Accurate: 88.1% → 99.6%
Time: 9.4s
Alternatives: 12
Speedup: 0.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 80.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}} \]

    if -3.9999999999999999e-223 < y < 7.79999999999999986e-4

    1. Initial program 100.0%

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

    if 7.79999999999999986e-4 < y

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \frac{y}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \cdot x \]
      3. sqrt-unprod65.0%

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

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

        \[\leadsto y + \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \cdot x \]
      6. add-sqr-sqrt45.7%

        \[\leadsto y + \frac{y}{\color{blue}{z}} \cdot x \]
      7. cancel-sign-sub45.7%

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

        \[\leadsto y - \color{blue}{\frac{y}{-z}} \cdot x \]
      9. associate-*l/43.3%

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

        \[\leadsto y - \frac{\color{blue}{x \cdot y}}{-z} \]
      11. add-sqr-sqrt20.4%

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

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}} \]
      13. sqr-neg62.8%

        \[\leadsto y - \frac{x \cdot y}{\sqrt{\color{blue}{z \cdot z}}} \]
      14. sqrt-unprod46.7%

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      15. add-sqr-sqrt91.8%

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{z}} \]
      16. associate-*l/100.0%

        \[\leadsto y - \color{blue}{\frac{x}{z} \cdot y} \]
      17. *-commutative100.0%

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

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

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

Alternative 2: 79.0% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;y \leq 8.2 \cdot 10^{+275}:\\
\;\;\;\;z \cdot \frac{y}{z}\\

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


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

    1. Initial program 88.6%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    6. Simplified87.6%

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

    if 1.7000000000000001e26 < y < 3.70000000000000004e112

    1. Initial program 95.1%

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \frac{\color{blue}{-y}}{z} \]
    9. Step-by-step derivation
      1. distribute-frac-neg64.3%

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

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

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

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      5. associate-*l/69.0%

        \[\leadsto -\color{blue}{\frac{x}{z} \cdot y} \]
      6. *-commutative69.0%

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
    10. Applied egg-rr69.0%

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

    if 3.70000000000000004e112 < y < 8.1999999999999994e275

    1. Initial program 70.8%

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot y}}{z} \]
    6. Simplified33.4%

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

        \[\leadsto \color{blue}{z \cdot \frac{y}{z}} \]
      2. *-commutative64.4%

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

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

    if 8.1999999999999994e275 < y

    1. Initial program 75.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.7 \cdot 10^{+26}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+112}:\\ \;\;\;\;y \cdot \frac{-x}{z}\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+275}:\\ \;\;\;\;z \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-\frac{y}{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.6% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 66.9%

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

      \[\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 -4e14 < y < 7.79999999999999986e-4

    1. Initial program 99.9%

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

    if 7.79999999999999986e-4 < y

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \frac{y}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \cdot x \]
      3. sqrt-unprod65.0%

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

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

        \[\leadsto y + \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \cdot x \]
      6. add-sqr-sqrt45.7%

        \[\leadsto y + \frac{y}{\color{blue}{z}} \cdot x \]
      7. cancel-sign-sub45.7%

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

        \[\leadsto y - \color{blue}{\frac{y}{-z}} \cdot x \]
      9. associate-*l/43.3%

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

        \[\leadsto y - \frac{\color{blue}{x \cdot y}}{-z} \]
      11. add-sqr-sqrt20.4%

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

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}} \]
      13. sqr-neg62.8%

        \[\leadsto y - \frac{x \cdot y}{\sqrt{\color{blue}{z \cdot z}}} \]
      14. sqrt-unprod46.7%

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      15. add-sqr-sqrt91.8%

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{z}} \]
      16. associate-*l/100.0%

        \[\leadsto y - \color{blue}{\frac{x}{z} \cdot y} \]
      17. *-commutative100.0%

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

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

Alternative 4: 99.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -370000000000 \lor \neg \left(y \leq 0.00078\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 -370000000000.0) (not (<= y 0.00078)))
   (* y (/ (- z x) z))
   (+ y (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -370000000000.0) || !(y <= 0.00078)) {
		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 <= (-370000000000.0d0)) .or. (.not. (y <= 0.00078d0))) 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 <= -370000000000.0) || !(y <= 0.00078)) {
		tmp = y * ((z - x) / z);
	} else {
		tmp = y + (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -370000000000.0) or not (y <= 0.00078):
		tmp = y * ((z - x) / z)
	else:
		tmp = y + (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -370000000000.0) || !(y <= 0.00078))
		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 <= -370000000000.0) || ~((y <= 0.00078)))
		tmp = y * ((z - x) / z);
	else
		tmp = y + (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -370000000000.0], N[Not[LessEqual[y, 0.00078]], $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 -370000000000 \lor \neg \left(y \leq 0.00078\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 < -3.7e11 or 7.79999999999999986e-4 < 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}} \]
    5. Simplified99.9%

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

    if -3.7e11 < y < 7.79999999999999986e-4

    1. Initial program 99.9%

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

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

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

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

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

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

Alternative 5: 85.4% accurate, 0.5× speedup?

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

    1. Initial program 87.6%

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

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

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

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

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

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

    if -2.65000000000000003e101 < x < 2.04999999999999993e-19

    1. Initial program 85.3%

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

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

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

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

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

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

Alternative 6: 99.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -370000000000:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\

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

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


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

    1. Initial program 66.9%

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

      \[\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 -3.7e11 < y < 7.79999999999999986e-4

    1. Initial program 99.9%

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

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

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

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

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

    if 7.79999999999999986e-4 < y

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \frac{y}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \cdot x \]
      3. sqrt-unprod65.0%

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

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

        \[\leadsto y + \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \cdot x \]
      6. add-sqr-sqrt45.7%

        \[\leadsto y + \frac{y}{\color{blue}{z}} \cdot x \]
      7. cancel-sign-sub45.7%

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

        \[\leadsto y - \color{blue}{\frac{y}{-z}} \cdot x \]
      9. associate-*l/43.3%

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

        \[\leadsto y - \frac{\color{blue}{x \cdot y}}{-z} \]
      11. add-sqr-sqrt20.4%

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

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}} \]
      13. sqr-neg62.8%

        \[\leadsto y - \frac{x \cdot y}{\sqrt{\color{blue}{z \cdot z}}} \]
      14. sqrt-unprod46.7%

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      15. add-sqr-sqrt91.8%

        \[\leadsto y - \frac{x \cdot y}{\color{blue}{z}} \]
      16. associate-*l/100.0%

        \[\leadsto y - \color{blue}{\frac{x}{z} \cdot y} \]
      17. *-commutative100.0%

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

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

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

Alternative 7: 97.7% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 83.9%

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

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

    if 5.1999999999999999e-286 < y

    1. Initial program 89.2%

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

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

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

Alternative 8: 61.1% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{-106} \lor \neg \left(y \leq 4.8 \cdot 10^{-21}\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 < -3.00000000000000019e-106 or 4.7999999999999999e-21 < y

    1. Initial program 78.5%

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

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \frac{y}{z}} \]
      2. *-commutative55.1%

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

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

    if -3.00000000000000019e-106 < y < 4.7999999999999999e-21

    1. Initial program 100.0%

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

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

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

Alternative 9: 59.3% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.00000000000000019e-106 or 1.40000000000000001e-19 < y

    1. Initial program 78.5%

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

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

    if -3.00000000000000019e-106 < y < 1.40000000000000001e-19

    1. Initial program 100.0%

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

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

Alternative 10: 78.8% accurate, 0.8× speedup?

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

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


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

    1. Initial program 88.6%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} + y} \]
    6. Simplified87.6%

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

    if 1.25000000000000007e31 < y

    1. Initial program 79.4%

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \frac{\color{blue}{-y}}{z} \]
    9. Step-by-step derivation
      1. distribute-frac-neg53.3%

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

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

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

        \[\leadsto \color{blue}{-\frac{x \cdot y}{z}} \]
      5. associate-*l/54.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{z} + y} \]
  7. Final simplification77.2%

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

Alternative 12: 40.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 86.4%

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

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