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

Percentage Accurate: 88.4% → 99.9%
Time: 7.8s
Alternatives: 11
Speedup: 1.0×

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.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, 1.0× speedup?

\[\begin{array}{l} \\ y + \frac{x}{z} \cdot \left(1 - y\right) \end{array} \]
(FPCore (x y z) :precision binary64 (+ y (* (/ x z) (- 1.0 y))))
double code(double x, double y, double z) {
	return y + ((x / z) * (1.0 - 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 + ((x / z) * (1.0d0 - y))
end function
public static double code(double x, double y, double z) {
	return y + ((x / z) * (1.0 - y));
}
def code(x, y, z):
	return y + ((x / z) * (1.0 - y))
function code(x, y, z)
	return Float64(y + Float64(Float64(x / z) * Float64(1.0 - y)))
end
function tmp = code(x, y, z)
	tmp = y + ((x / z) * (1.0 - y));
end
code[x_, y_, z_] := N[(y + N[(N[(x / z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
y + \frac{x}{z} \cdot \left(1 - y\right)
\end{array}
Derivation
  1. Initial program 90.4%

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

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

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

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

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

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

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

      \[\leadsto y + \color{blue}{\frac{x \cdot \left(1 - y\right)}{z}} \]
    6. associate-*l/99.9%

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

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

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

Alternative 2: 56.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.65 \cdot 10^{+56} \lor \neg \left(x \leq -1.5 \cdot 10^{-108} \lor \neg \left(x \leq -6.5 \cdot 10^{-124}\right) \land x \leq 1.8 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -3.65e+56)
         (not
          (or (<= x -1.5e-108) (and (not (<= x -6.5e-124)) (<= x 1.8e-11)))))
   (/ x z)
   y))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -3.65e+56) || !((x <= -1.5e-108) || (!(x <= -6.5e-124) && (x <= 1.8e-11)))) {
		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 ((x <= (-3.65d+56)) .or. (.not. (x <= (-1.5d-108)) .or. (.not. (x <= (-6.5d-124))) .and. (x <= 1.8d-11))) 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 ((x <= -3.65e+56) || !((x <= -1.5e-108) || (!(x <= -6.5e-124) && (x <= 1.8e-11)))) {
		tmp = x / z;
	} else {
		tmp = y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -3.65e+56) or not ((x <= -1.5e-108) or (not (x <= -6.5e-124) and (x <= 1.8e-11))):
		tmp = x / z
	else:
		tmp = y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -3.65e+56) || !((x <= -1.5e-108) || (!(x <= -6.5e-124) && (x <= 1.8e-11))))
		tmp = Float64(x / z);
	else
		tmp = y;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -3.65e+56) || ~(((x <= -1.5e-108) || (~((x <= -6.5e-124)) && (x <= 1.8e-11)))))
		tmp = x / z;
	else
		tmp = y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.65e+56], N[Not[Or[LessEqual[x, -1.5e-108], And[N[Not[LessEqual[x, -6.5e-124]], $MachinePrecision], LessEqual[x, 1.8e-11]]]], $MachinePrecision]], N[(x / z), $MachinePrecision], y]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.65 \cdot 10^{+56} \lor \neg \left(x \leq -1.5 \cdot 10^{-108} \lor \neg \left(x \leq -6.5 \cdot 10^{-124}\right) \land x \leq 1.8 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.65e56 or -1.49999999999999996e-108 < x < -6.49999999999999988e-124 or 1.79999999999999992e-11 < x

    1. Initial program 91.8%

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

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

    if -3.65e56 < x < -1.49999999999999996e-108 or -6.49999999999999988e-124 < x < 1.79999999999999992e-11

    1. Initial program 88.7%

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

      \[\leadsto \color{blue}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.65 \cdot 10^{+56} \lor \neg \left(x \leq -1.5 \cdot 10^{-108} \lor \neg \left(x \leq -6.5 \cdot 10^{-124}\right) \land x \leq 1.8 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.7% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq 3.55 \cdot 10^{+103} \lor \neg \left(y \leq 8.5 \cdot 10^{+256}\right):\\
\;\;\;\;-x \cdot \frac{y}{z}\\

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


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

    1. Initial program 93.3%

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

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

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

    if 1.29999999999999995e42 < y < 3.5500000000000001e103 or 8.5000000000000006e256 < y

    1. Initial program 85.5%

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

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

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

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

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

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

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

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

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

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

    if 3.5500000000000001e103 < y < 8.5000000000000006e256

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot y}{x}} \]
    8. Applied egg-rr63.7%

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

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

Alternative 4: 77.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq 4.2 \cdot 10^{+102} \lor \neg \left(y \leq 9.4 \cdot 10^{+256}\right):\\
\;\;\;\;y \cdot \frac{x}{-z}\\

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


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

    1. Initial program 93.3%

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

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

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

    if 2.0000000000000002e44 < y < 4.20000000000000003e102 or 9.39999999999999935e256 < y

    1. Initial program 85.5%

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

      \[\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}} \]
    6. Taylor expanded in z around 0 79.3%

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

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

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

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

    if 4.20000000000000003e102 < y < 9.39999999999999935e256

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot y}{x}} \]
    8. Applied egg-rr63.7%

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

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

Alternative 5: 77.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq 1.55 \cdot 10^{+104} \lor \neg \left(y \leq 8.8 \cdot 10^{+256}\right):\\
\;\;\;\;\frac{y}{\frac{-z}{x}}\\

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


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

    1. Initial program 93.3%

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

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

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

    if 8.6e43 < y < 1.55000000000000008e104 or 8.7999999999999997e256 < y

    1. Initial program 85.5%

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

      \[\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}} \]
    6. Taylor expanded in z around 0 79.3%

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

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

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

      \[\leadsto y \cdot \color{blue}{\frac{x}{-z}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt15.7%

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

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

        \[\leadsto y \cdot \frac{x}{\sqrt{\color{blue}{z \cdot z}}} \]
      4. sqrt-unprod0.3%

        \[\leadsto y \cdot \frac{x}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      5. add-sqr-sqrt1.3%

        \[\leadsto y \cdot \frac{x}{\color{blue}{z}} \]
      6. clear-num1.3%

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

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

        \[\leadsto \color{blue}{\frac{-y}{-\frac{z}{x}}} \]
      9. distribute-frac-neg1.3%

        \[\leadsto \frac{-y}{\color{blue}{\frac{-z}{x}}} \]
      10. add-sqr-sqrt1.1%

        \[\leadsto \frac{-y}{\frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{x}} \]
      11. sqrt-unprod64.4%

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

        \[\leadsto \frac{-y}{\frac{\sqrt{\color{blue}{z \cdot z}}}{x}} \]
      13. sqrt-unprod63.2%

        \[\leadsto \frac{-y}{\frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{x}} \]
      14. add-sqr-sqrt79.3%

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

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

    if 1.55000000000000008e104 < y < 8.7999999999999997e256

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot y}{x}} \]
    8. Applied egg-rr63.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 8.6 \cdot 10^{+43}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{+104} \lor \neg \left(y \leq 8.8 \cdot 10^{+256}\right):\\ \;\;\;\;\frac{y}{\frac{-z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.2% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.3999999999999999e89 or 9.60000000000000019e-16 < x

    1. Initial program 91.6%

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

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

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

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

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

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

    if -1.3999999999999999e89 < x < 9.60000000000000019e-16

    1. Initial program 89.1%

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

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

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

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

Alternative 7: 99.1% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 80.8%

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

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

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

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

    if -3.8e5 < y < 1

    1. Initial program 99.9%

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

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

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

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

Alternative 8: 99.1% accurate, 0.5× speedup?

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

\mathbf{elif}\;y \leq 1:\\
\;\;\;\;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.8e5

    1. Initial program 79.4%

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

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

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

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

    if -3.8e5 < y < 1

    1. Initial program 99.9%

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

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

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

    if 1 < y

    1. Initial program 82.0%

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

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

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

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

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

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

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

        \[\leadsto y + \color{blue}{\frac{x \cdot \left(1 - y\right)}{z}} \]
      6. associate-*l/99.9%

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

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

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

        \[\leadsto y + \color{blue}{\left(-\frac{x \cdot y}{z}\right)} \]
      2. associate-*l/99.9%

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

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

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

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

Alternative 9: 77.8% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 91.6%

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

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

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

    if 2.10000000000000016e122 < y

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 40.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 90.4%

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

    \[\leadsto \color{blue}{y} \]
  4. Final simplification42.6%

    \[\leadsto y \]
  5. Add Preprocessing

Developer target: 94.5% 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 2024081 
(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))