Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C

Percentage Accurate: 99.9% → 99.9%
Time: 10.0s
Alternatives: 15
Speedup: 1.0×

Specification

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

\\
\left(x + \sin y\right) + z \cdot \cos y
\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 15 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: 99.9% accurate, 1.0× speedup?

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

\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}

Alternative 1: 99.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(z, \cos y, x + \sin y\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma z (cos y) (+ x (sin y))))
double code(double x, double y, double z) {
	return fma(z, cos(y), (x + sin(y)));
}
function code(x, y, z)
	return fma(z, cos(y), Float64(x + sin(y)))
end
code[x_, y_, z_] := N[(z * N[Cos[y], $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(z, \cos y, x + \sin y\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x + \sin y\right) + z \cdot \cos y \]
  2. Step-by-step derivation
    1. +-commutative99.9%

      \[\leadsto \color{blue}{z \cdot \cos y + \left(x + \sin y\right)} \]
    2. fma-define99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, \cos y, x + \sin y\right)} \]
  3. Simplified99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, \cos y, x + \sin y\right)} \]
  4. Add Preprocessing
  5. Final simplification99.9%

    \[\leadsto \mathsf{fma}\left(z, \cos y, x + \sin y\right) \]
  6. Add Preprocessing

Alternative 2: 99.9% accurate, 1.0× speedup?

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

\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x + \sin y\right) + z \cdot \cos y \]
  2. Add Preprocessing
  3. Final simplification99.9%

    \[\leadsto \left(x + \sin y\right) + z \cdot \cos y \]
  4. Add Preprocessing

Alternative 3: 99.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.8 \lor \neg \left(z \leq 3.5 \cdot 10^{-16}\right):\\
\;\;\;\;z \cdot \left(\cos y + \frac{x}{z}\right)\\

\mathbf{else}:\\
\;\;\;\;z + \left(x + \sin y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.80000000000000004 or 3.50000000000000017e-16 < z

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.80000000000000004 < z < 3.50000000000000017e-16

    1. Initial program 100.0%

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

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

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

Alternative 4: 88.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+77} \lor \neg \left(z \leq 1.36 \cdot 10^{+88}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -5.5e+77) (not (<= z 1.36e+88)))
   (* z (cos y))
   (+ z (+ x (sin y)))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -5.5e+77) || !(z <= 1.36e+88)) {
		tmp = z * cos(y);
	} else {
		tmp = z + (x + sin(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 ((z <= (-5.5d+77)) .or. (.not. (z <= 1.36d+88))) then
        tmp = z * cos(y)
    else
        tmp = z + (x + sin(y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -5.5e+77) || !(z <= 1.36e+88)) {
		tmp = z * Math.cos(y);
	} else {
		tmp = z + (x + Math.sin(y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -5.5e+77) or not (z <= 1.36e+88):
		tmp = z * math.cos(y)
	else:
		tmp = z + (x + math.sin(y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -5.5e+77) || !(z <= 1.36e+88))
		tmp = Float64(z * cos(y));
	else
		tmp = Float64(z + Float64(x + sin(y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -5.5e+77) || ~((z <= 1.36e+88)))
		tmp = z * cos(y);
	else
		tmp = z + (x + sin(y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.5e+77], N[Not[LessEqual[z, 1.36e+88]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+77} \lor \neg \left(z \leq 1.36 \cdot 10^{+88}\right):\\
\;\;\;\;z \cdot \cos y\\

\mathbf{else}:\\
\;\;\;\;z + \left(x + \sin y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.50000000000000036e77 or 1.3600000000000001e88 < z

    1. Initial program 99.8%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 81.8%

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

    if -5.50000000000000036e77 < z < 1.3600000000000001e88

    1. Initial program 100.0%

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

      \[\leadsto \left(x + \sin y\right) + \color{blue}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+77} \lor \neg \left(z \leq 1.36 \cdot 10^{+88}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 89.3% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -6.5 \cdot 10^{+105}:\\ \;\;\;\;x + \left(y + t\_0\right)\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+87}:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (cos y))))
   (if (<= z -6.5e+105)
     (+ x (+ y t_0))
     (if (<= z 9e+87) (+ z (+ x (sin y))) t_0))))
double code(double x, double y, double z) {
	double t_0 = z * cos(y);
	double tmp;
	if (z <= -6.5e+105) {
		tmp = x + (y + t_0);
	} else if (z <= 9e+87) {
		tmp = z + (x + sin(y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = z * cos(y)
    if (z <= (-6.5d+105)) then
        tmp = x + (y + t_0)
    else if (z <= 9d+87) then
        tmp = z + (x + sin(y))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * Math.cos(y);
	double tmp;
	if (z <= -6.5e+105) {
		tmp = x + (y + t_0);
	} else if (z <= 9e+87) {
		tmp = z + (x + Math.sin(y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * math.cos(y)
	tmp = 0
	if z <= -6.5e+105:
		tmp = x + (y + t_0)
	elif z <= 9e+87:
		tmp = z + (x + math.sin(y))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(z * cos(y))
	tmp = 0.0
	if (z <= -6.5e+105)
		tmp = Float64(x + Float64(y + t_0));
	elseif (z <= 9e+87)
		tmp = Float64(z + Float64(x + sin(y)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * cos(y);
	tmp = 0.0;
	if (z <= -6.5e+105)
		tmp = x + (y + t_0);
	elseif (z <= 9e+87)
		tmp = z + (x + sin(y));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.5e+105], N[(x + N[(y + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9e+87], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 9 \cdot 10^{+87}:\\
\;\;\;\;z + \left(x + \sin y\right)\\

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


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

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 99.8%

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

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

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

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

      \[\leadsto z \cdot \left(\color{blue}{\frac{y}{z}} + \left(\cos y + \frac{x}{z}\right)\right) \]
    7. Taylor expanded in z around 0 89.4%

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

    if -6.50000000000000049e105 < z < 9.0000000000000005e87

    1. Initial program 100.0%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 95.1%

      \[\leadsto \left(x + \sin y\right) + \color{blue}{z} \]

    if 9.0000000000000005e87 < z

    1. Initial program 99.7%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 83.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+105}:\\ \;\;\;\;x + \left(y + z \cdot \cos y\right)\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+87}:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 72.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+78} \lor \neg \left(z \leq 1.4 \cdot 10^{+88}\right):\\
\;\;\;\;z \cdot \cos y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.05e78 or 1.39999999999999994e88 < z

    1. Initial program 99.8%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 81.8%

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

    if -1.05e78 < z < 1.39999999999999994e88

    1. Initial program 100.0%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 68.9%

      \[\leadsto \color{blue}{x + z} \]
    4. Step-by-step derivation
      1. +-commutative68.9%

        \[\leadsto \color{blue}{z + x} \]
    5. Simplified68.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+78} \lor \neg \left(z \leq 1.4 \cdot 10^{+88}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 81.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+77} \lor \neg \left(z \leq 9.5 \cdot 10^{+16}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x + \sin y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -2.7e+77) (not (<= z 9.5e+16))) (* z (cos y)) (+ x (sin y))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -2.7e+77) || !(z <= 9.5e+16)) {
		tmp = z * cos(y);
	} else {
		tmp = x + sin(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 ((z <= (-2.7d+77)) .or. (.not. (z <= 9.5d+16))) then
        tmp = z * cos(y)
    else
        tmp = x + sin(y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -2.7e+77) || !(z <= 9.5e+16)) {
		tmp = z * Math.cos(y);
	} else {
		tmp = x + Math.sin(y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -2.7e+77) or not (z <= 9.5e+16):
		tmp = z * math.cos(y)
	else:
		tmp = x + math.sin(y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -2.7e+77) || !(z <= 9.5e+16))
		tmp = Float64(z * cos(y));
	else
		tmp = Float64(x + sin(y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -2.7e+77) || ~((z <= 9.5e+16)))
		tmp = z * cos(y);
	else
		tmp = x + sin(y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.7e+77], N[Not[LessEqual[z, 9.5e+16]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+77} \lor \neg \left(z \leq 9.5 \cdot 10^{+16}\right):\\
\;\;\;\;z \cdot \cos y\\

\mathbf{else}:\\
\;\;\;\;x + \sin y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.6999999999999998e77 or 9.5e16 < z

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 80.0%

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

    if -2.6999999999999998e77 < z < 9.5e16

    1. Initial program 100.0%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 88.2%

      \[\leadsto \color{blue}{x + \sin y} \]
    4. Step-by-step derivation
      1. +-commutative88.2%

        \[\leadsto \color{blue}{\sin y + x} \]
    5. Simplified88.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+77} \lor \neg \left(z \leq 9.5 \cdot 10^{+16}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x + \sin y\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 70.1% accurate, 7.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -23000000000 \lor \neg \left(y \leq 39000000000000\right):\\
\;\;\;\;z + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.3e10 or 3.9e13 < y

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 39.6%

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

        \[\leadsto \color{blue}{z + x} \]
    5. Simplified39.6%

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

    if -2.3e10 < y < 3.9e13

    1. Initial program 100.0%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 98.2%

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

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

Alternative 9: 69.9% accurate, 9.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+32} \lor \neg \left(y \leq 850\right):\\
\;\;\;\;z + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.7e32 or 850 < y

    1. Initial program 99.8%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 38.4%

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

        \[\leadsto \color{blue}{z + x} \]
    5. Simplified38.4%

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

    if -3.7e32 < y < 850

    1. Initial program 100.0%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 96.8%

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

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

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

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

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

Alternative 10: 70.1% accurate, 9.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.42 \lor \neg \left(y \leq 4.5 \cdot 10^{+16}\right):\\
\;\;\;\;z + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.4199999999999999 or 4.5e16 < y

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 39.7%

      \[\leadsto \color{blue}{x + z} \]
    4. Step-by-step derivation
      1. +-commutative39.7%

        \[\leadsto \color{blue}{z + x} \]
    5. Simplified39.7%

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

    if -1.4199999999999999 < y < 4.5e16

    1. Initial program 100.0%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 97.9%

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

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

        \[\leadsto \color{blue}{\left(z + x\right)} + y \cdot \left(1 + -0.5 \cdot \left(y \cdot z\right)\right) \]
      3. *-commutative97.9%

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

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

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

Alternative 11: 69.8% accurate, 13.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+52} \lor \neg \left(y \leq 2.4 \cdot 10^{+66}\right):\\
\;\;\;\;z + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.7e52 or 2.4000000000000002e66 < y

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 39.9%

      \[\leadsto \color{blue}{x + z} \]
    4. Step-by-step derivation
      1. +-commutative39.9%

        \[\leadsto \color{blue}{z + x} \]
    5. Simplified39.9%

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

    if -4.7e52 < y < 2.4000000000000002e66

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 88.6%

      \[\leadsto \color{blue}{x + \left(y + z\right)} \]
    4. Step-by-step derivation
      1. +-commutative88.6%

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

        \[\leadsto \color{blue}{\left(z + y\right)} + x \]
      3. associate-+l+88.6%

        \[\leadsto \color{blue}{z + \left(y + x\right)} \]
    5. Simplified88.6%

      \[\leadsto \color{blue}{z + \left(y + x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.2%

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

Alternative 12: 66.6% accurate, 15.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.25 \cdot 10^{-21} \lor \neg \left(x \leq 5.3 \cdot 10^{-127}\right):\\
\;\;\;\;z + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.2500000000000001e-21 or 5.3000000000000003e-127 < x

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 76.5%

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

        \[\leadsto \color{blue}{z + x} \]
    5. Simplified76.5%

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

    if -9.2500000000000001e-21 < x < 5.3000000000000003e-127

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 99.8%

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

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

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

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

      \[\leadsto z \cdot \left(\frac{\sin y}{z} + \color{blue}{\cos y}\right) \]
    7. Taylor expanded in y around 0 52.3%

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

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

Alternative 13: 58.4% accurate, 15.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.4 \cdot 10^{-20}:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.3999999999999996e-20 or 5.4e6 < x

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 69.8%

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

    if -8.3999999999999996e-20 < x < 5.4e6

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 99.8%

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

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

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

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

      \[\leadsto z \cdot \left(\frac{\sin y}{z} + \color{blue}{\cos y}\right) \]
    7. Taylor expanded in y around 0 51.4%

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

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

Alternative 14: 55.2% accurate, 18.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7.8 \cdot 10^{-20}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3300000:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -7.8e-20) x (if (<= x 3300000.0) z x)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -7.8e-20) {
		tmp = x;
	} else if (x <= 3300000.0) {
		tmp = z;
	} else {
		tmp = 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 (x <= (-7.8d-20)) then
        tmp = x
    else if (x <= 3300000.0d0) then
        tmp = z
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -7.8e-20) {
		tmp = x;
	} else if (x <= 3300000.0) {
		tmp = z;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -7.8e-20:
		tmp = x
	elif x <= 3300000.0:
		tmp = z
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -7.8e-20)
		tmp = x;
	elseif (x <= 3300000.0)
		tmp = z;
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -7.8e-20)
		tmp = x;
	elseif (x <= 3300000.0)
		tmp = z;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -7.8e-20], x, If[LessEqual[x, 3300000.0], z, x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{-20}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 3300000:\\
\;\;\;\;z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.80000000000000014e-20 or 3.3e6 < x

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 69.8%

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

    if -7.80000000000000014e-20 < x < 3.3e6

    1. Initial program 99.9%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 99.8%

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

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

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

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

      \[\leadsto z \cdot \left(\frac{\sin y}{z} + \color{blue}{\cos y}\right) \]
    7. Taylor expanded in y around 0 45.1%

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

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

Alternative 15: 42.5% accurate, 207.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x + \sin y\right) + z \cdot \cos y \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 39.6%

    \[\leadsto \color{blue}{x} \]
  4. Final simplification39.6%

    \[\leadsto x \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2024096 
(FPCore (x y z)
  :name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
  :precision binary64
  (+ (+ x (sin y)) (* z (cos y))))