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

Percentage Accurate: 99.9% → 99.9%
Time: 8.0s
Alternatives: 14
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 14 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, 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. Add Preprocessing

Alternative 2: 95.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-27} \lor \neg \left(x \leq 0.036\right):\\
\;\;\;\;x \cdot \left(1 + \cos y \cdot \frac{z}{x}\right)\\

\mathbf{else}:\\
\;\;\;\;\sin y + z \cdot \cos y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.10000000000000015e-27 or 0.0359999999999999973 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -2.10000000000000015e-27 < x < 0.0359999999999999973

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\sin y + z \cdot \cos y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.0%

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

Alternative 3: 89.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+202}:\\
\;\;\;\;z \cdot \cos y + \left(x + y\right)\\

\mathbf{elif}\;z \leq -6 \cdot 10^{+26} \lor \neg \left(z \leq 5.5 \cdot 10^{-32}\right):\\
\;\;\;\;x \cdot \left(1 + \cos y \cdot \frac{z}{x}\right)\\

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


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

    1. Initial program 99.9%

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

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

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

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

    if -1.80000000000000004e202 < z < -5.99999999999999994e26 or 5.50000000000000024e-32 < z

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if -5.99999999999999994e26 < z < 5.50000000000000024e-32

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

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

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

Alternative 4: 90.1% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+205}:\\
\;\;\;\;z \cdot \cos y + \left(x + y\right)\\

\mathbf{elif}\;z \leq -6 \cdot 10^{+26} \lor \neg \left(z \leq 6.6 \cdot 10^{+18}\right):\\
\;\;\;\;x \cdot \left(1 + z \cdot \frac{\cos y}{x}\right)\\

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


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

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\left(y + x\right)} + z \cdot \cos y \]
    5. Simplified95.9%

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

    if -5.0000000000000002e205 < z < -5.99999999999999994e26 or 6.6e18 < z

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

    if -5.99999999999999994e26 < z < 6.6e18

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{+205}:\\ \;\;\;\;z \cdot \cos y + \left(x + y\right)\\ \mathbf{elif}\;z \leq -6 \cdot 10^{+26} \lor \neg \left(z \leq 6.6 \cdot 10^{+18}\right):\\ \;\;\;\;x \cdot \left(1 + z \cdot \frac{\cos y}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \sin y\right) + z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.8% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.25 \cdot 10^{+209}:\\ \;\;\;\;t\_0 + \left(x + y\right)\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{+27} \lor \neg \left(z \leq 2.2 \cdot 10^{+111}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(x + \sin y\right) + z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (cos y))))
   (if (<= z -1.25e+209)
     (+ t_0 (+ x y))
     (if (or (<= z -2.8e+27) (not (<= z 2.2e+111))) t_0 (+ (+ x (sin y)) z)))))
double code(double x, double y, double z) {
	double t_0 = z * cos(y);
	double tmp;
	if (z <= -1.25e+209) {
		tmp = t_0 + (x + y);
	} else if ((z <= -2.8e+27) || !(z <= 2.2e+111)) {
		tmp = t_0;
	} else {
		tmp = (x + sin(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) :: t_0
    real(8) :: tmp
    t_0 = z * cos(y)
    if (z <= (-1.25d+209)) then
        tmp = t_0 + (x + y)
    else if ((z <= (-2.8d+27)) .or. (.not. (z <= 2.2d+111))) then
        tmp = t_0
    else
        tmp = (x + sin(y)) + z
    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 <= -1.25e+209) {
		tmp = t_0 + (x + y);
	} else if ((z <= -2.8e+27) || !(z <= 2.2e+111)) {
		tmp = t_0;
	} else {
		tmp = (x + Math.sin(y)) + z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * math.cos(y)
	tmp = 0
	if z <= -1.25e+209:
		tmp = t_0 + (x + y)
	elif (z <= -2.8e+27) or not (z <= 2.2e+111):
		tmp = t_0
	else:
		tmp = (x + math.sin(y)) + z
	return tmp
function code(x, y, z)
	t_0 = Float64(z * cos(y))
	tmp = 0.0
	if (z <= -1.25e+209)
		tmp = Float64(t_0 + Float64(x + y));
	elseif ((z <= -2.8e+27) || !(z <= 2.2e+111))
		tmp = t_0;
	else
		tmp = Float64(Float64(x + sin(y)) + z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * cos(y);
	tmp = 0.0;
	if (z <= -1.25e+209)
		tmp = t_0 + (x + y);
	elseif ((z <= -2.8e+27) || ~((z <= 2.2e+111)))
		tmp = t_0;
	else
		tmp = (x + sin(y)) + z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.25e+209], N[(t$95$0 + N[(x + y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -2.8e+27], N[Not[LessEqual[z, 2.2e+111]], $MachinePrecision]], t$95$0, N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.8 \cdot 10^{+27} \lor \neg \left(z \leq 2.2 \cdot 10^{+111}\right):\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 99.9%

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

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

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

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

    if -1.24999999999999991e209 < z < -2.7999999999999999e27 or 2.19999999999999999e111 < 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 79.6%

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

    if -2.7999999999999999e27 < z < 2.19999999999999999e111

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+209}:\\ \;\;\;\;z \cdot \cos y + \left(x + y\right)\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{+27} \lor \neg \left(z \leq 2.2 \cdot 10^{+111}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;\left(x + \sin y\right) + z\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 71.5% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+27}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-204}:\\ \;\;\;\;z + \left(x + y\right)\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+111}:\\ \;\;\;\;x + z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (cos y))))
   (if (<= z -1.9e+27)
     t_0
     (if (<= z 8.6e-204) (+ z (+ x y)) (if (<= z 1.15e+111) (+ x z) t_0)))))
double code(double x, double y, double z) {
	double t_0 = z * cos(y);
	double tmp;
	if (z <= -1.9e+27) {
		tmp = t_0;
	} else if (z <= 8.6e-204) {
		tmp = z + (x + y);
	} else if (z <= 1.15e+111) {
		tmp = x + z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = z * cos(y)
    if (z <= (-1.9d+27)) then
        tmp = t_0
    else if (z <= 8.6d-204) then
        tmp = z + (x + y)
    else if (z <= 1.15d+111) then
        tmp = x + z
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * Math.cos(y);
	double tmp;
	if (z <= -1.9e+27) {
		tmp = t_0;
	} else if (z <= 8.6e-204) {
		tmp = z + (x + y);
	} else if (z <= 1.15e+111) {
		tmp = x + z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * math.cos(y)
	tmp = 0
	if z <= -1.9e+27:
		tmp = t_0
	elif z <= 8.6e-204:
		tmp = z + (x + y)
	elif z <= 1.15e+111:
		tmp = x + z
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(z * cos(y))
	tmp = 0.0
	if (z <= -1.9e+27)
		tmp = t_0;
	elseif (z <= 8.6e-204)
		tmp = Float64(z + Float64(x + y));
	elseif (z <= 1.15e+111)
		tmp = Float64(x + z);
	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 <= -1.9e+27)
		tmp = t_0;
	elseif (z <= 8.6e-204)
		tmp = z + (x + y);
	elseif (z <= 1.15e+111)
		tmp = x + z;
	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, -1.9e+27], t$95$0, If[LessEqual[z, 8.6e-204], N[(z + N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e+111], N[(x + z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -1.9 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 1.15 \cdot 10^{+111}:\\
\;\;\;\;x + z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.90000000000000011e27 or 1.15000000000000001e111 < 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 78.2%

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

    if -1.90000000000000011e27 < z < 8.6000000000000005e-204

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

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

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

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

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

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

    if 8.6000000000000005e-204 < z < 1.15000000000000001e111

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+27}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-204}:\\ \;\;\;\;z + \left(x + y\right)\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+111}:\\ \;\;\;\;x + z\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 88.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.05 \cdot 10^{+27} \lor \neg \left(z \leq 1.55 \cdot 10^{+111}\right):\\
\;\;\;\;z \cdot \cos y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.0499999999999999e27 or 1.55e111 < 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 78.2%

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

    if -3.0499999999999999e27 < z < 1.55e111

    1. Initial program 100.0%

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

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

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

Alternative 8: 82.8% accurate, 1.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.3e22 or 4.3e15 < 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 75.9%

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

    if -1.3e22 < z < 4.3e15

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\sin y + x} \]
    5. Simplified89.3%

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

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

Alternative 9: 71.3% accurate, 9.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.85e17 or 7600 < 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 42.8%

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

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

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

    if -2.85e17 < y < 7600

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

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

Alternative 10: 71.1% accurate, 13.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+41} \lor \neg \left(y \leq 9.5 \cdot 10^{+25}\right):\\
\;\;\;\;x + z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.5000000000000003e41 or 9.5000000000000005e25 < 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 42.3%

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

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

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

    if -5.5000000000000003e41 < y < 9.5000000000000005e25

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 11: 46.6% accurate, 15.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.6 \cdot 10^{+30}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.4 \cdot 10^{+111}:\\
\;\;\;\;x + y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.5999999999999997e30 or 1.4e111 < y

    1. Initial program 99.8%

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

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

    if -9.5999999999999997e30 < y < 1.4e111

    1. Initial program 100.0%

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

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

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

      \[\leadsto \color{blue}{\sin y + x} \]
    6. Taylor expanded in y around 0 50.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.6 \cdot 10^{+30}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+111}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 44.4% accurate, 18.8× speedup?

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

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

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-222}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.50000000000000017e-38 or 1.6e-222 < 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 55.3%

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

    if -2.50000000000000017e-38 < x < 1.6e-222

    1. Initial program 99.8%

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

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

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

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

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

      \[\leadsto \color{blue}{y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 67.1% accurate, 69.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{z + x} \]
  6. Final simplification64.3%

    \[\leadsto x + z \]
  7. Add Preprocessing

Alternative 14: 43.1% 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 40.8%

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

Reproduce

?
herbie shell --seed 2024111 
(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))))