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

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

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

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

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

Alternative 2: 89.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

    if -6e7 < x < 4e7

    1. Initial program 99.9%

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

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

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

Alternative 3: 67.2% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+177}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{+16}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;y \leq 0.83:\\ \;\;\;\;x + \left(z + y \cdot \left(1 + y \cdot \left(z \cdot -0.5 + y \cdot -0.16666666666666666\right)\right)\right)\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+179}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;x + z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -5.2e+177)
   (+ x z)
   (if (<= y -1.25e+16)
     (sin y)
     (if (<= y 0.83)
       (+
        x
        (+ z (* y (+ 1.0 (* y (+ (* z -0.5) (* y -0.16666666666666666)))))))
       (if (<= y 1.7e+179) (sin y) (+ x z))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5.2e+177) {
		tmp = x + z;
	} else if (y <= -1.25e+16) {
		tmp = sin(y);
	} else if (y <= 0.83) {
		tmp = x + (z + (y * (1.0 + (y * ((z * -0.5) + (y * -0.16666666666666666))))));
	} else if (y <= 1.7e+179) {
		tmp = sin(y);
	} else {
		tmp = x + z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-5.2d+177)) then
        tmp = x + z
    else if (y <= (-1.25d+16)) then
        tmp = sin(y)
    else if (y <= 0.83d0) then
        tmp = x + (z + (y * (1.0d0 + (y * ((z * (-0.5d0)) + (y * (-0.16666666666666666d0)))))))
    else if (y <= 1.7d+179) then
        tmp = sin(y)
    else
        tmp = x + z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -5.2e+177) {
		tmp = x + z;
	} else if (y <= -1.25e+16) {
		tmp = Math.sin(y);
	} else if (y <= 0.83) {
		tmp = x + (z + (y * (1.0 + (y * ((z * -0.5) + (y * -0.16666666666666666))))));
	} else if (y <= 1.7e+179) {
		tmp = Math.sin(y);
	} else {
		tmp = x + z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -5.2e+177:
		tmp = x + z
	elif y <= -1.25e+16:
		tmp = math.sin(y)
	elif y <= 0.83:
		tmp = x + (z + (y * (1.0 + (y * ((z * -0.5) + (y * -0.16666666666666666))))))
	elif y <= 1.7e+179:
		tmp = math.sin(y)
	else:
		tmp = x + z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -5.2e+177)
		tmp = Float64(x + z);
	elseif (y <= -1.25e+16)
		tmp = sin(y);
	elseif (y <= 0.83)
		tmp = Float64(x + Float64(z + Float64(y * Float64(1.0 + Float64(y * Float64(Float64(z * -0.5) + Float64(y * -0.16666666666666666)))))));
	elseif (y <= 1.7e+179)
		tmp = sin(y);
	else
		tmp = Float64(x + z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -5.2e+177)
		tmp = x + z;
	elseif (y <= -1.25e+16)
		tmp = sin(y);
	elseif (y <= 0.83)
		tmp = x + (z + (y * (1.0 + (y * ((z * -0.5) + (y * -0.16666666666666666))))));
	elseif (y <= 1.7e+179)
		tmp = sin(y);
	else
		tmp = x + z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -5.2e+177], N[(x + z), $MachinePrecision], If[LessEqual[y, -1.25e+16], N[Sin[y], $MachinePrecision], If[LessEqual[y, 0.83], N[(x + N[(z + N[(y * N[(1.0 + N[(y * N[(N[(z * -0.5), $MachinePrecision] + N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.7e+179], N[Sin[y], $MachinePrecision], N[(x + z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+177}:\\
\;\;\;\;x + z\\

\mathbf{elif}\;y \leq -1.25 \cdot 10^{+16}:\\
\;\;\;\;\sin y\\

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

\mathbf{elif}\;y \leq 1.7 \cdot 10^{+179}:\\
\;\;\;\;\sin y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.19999999999999959e177 or 1.69999999999999998e179 < 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} \]

    if -5.19999999999999959e177 < y < -1.25e16 or 0.82999999999999996 < y < 1.69999999999999998e179

    1. Initial program 99.8%

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{\sin y}{x} + 1\right)} \]
    6. Simplified64.7%

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

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

    if -1.25e16 < y < 0.82999999999999996

    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 + y \cdot \left(-0.5 \cdot z + -0.16666666666666666 \cdot y\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+177}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{+16}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;y \leq 0.83:\\ \;\;\;\;x + \left(z + y \cdot \left(1 + y \cdot \left(z \cdot -0.5 + y \cdot -0.16666666666666666\right)\right)\right)\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+179}:\\ \;\;\;\;\sin y\\ \mathbf{else}:\\ \;\;\;\;x + z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.0% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;z \leq -2.15 \cdot 10^{-135}:\\
\;\;\;\;z \cdot \left(\frac{\sin y}{z} + \left(1 + \frac{x}{z}\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.40000000000000022e113 or 9.5 < z

    1. Initial program 99.9%

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

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

    if -5.40000000000000022e113 < z < -2.14999999999999999e-135

    1. Initial program 100.0%

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

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

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

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

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

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

    if -2.14999999999999999e-135 < z < 9.5

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.4 \cdot 10^{+113}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;z \leq -2.15 \cdot 10^{-135}:\\ \;\;\;\;z \cdot \left(\frac{\sin y}{z} + \left(1 + \frac{x}{z}\right)\right)\\ \mathbf{elif}\;z \leq 9.5:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 82.9% accurate, 1.8× speedup?

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

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


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

    1. Initial program 99.9%

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

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

    if -4.1999999999999998e25 < z < 10

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\sin y + x} \]
    5. Simplified87.8%

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

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

Alternative 6: 73.5% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.09999999999999994e113 or 3.99999999999999983e111 < 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 89.1%

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

    if -5.09999999999999994e113 < z < 3.99999999999999983e111

    1. Initial program 100.0%

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

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

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

Alternative 7: 70.9% accurate, 7.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -30 or 17 < 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 31.6%

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

    if -30 < y < 17

    1. Initial program 100.0%

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

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

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

Alternative 8: 70.8% accurate, 9.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -55 \lor \neg \left(y \leq 17\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 -55.0) (not (<= y 17.0)))
   (+ x z)
   (+ (+ x z) (* y (+ 1.0 (* -0.5 (* y z)))))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -55.0) || !(y <= 17.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 <= (-55.0d0)) .or. (.not. (y <= 17.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 <= -55.0) || !(y <= 17.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 <= -55.0) or not (y <= 17.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 <= -55.0) || !(y <= 17.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 <= -55.0) || ~((y <= 17.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, -55.0], N[Not[LessEqual[y, 17.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 -55 \lor \neg \left(y \leq 17\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 < -55 or 17 < 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 31.6%

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

    if -55 < y < 17

    1. Initial program 100.0%

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

      \[\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+99.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -55 \lor \neg \left(y \leq 17\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 9: 70.4% accurate, 13.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.1500000000000001e99 or 0.19500000000000001 < 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 32.3%

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

    if -1.1500000000000001e99 < y < 0.19500000000000001

    1. Initial program 100.0%

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

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

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

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

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

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

Alternative 10: 54.8% accurate, 18.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{+27}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{+35}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -7.2e+27) x (if (<= x 5.9e+35) z x)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -7.2e+27) {
		tmp = x;
	} else if (x <= 5.9e+35) {
		tmp = z;
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-7.2d+27)) then
        tmp = x
    else if (x <= 5.9d+35) then
        tmp = z
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -7.2e+27) {
		tmp = x;
	} else if (x <= 5.9e+35) {
		tmp = z;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -7.2e+27:
		tmp = x
	elif x <= 5.9e+35:
		tmp = z
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -7.2e+27)
		tmp = x;
	elseif (x <= 5.9e+35)
		tmp = z;
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -7.2e+27)
		tmp = x;
	elseif (x <= 5.9e+35)
		tmp = z;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -7.2e+27], x, If[LessEqual[x, 5.9e+35], z, x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{+27}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 5.9 \cdot 10^{+35}:\\
\;\;\;\;z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.19999999999999966e27 or 5.89999999999999985e35 < 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 99.9%

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

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

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

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

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

    if -7.19999999999999966e27 < x < 5.89999999999999985e35

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{x + z} \]
    4. Taylor expanded in x around 0 36.8%

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

Alternative 11: 44.0% accurate, 18.8× speedup?

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

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

\mathbf{elif}\;x \leq 2.05 \cdot 10^{-283}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.0000000000000003e-126 or 2.04999999999999993e-283 < 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 99.9%

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{\sin y}{x} + 1\right)} \]
    6. Simplified56.8%

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

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

    if -6.0000000000000003e-126 < x < 2.04999999999999993e-283

    1. Initial program 99.9%

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

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

      \[\leadsto \color{blue}{y + z} \]
    5. Taylor expanded in y around inf 20.5%

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

Alternative 12: 66.4% 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 61.8%

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

Alternative 13: 42.6% 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 99.9%

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

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{\sin y}{x} + 1\right)} \]
  6. Simplified54.0%

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

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

Reproduce

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