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

Percentage Accurate: 88.4% → 98.2%
Time: 8.2s
Alternatives: 11
Speedup: 0.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 98.2% accurate, 0.5× speedup?

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

\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 < -6.7999999999999998e144 or 9.99999999999999949e60 < z

    1. Initial program 60.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.7999999999999998e144 < z < 9.99999999999999949e60

    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}\;z \leq -6.8 \cdot 10^{+144} \lor \neg \left(z \leq 10^{+61}\right):\\ \;\;\;\;y + x \cdot \frac{1 - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.7% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y \leq 5 \cdot 10^{+20}:\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\

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


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

    1. Initial program 72.6%

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

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

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

        \[\leadsto y + \frac{\color{blue}{-x \cdot y}}{z} \]
      2. distribute-rgt-neg-in95.2%

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

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

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

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

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

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

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

        \[\leadsto y + \left(x \cdot \color{blue}{y}\right) \cdot \frac{1}{z} \]
      7. remove-double-neg61.6%

        \[\leadsto y + \color{blue}{\left(-\left(-x \cdot y\right)\right)} \cdot \frac{1}{z} \]
      8. distribute-rgt-neg-out61.6%

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

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

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

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

        \[\leadsto y - \color{blue}{\left(-y\right) \cdot \frac{x}{z}} \]
      13. add-sqr-sqrt64.6%

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

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

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

        \[\leadsto y - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \frac{x}{z} \]
      17. add-sqr-sqrt100.0%

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

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

    if -4.99999999999999973e48 < y < 5e20

    1. Initial program 97.8%

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

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

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

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

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

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

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

        \[\leadsto y + \left(x \cdot \frac{1}{z} + \left(-\color{blue}{x \cdot \frac{y}{z}}\right)\right) \]
      6. distribute-rgt-neg-in99.8%

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

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

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

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

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

    if 5e20 < y

    1. Initial program 72.5%

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

      \[\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}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.9%

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

Alternative 3: 86.0% accurate, 0.5× speedup?

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

    1. Initial program 89.4%

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

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

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

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

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

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

    if -8.19999999999999956e64 < x < 5.9999999999999999e39

    1. Initial program 84.3%

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

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

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

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

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

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

Alternative 4: 98.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1350000000 \lor \neg \left(y \leq 0.001\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 -1350000000.0) (not (<= y 0.001)))
   (* y (/ (- z x) z))
   (+ y (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1350000000.0) || !(y <= 0.001)) {
		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 <= (-1350000000.0d0)) .or. (.not. (y <= 0.001d0))) 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 <= -1350000000.0) || !(y <= 0.001)) {
		tmp = y * ((z - x) / z);
	} else {
		tmp = y + (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -1350000000.0) or not (y <= 0.001):
		tmp = y * ((z - x) / z)
	else:
		tmp = y + (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1350000000.0) || !(y <= 0.001))
		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 <= -1350000000.0) || ~((y <= 0.001)))
		tmp = y * ((z - x) / z);
	else
		tmp = y + (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -1350000000.0], N[Not[LessEqual[y, 0.001]], $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 -1350000000 \lor \neg \left(y \leq 0.001\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 < -1.35e9 or 1e-3 < y

    1. Initial program 74.0%

      \[\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.2%

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

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

    if -1.35e9 < y < 1e-3

    1. Initial program 99.1%

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

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

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

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

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

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

Alternative 5: 98.9% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 73.3%

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

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

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

        \[\leadsto y + \frac{\color{blue}{-x \cdot y}}{z} \]
      2. distribute-rgt-neg-in94.2%

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

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

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

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

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

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

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

        \[\leadsto y + \left(x \cdot \color{blue}{y}\right) \cdot \frac{1}{z} \]
      7. remove-double-neg58.0%

        \[\leadsto y + \color{blue}{\left(-\left(-x \cdot y\right)\right)} \cdot \frac{1}{z} \]
      8. distribute-rgt-neg-out58.0%

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

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

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

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

        \[\leadsto y - \color{blue}{\left(-y\right) \cdot \frac{x}{z}} \]
      13. add-sqr-sqrt60.7%

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

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

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

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

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

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

    if -1.35e9 < y < 1e-3

    1. Initial program 99.1%

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

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

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

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

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

    if 1e-3 < y

    1. Initial program 74.8%

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

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

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

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

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

Alternative 6: 75.7% accurate, 0.6× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -8.99999999999999966e228

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.99999999999999966e228 < x < -1.6500000000000001e142

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

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

    if -1.6500000000000001e142 < x

    1. Initial program 85.4%

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

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

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

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

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

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

Alternative 7: 75.9% accurate, 0.6× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.9499999999999999e232

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9499999999999999e232 < x < -4.6e139

    1. Initial program 87.3%

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{y \cdot \frac{x}{z}} \]
      4. distribute-rgt-neg-in80.7%

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

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

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

    if -4.6e139 < x

    1. Initial program 85.4%

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

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

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

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

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

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

Alternative 8: 97.1% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 6.2000000000000004e158

    1. Initial program 93.3%

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

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

    if 6.2000000000000004e158 < z

    1. Initial program 52.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 57.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+20} \lor \neg \left(x \leq 5.6 \cdot 10^{+39}\right):\\
\;\;\;\;\frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.8e20 or 5.60000000000000003e39 < x

    1. Initial program 89.9%

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

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

    if -5.8e20 < x < 5.60000000000000003e39

    1. Initial program 83.9%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 40.6% 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.3%

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

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

    \[\leadsto y \]
  5. Add Preprocessing

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 2024044 
(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))