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

Percentage Accurate: 87.4% → 99.9%
Time: 6.7s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 87.4% 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.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(1 - \frac{x}{z}\right)\\ \mathbf{if}\;y \leq -2 \cdot 10^{-63}:\\ \;\;\;\;\frac{x}{z} + t\_0\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+16}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (- 1.0 (/ x z)))))
   (if (<= y -2e-63)
     (+ (/ x z) t_0)
     (if (<= y 5e+16) (/ (fma y (- z x) x) z) t_0))))
double code(double x, double y, double z) {
	double t_0 = y * (1.0 - (x / z));
	double tmp;
	if (y <= -2e-63) {
		tmp = (x / z) + t_0;
	} else if (y <= 5e+16) {
		tmp = fma(y, (z - x), x) / z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(y * Float64(1.0 - Float64(x / z)))
	tmp = 0.0
	if (y <= -2e-63)
		tmp = Float64(Float64(x / z) + t_0);
	elseif (y <= 5e+16)
		tmp = Float64(fma(y, Float64(z - x), x) / z);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e-63], N[(N[(x / z), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[y, 5e+16], N[(N[(y * N[(z - x), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 79.1%

      \[\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 -2.00000000000000013e-63 < y < 5e16

    1. Initial program 100.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}} \]
    4. Add Preprocessing

    if 5e16 < y

    1. Initial program 76.1%

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

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

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

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

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

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

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

Alternative 2: 80.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y + \frac{x}{z}\\ \mathbf{if}\;y \leq -1.36 \cdot 10^{+133}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -1.08 \cdot 10^{+73}:\\ \;\;\;\;y \cdot \frac{x}{-z}\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ y (/ x z))))
   (if (<= y -1.36e+133)
     t_0
     (if (<= y -1.08e+73)
       (* y (/ x (- z)))
       (if (<= y 1.65e-5) t_0 (- y (/ x z)))))))
double code(double x, double y, double z) {
	double t_0 = y + (x / z);
	double tmp;
	if (y <= -1.36e+133) {
		tmp = t_0;
	} else if (y <= -1.08e+73) {
		tmp = y * (x / -z);
	} else if (y <= 1.65e-5) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = y + (x / z)
    if (y <= (-1.36d+133)) then
        tmp = t_0
    else if (y <= (-1.08d+73)) then
        tmp = y * (x / -z)
    else if (y <= 1.65d-5) then
        tmp = t_0
    else
        tmp = y - (x / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y + (x / z);
	double tmp;
	if (y <= -1.36e+133) {
		tmp = t_0;
	} else if (y <= -1.08e+73) {
		tmp = y * (x / -z);
	} else if (y <= 1.65e-5) {
		tmp = t_0;
	} else {
		tmp = y - (x / z);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y + (x / z)
	tmp = 0
	if y <= -1.36e+133:
		tmp = t_0
	elif y <= -1.08e+73:
		tmp = y * (x / -z)
	elif y <= 1.65e-5:
		tmp = t_0
	else:
		tmp = y - (x / z)
	return tmp
function code(x, y, z)
	t_0 = Float64(y + Float64(x / z))
	tmp = 0.0
	if (y <= -1.36e+133)
		tmp = t_0;
	elseif (y <= -1.08e+73)
		tmp = Float64(y * Float64(x / Float64(-z)));
	elseif (y <= 1.65e-5)
		tmp = t_0;
	else
		tmp = Float64(y - Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y + (x / z);
	tmp = 0.0;
	if (y <= -1.36e+133)
		tmp = t_0;
	elseif (y <= -1.08e+73)
		tmp = y * (x / -z);
	elseif (y <= 1.65e-5)
		tmp = t_0;
	else
		tmp = y - (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.36e+133], t$95$0, If[LessEqual[y, -1.08e+73], N[(y * N[(x / (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e-5], t$95$0, N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
\mathbf{if}\;y \leq -1.36 \cdot 10^{+133}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y \leq 1.65 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.3600000000000001e133 or -1.08e73 < y < 1.6500000000000001e-5

    1. Initial program 89.9%

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

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

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

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

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

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

    if -1.3600000000000001e133 < y < -1.08e73

    1. Initial program 87.2%

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

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

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

        \[\leadsto \frac{\color{blue}{-x \cdot y}}{z} \]
      2. distribute-lft-neg-out59.7%

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

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

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

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

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

        \[\leadsto -\frac{-\color{blue}{\left(-y \cdot x\right)}}{z} \]
      4. remove-double-neg59.7%

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

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

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

    if 1.6500000000000001e-5 < y

    1. Initial program 77.7%

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

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

      \[\leadsto y \cdot \color{blue}{1} + \frac{x}{z} \]
    5. Step-by-step derivation
      1. *-rgt-identity52.3%

        \[\leadsto \color{blue}{y} + \frac{x}{z} \]
      2. add-sqr-sqrt19.9%

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

        \[\leadsto y + \frac{\color{blue}{\sqrt{x \cdot x}}}{z} \]
      4. sqr-neg67.9%

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

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

        \[\leadsto y + \frac{\color{blue}{-x}}{z} \]
      7. distribute-frac-neg67.7%

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

        \[\leadsto \color{blue}{y - \frac{x}{z}} \]
      9. add-sqr-sqrt40.2%

        \[\leadsto y - \color{blue}{\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}} \]
      10. cancel-sign-sub-inv40.2%

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

      \[\leadsto \color{blue}{y + \left(-\sqrt{\frac{x}{z}}\right) \cdot \sqrt{\frac{x}{z}}} \]
    7. Step-by-step derivation
      1. distribute-lft-neg-out40.2%

        \[\leadsto y + \color{blue}{\left(-\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
      2. rem-square-sqrt67.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.36 \cdot 10^{+133}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq -1.08 \cdot 10^{+73}:\\ \;\;\;\;y \cdot \frac{x}{-z}\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-5}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 73.3%

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

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

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

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

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

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

    if -4.7999999999999997e42 < y < 1e14

    1. Initial program 99.9%

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

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

Alternative 4: 99.9% accurate, 0.5× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 79.1%

      \[\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 -1.00000000000000007e-63 < y < 3.2e12

    1. Initial program 100.0%

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

    if 3.2e12 < y

    1. Initial program 76.1%

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

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

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

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

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

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

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

Alternative 5: 99.1% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 75.0%

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

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

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

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

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

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

    if -32 < y < 1.6500000000000001e-5

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 6: 85.1% accurate, 0.5× speedup?

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

    1. Initial program 85.7%

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

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

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

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

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

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

    if -3.6e9 < x < 4.3e124

    1. Initial program 86.3%

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

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

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

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

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

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

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

Alternative 7: 60.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-33} \lor \neg \left(y \leq 2.9 \cdot 10^{-32}\right):\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.4000000000000001e-33 or 2.89999999999999996e-32 < y

    1. Initial program 77.5%

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

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

    if -3.4000000000000001e-33 < y < 2.89999999999999996e-32

    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.1%

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

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

Alternative 8: 81.1% accurate, 0.9× speedup?

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

    1. Initial program 89.6%

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

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

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

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

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

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

    if 1.6500000000000001e-5 < y

    1. Initial program 77.7%

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

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

      \[\leadsto y \cdot \color{blue}{1} + \frac{x}{z} \]
    5. Step-by-step derivation
      1. *-rgt-identity52.3%

        \[\leadsto \color{blue}{y} + \frac{x}{z} \]
      2. add-sqr-sqrt19.9%

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

        \[\leadsto y + \frac{\color{blue}{\sqrt{x \cdot x}}}{z} \]
      4. sqr-neg67.9%

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

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

        \[\leadsto y + \frac{\color{blue}{-x}}{z} \]
      7. distribute-frac-neg67.7%

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

        \[\leadsto \color{blue}{y - \frac{x}{z}} \]
      9. add-sqr-sqrt40.2%

        \[\leadsto y - \color{blue}{\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}} \]
      10. cancel-sign-sub-inv40.2%

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

      \[\leadsto \color{blue}{y + \left(-\sqrt{\frac{x}{z}}\right) \cdot \sqrt{\frac{x}{z}}} \]
    7. Step-by-step derivation
      1. distribute-lft-neg-out40.2%

        \[\leadsto y + \color{blue}{\left(-\sqrt{\frac{x}{z}} \cdot \sqrt{\frac{x}{z}}\right)} \]
      2. rem-square-sqrt67.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Developer target: 94.2% accurate, 0.8× speedup?

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

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

Reproduce

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

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

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