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

Percentage Accurate: 88.3% → 99.8%
Time: 5.9s
Alternatives: 11
Speedup: 0.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 88.3% 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.8% accurate, 0.6× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.00000000000000001e43

    1. Initial program 72.9%

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

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

    if -1.00000000000000001e43 < z < 4.9999999999999999e-48

    1. Initial program 100.0%

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

    if 4.9999999999999999e-48 < z

    1. Initial program 76.6%

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

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

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

Alternative 2: 99.9% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.26 \cdot 10^{-30} \lor \neg \left(z \leq 5 \cdot 10^{-48}\right):\\
\;\;\;\;\frac{x}{z} + 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 z < -1.26e-30 or 4.9999999999999999e-48 < z

    1. Initial program 77.2%

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

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

    if -1.26e-30 < z < 4.9999999999999999e-48

    1. Initial program 100.0%

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

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

Alternative 3: 75.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y + \frac{x}{z}\\ t_1 := x \cdot \left(-\frac{y}{z}\right)\\ \mathbf{if}\;y \leq -1.22 \cdot 10^{+233}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 69000000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.06 \cdot 10^{+139}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ y (/ x z))) (t_1 (* x (- (/ y z)))))
   (if (<= y -1.22e+233)
     t_0
     (if (<= y -4.8e+32)
       t_1
       (if (<= y 69000000000000.0)
         t_0
         (if (<= y 2.06e+139) t_1 (- y (/ x z))))))))
double code(double x, double y, double z) {
	double t_0 = y + (x / z);
	double t_1 = x * -(y / z);
	double tmp;
	if (y <= -1.22e+233) {
		tmp = t_0;
	} else if (y <= -4.8e+32) {
		tmp = t_1;
	} else if (y <= 69000000000000.0) {
		tmp = t_0;
	} else if (y <= 2.06e+139) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = y + (x / z)
    t_1 = x * -(y / z)
    if (y <= (-1.22d+233)) then
        tmp = t_0
    else if (y <= (-4.8d+32)) then
        tmp = t_1
    else if (y <= 69000000000000.0d0) then
        tmp = t_0
    else if (y <= 2.06d+139) then
        tmp = t_1
    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 t_1 = x * -(y / z);
	double tmp;
	if (y <= -1.22e+233) {
		tmp = t_0;
	} else if (y <= -4.8e+32) {
		tmp = t_1;
	} else if (y <= 69000000000000.0) {
		tmp = t_0;
	} else if (y <= 2.06e+139) {
		tmp = t_1;
	} else {
		tmp = y - (x / z);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y + (x / z)
	t_1 = x * -(y / z)
	tmp = 0
	if y <= -1.22e+233:
		tmp = t_0
	elif y <= -4.8e+32:
		tmp = t_1
	elif y <= 69000000000000.0:
		tmp = t_0
	elif y <= 2.06e+139:
		tmp = t_1
	else:
		tmp = y - (x / z)
	return tmp
function code(x, y, z)
	t_0 = Float64(y + Float64(x / z))
	t_1 = Float64(x * Float64(-Float64(y / z)))
	tmp = 0.0
	if (y <= -1.22e+233)
		tmp = t_0;
	elseif (y <= -4.8e+32)
		tmp = t_1;
	elseif (y <= 69000000000000.0)
		tmp = t_0;
	elseif (y <= 2.06e+139)
		tmp = t_1;
	else
		tmp = Float64(y - Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y + (x / z);
	t_1 = x * -(y / z);
	tmp = 0.0;
	if (y <= -1.22e+233)
		tmp = t_0;
	elseif (y <= -4.8e+32)
		tmp = t_1;
	elseif (y <= 69000000000000.0)
		tmp = t_0;
	elseif (y <= 2.06e+139)
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(x * (-N[(y / z), $MachinePrecision])), $MachinePrecision]}, If[LessEqual[y, -1.22e+233], t$95$0, If[LessEqual[y, -4.8e+32], t$95$1, If[LessEqual[y, 69000000000000.0], t$95$0, If[LessEqual[y, 2.06e+139], t$95$1, N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
t_1 := x \cdot \left(-\frac{y}{z}\right)\\
\mathbf{if}\;y \leq -1.22 \cdot 10^{+233}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -4.8 \cdot 10^{+32}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 69000000000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 2.06 \cdot 10^{+139}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.22e233 or -4.79999999999999983e32 < y < 6.9e13

    1. Initial program 96.6%

      \[\frac{x + y \cdot \left(z - x\right)}{z} \]
    2. 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. Taylor expanded in y around 0 96.7%

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

    if -1.22e233 < y < -4.79999999999999983e32 or 6.9e13 < y < 2.06e139

    1. Initial program 79.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{x \cdot \frac{y}{z}} \]
      3. distribute-rgt-neg-in67.1%

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

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

    if 2.06e139 < y

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \color{blue}{\frac{x}{z}} \]
    5. Applied egg-rr71.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.22 \cdot 10^{+233}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{+32}:\\ \;\;\;\;x \cdot \left(-\frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 69000000000000:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 2.06 \cdot 10^{+139}:\\ \;\;\;\;x \cdot \left(-\frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \]

Alternative 4: 76.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y + \frac{x}{z}\\ t_1 := y \cdot \frac{-x}{z}\\ \mathbf{if}\;y \leq -4.1 \cdot 10^{+234}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2600000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{+139}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ y (/ x z))) (t_1 (* y (/ (- x) z))))
   (if (<= y -4.1e+234)
     t_0
     (if (<= y -6e+32)
       t_1
       (if (<= y 2600000000000.0)
         t_0
         (if (<= y 1.46e+139) t_1 (- y (/ x z))))))))
double code(double x, double y, double z) {
	double t_0 = y + (x / z);
	double t_1 = y * (-x / z);
	double tmp;
	if (y <= -4.1e+234) {
		tmp = t_0;
	} else if (y <= -6e+32) {
		tmp = t_1;
	} else if (y <= 2600000000000.0) {
		tmp = t_0;
	} else if (y <= 1.46e+139) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = y + (x / z)
    t_1 = y * (-x / z)
    if (y <= (-4.1d+234)) then
        tmp = t_0
    else if (y <= (-6d+32)) then
        tmp = t_1
    else if (y <= 2600000000000.0d0) then
        tmp = t_0
    else if (y <= 1.46d+139) then
        tmp = t_1
    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 t_1 = y * (-x / z);
	double tmp;
	if (y <= -4.1e+234) {
		tmp = t_0;
	} else if (y <= -6e+32) {
		tmp = t_1;
	} else if (y <= 2600000000000.0) {
		tmp = t_0;
	} else if (y <= 1.46e+139) {
		tmp = t_1;
	} else {
		tmp = y - (x / z);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y + (x / z)
	t_1 = y * (-x / z)
	tmp = 0
	if y <= -4.1e+234:
		tmp = t_0
	elif y <= -6e+32:
		tmp = t_1
	elif y <= 2600000000000.0:
		tmp = t_0
	elif y <= 1.46e+139:
		tmp = t_1
	else:
		tmp = y - (x / z)
	return tmp
function code(x, y, z)
	t_0 = Float64(y + Float64(x / z))
	t_1 = Float64(y * Float64(Float64(-x) / z))
	tmp = 0.0
	if (y <= -4.1e+234)
		tmp = t_0;
	elseif (y <= -6e+32)
		tmp = t_1;
	elseif (y <= 2600000000000.0)
		tmp = t_0;
	elseif (y <= 1.46e+139)
		tmp = t_1;
	else
		tmp = Float64(y - Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y + (x / z);
	t_1 = y * (-x / z);
	tmp = 0.0;
	if (y <= -4.1e+234)
		tmp = t_0;
	elseif (y <= -6e+32)
		tmp = t_1;
	elseif (y <= 2600000000000.0)
		tmp = t_0;
	elseif (y <= 1.46e+139)
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.1e+234], t$95$0, If[LessEqual[y, -6e+32], t$95$1, If[LessEqual[y, 2600000000000.0], t$95$0, If[LessEqual[y, 1.46e+139], t$95$1, N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
t_1 := y \cdot \frac{-x}{z}\\
\mathbf{if}\;y \leq -4.1 \cdot 10^{+234}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -6 \cdot 10^{+32}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 2600000000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.46 \cdot 10^{+139}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.09999999999999974e234 or -6e32 < y < 2.6e12

    1. Initial program 96.6%

      \[\frac{x + y \cdot \left(z - x\right)}{z} \]
    2. 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. Taylor expanded in y around 0 96.7%

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

    if -4.09999999999999974e234 < y < -6e32 or 2.6e12 < y < 1.46000000000000011e139

    1. Initial program 79.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.46000000000000011e139 < y

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \color{blue}{\frac{x}{z}} \]
    5. Applied egg-rr71.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.1 \cdot 10^{+234}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq -6 \cdot 10^{+32}:\\ \;\;\;\;y \cdot \frac{-x}{z}\\ \mathbf{elif}\;y \leq 2600000000000:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{+139}:\\ \;\;\;\;y \cdot \frac{-x}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \]

Alternative 5: 99.3% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 66.8%

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

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

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

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

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

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

    if -1.9e84 < y < 6.4e18

    1. Initial program 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+84} \lor \neg \left(y \leq 6.4 \cdot 10^{+18}\right):\\ \;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \end{array} \]

Alternative 6: 98.8% accurate, 0.8× speedup?

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

    1. Initial program 72.9%

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

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

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

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

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

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

    if -8e20 < y < 0.409999999999999976

    1. Initial program 99.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{+20} \lor \neg \left(y \leq 0.41\right):\\ \;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]

Alternative 7: 59.9% accurate, 1.3× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.50000000000000016e-10 or 8.50000000000000014e-7 < y

    1. Initial program 74.3%

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

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

    if -2.50000000000000016e-10 < y < 8.50000000000000014e-7

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{-10}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]

Alternative 8: 60.8% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 74.7%

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{z}}} \]
      2. associate-/r/48.7%

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

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

    if -3.5000000000000002e-13 < y < 2.1500000000000001e-7

    1. Initial program 99.9%

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

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

    if 2.1500000000000001e-7 < y

    1. Initial program 73.9%

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

      \[\leadsto \color{blue}{y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification60.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{-13}:\\ \;\;\;\;z \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]

Alternative 9: 80.7% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 92.3%

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

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

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

    if 0.409999999999999976 < y

    1. Initial program 73.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \color{blue}{\frac{x}{z}} \]
    5. Applied egg-rr55.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 0.41:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{x}{z}\\ \end{array} \]

Alternative 10: 77.1% accurate, 1.8× speedup?

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

\\
y + \frac{x}{z}
\end{array}
Derivation
  1. Initial program 87.9%

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

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

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

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

Alternative 11: 41.0% accurate, 9.0× speedup?

\[\begin{array}{l} \\ y \end{array} \]
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
	return y;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = y
end function
public static double code(double x, double y, double z) {
	return y;
}
def code(x, y, z):
	return y
function code(x, y, z)
	return y
end
function tmp = code(x, y, z)
	tmp = y;
end
code[x_, y_, z_] := y
\begin{array}{l}

\\
y
\end{array}
Derivation
  1. Initial program 87.9%

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

    \[\leadsto \color{blue}{y} \]
  3. Final simplification36.3%

    \[\leadsto y \]

Developer target: 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 2023308 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
  :precision binary64

  :herbie-target
  (- (+ y (/ x z)) (/ y (/ z x)))

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