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

Percentage Accurate: 99.9% → 99.9%
Time: 8.8s
Alternatives: 16
Speedup: 1.0×

Specification

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

\\
\left(x + \cos y\right) - z \cdot \sin 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 16 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 + \cos y\right) - z \cdot \sin y \end{array} \]
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
	return (x + cos(y)) - (z * sin(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 + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
	return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z):
	return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z)
	return Float64(Float64(x + cos(y)) - Float64(z * sin(y)))
end
function tmp = code(x, y, z)
	tmp = (x + cos(y)) - (z * sin(y));
end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

    \[\left(x + \cos y\right) - z \cdot \sin y \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 98.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := z \cdot \sin y\\
\mathbf{if}\;x \leq -1.95 \cdot 10^{-11} \lor \neg \left(x \leq 1.16 \cdot 10^{-63}\right):\\
\;\;\;\;\left(x + 1\right) - t\_0\\

\mathbf{else}:\\
\;\;\;\;\cos y - t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.95000000000000005e-11 or 1.16e-63 < x

    1. Initial program 99.9%

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

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

    if -1.95000000000000005e-11 < x < 1.16e-63

    1. Initial program 99.9%

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

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

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

Alternative 3: 98.7% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.00033 \lor \neg \left(z \leq 4.3 \cdot 10^{-46}\right):\\
\;\;\;\;\left(x + 1\right) - z \cdot \sin y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.3e-4 or 4.30000000000000035e-46 < z

    1. Initial program 99.9%

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

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

    if -3.3e-4 < z < 4.30000000000000035e-46

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x + \cos y} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\cos y + x} \]
    5. Simplified100.0%

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

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

Alternative 4: 93.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+25} \lor \neg \left(z \leq 6.2 \cdot 10^{+33}\right):\\
\;\;\;\;x - z \cdot \sin y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.1999999999999998e25 or 6.2e33 < z

    1. Initial program 99.9%

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

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

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

    if -4.1999999999999998e25 < z < 6.2e33

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos y + x} \]
    5. Simplified97.3%

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

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

Alternative 5: 81.6% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+132} \lor \neg \left(z \leq 6.2 \cdot 10^{+195}\right):\\
\;\;\;\;\sin y \cdot \left(-z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.99999999999999991e131 or 6.2000000000000004e195 < z

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \sin y\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg81.6%

        \[\leadsto \color{blue}{-z \cdot \sin y} \]
      2. distribute-rgt-neg-out81.6%

        \[\leadsto \color{blue}{z \cdot \left(-\sin y\right)} \]
    5. Simplified81.6%

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

    if -9.99999999999999991e131 < z < 6.2000000000000004e195

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos y + x} \]
    5. Simplified88.9%

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

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

Alternative 6: 81.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -35000000 \lor \neg \left(y \leq 1.05\right):\\
\;\;\;\;x + \cos y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.5e7 or 1.05000000000000004 < y

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\cos y + x} \]
    5. Simplified61.5%

      \[\leadsto \color{blue}{\cos y + x} \]

    if -3.5e7 < y < 1.05000000000000004

    1. Initial program 100.0%

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

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

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

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

Alternative 7: 69.5% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;x \leq 1.16 \cdot 10^{-63}:\\
\;\;\;\;\cos y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.50000000000000008e-77

    1. Initial program 99.9%

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

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

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

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

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

    if -1.50000000000000008e-77 < x < 1.16e-63

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\cos y - z \cdot \sin y} \]
    4. Taylor expanded in z around 0 67.2%

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

    if 1.16e-63 < x

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{x + 1} \]
    5. Simplified85.0%

      \[\leadsto \color{blue}{x + 1} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 69.8% accurate, 7.7× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

        \[\leadsto \color{blue}{x + 1} \]
    5. Simplified37.2%

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

    if -1.69999999999999989e32 < y < 62

    1. Initial program 100.0%

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

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

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

Alternative 9: 69.3% accurate, 8.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{+83} \lor \neg \left(y \leq 2.1\right):\\
\;\;\;\;x + 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.5999999999999997e83 or 2.10000000000000009 < y

    1. Initial program 99.8%

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

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

        \[\leadsto \color{blue}{x + 1} \]
    5. Simplified37.3%

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

    if -3.5999999999999997e83 < y < 2.10000000000000009

    1. Initial program 100.0%

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

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

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

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

Alternative 10: 69.7% accurate, 9.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+35} \lor \neg \left(y \leq 600000\right):\\
\;\;\;\;x + 1\\

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


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

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{x + 1} \]
    5. Simplified38.0%

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

    if -1.0499999999999999e35 < y < 6e5

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 11: 69.3% accurate, 12.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+120} \lor \neg \left(y \leq 520000\right):\\
\;\;\;\;x + 1\\

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


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

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{x + 1} \]
    5. Simplified38.2%

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

    if -7.9999999999999998e120 < y < 5.2e5

    1. Initial program 100.0%

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

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

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

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

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

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

Alternative 12: 60.9% accurate, 18.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 0.000115:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1 or 1.15e-4 < x

    1. Initial program 99.9%

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

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

    if -1 < x < 1.15e-4

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\cos y - z \cdot \sin y} \]
    4. Taylor expanded in y around 0 43.0%

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

Alternative 13: 61.6% accurate, 20.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{+139}:\\
\;\;\;\;1 - y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.00000000000000013e139

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\cos y - z \cdot \sin y} \]
    4. Taylor expanded in y around 0 54.1%

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

        \[\leadsto 1 + \color{blue}{\left(-y \cdot z\right)} \]
      2. *-commutative54.1%

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

        \[\leadsto \color{blue}{1 - z \cdot y} \]
    6. Simplified54.1%

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

    if -4.00000000000000013e139 < z

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{x + 1} \]
    5. Simplified70.1%

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

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

Alternative 14: 60.7% accurate, 23.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+139}:\\
\;\;\;\;y \cdot \left(-z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.1000000000000002e139

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\cos y - z \cdot \sin y} \]
    4. Taylor expanded in y around 0 54.1%

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

        \[\leadsto 1 + y \cdot \left(\color{blue}{y \cdot -0.5} - z\right) \]
    6. Simplified54.1%

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    8. Step-by-step derivation
      1. associate-*r*44.2%

        \[\leadsto \color{blue}{\left(-1 \cdot y\right) \cdot z} \]
      2. *-commutative44.2%

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

        \[\leadsto z \cdot \color{blue}{\left(-y\right)} \]
    9. Simplified44.2%

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

    if -4.1000000000000002e139 < z

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{x + 1} \]
    5. Simplified70.1%

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

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

Alternative 15: 61.6% accurate, 69.0× speedup?

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

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

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

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

      \[\leadsto \color{blue}{x + 1} \]
  5. Simplified62.5%

    \[\leadsto \color{blue}{x + 1} \]
  6. Add Preprocessing

Alternative 16: 21.9% accurate, 207.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\cos y - z \cdot \sin y} \]
  4. Taylor expanded in y around 0 23.8%

    \[\leadsto \color{blue}{1} \]
  5. Add Preprocessing

Reproduce

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