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

Percentage Accurate: 99.9% → 99.9%
Time: 8.8s
Alternatives: 14
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 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 + \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: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \sin y\\ \mathbf{if}\;x \leq -4 \cdot 10^{-13} \lor \neg \left(x \leq 2.35 \cdot 10^{-15}\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 -4e-13) (not (<= x 2.35e-15)))
     (- (+ 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 <= -4e-13) || !(x <= 2.35e-15)) {
		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 <= (-4d-13)) .or. (.not. (x <= 2.35d-15))) 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 <= -4e-13) || !(x <= 2.35e-15)) {
		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 <= -4e-13) or not (x <= 2.35e-15):
		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 <= -4e-13) || !(x <= 2.35e-15))
		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 <= -4e-13) || ~((x <= 2.35e-15)))
		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, -4e-13], N[Not[LessEqual[x, 2.35e-15]], $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 -4 \cdot 10^{-13} \lor \neg \left(x \leq 2.35 \cdot 10^{-15}\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 < -4.0000000000000001e-13 or 2.3499999999999999e-15 < 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 99.8%

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

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

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

    if -4.0000000000000001e-13 < x < 2.3499999999999999e-15

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-13} \lor \neg \left(x \leq 2.35 \cdot 10^{-15}\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.3% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -16000000 \lor \neg \left(z \leq 2.9 \cdot 10^{-61}\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 -16000000.0) (not (<= z 2.9e-61)))
   (- (+ x 1.0) (* z (sin y)))
   (+ x (cos y))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -16000000.0) || !(z <= 2.9e-61)) {
		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 <= (-16000000.0d0)) .or. (.not. (z <= 2.9d-61))) 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 <= -16000000.0) || !(z <= 2.9e-61)) {
		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 <= -16000000.0) or not (z <= 2.9e-61):
		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 <= -16000000.0) || !(z <= 2.9e-61))
		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 <= -16000000.0) || ~((z <= 2.9e-61)))
		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, -16000000.0], N[Not[LessEqual[z, 2.9e-61]], $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 -16000000 \lor \neg \left(z \leq 2.9 \cdot 10^{-61}\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 < -1.6e7 or 2.8999999999999999e-61 < 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.9%

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

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

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

    if -1.6e7 < z < 2.8999999999999999e-61

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

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

Alternative 4: 92.2% accurate, 1.8× speedup?

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

    1. Initial program 99.9%

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

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

    if -3e9 < z < 4.2e-7

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

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

Alternative 5: 84.3% accurate, 1.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.5e9 or 2.7000000000000001e56 < 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.4%

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

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

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

      \[\leadsto \color{blue}{1 - z \cdot \sin y} \]
    7. Step-by-step derivation
      1. *-commutative68.2%

        \[\leadsto 1 - \color{blue}{\sin y \cdot z} \]
    8. Simplified68.2%

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

    if -3.5e9 < z < 2.7000000000000001e56

    1. Initial program 100.0%

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

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

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

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

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

Alternative 6: 80.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{+178} \lor \neg \left(z \leq 2.5 \cdot 10^{+56}\right):\\
\;\;\;\;z \cdot \left(-\sin y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.49999999999999991e178 or 2.50000000000000012e56 < z

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{\left(-z\right)} \cdot \sin y \]
      3. *-commutative68.0%

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

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

    if -8.49999999999999991e178 < z < 2.50000000000000012e56

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

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

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

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

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

Alternative 7: 79.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{+25} \lor \neg \left(y \leq 1.75 \cdot 10^{+27}\right):\\ \;\;\;\;x + \cos y\\ \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 -6.4e+25) (not (<= y 1.75e+27)))
   (+ x (cos y))
   (+ 1.0 (+ x (* y (- (* y (- (* 0.16666666666666666 (* y z)) 0.5)) z))))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -6.4e+25) || !(y <= 1.75e+27)) {
		tmp = x + cos(y);
	} 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 <= (-6.4d+25)) .or. (.not. (y <= 1.75d+27))) then
        tmp = x + cos(y)
    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 <= -6.4e+25) || !(y <= 1.75e+27)) {
		tmp = x + Math.cos(y);
	} 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 <= -6.4e+25) or not (y <= 1.75e+27):
		tmp = x + math.cos(y)
	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 <= -6.4e+25) || !(y <= 1.75e+27))
		tmp = Float64(x + cos(y));
	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 <= -6.4e+25) || ~((y <= 1.75e+27)))
		tmp = x + cos(y);
	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, -6.4e+25], N[Not[LessEqual[y, 1.75e+27]], $MachinePrecision]], N[(x + N[Cos[y], $MachinePrecision]), $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 -6.4 \cdot 10^{+25} \lor \neg \left(y \leq 1.75 \cdot 10^{+27}\right):\\
\;\;\;\;x + \cos y\\

\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 < -6.3999999999999999e25 or 1.7500000000000001e27 < 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 62.1%

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

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

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

    if -6.3999999999999999e25 < y < 1.7500000000000001e27

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{+25} \lor \neg \left(y \leq 1.75 \cdot 10^{+27}\right):\\ \;\;\;\;x + \cos y\\ \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 8: 68.7% accurate, 7.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{+25} \lor \neg \left(y \leq 3\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 -6.4e+25) (not (<= y 3.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 <= -6.4e+25) || !(y <= 3.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 <= (-6.4d+25)) .or. (.not. (y <= 3.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 <= -6.4e+25) || !(y <= 3.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 <= -6.4e+25) or not (y <= 3.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 <= -6.4e+25) || !(y <= 3.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 <= -6.4e+25) || ~((y <= 3.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, -6.4e+25], N[Not[LessEqual[y, 3.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 -6.4 \cdot 10^{+25} \lor \neg \left(y \leq 3\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 < -6.3999999999999999e25 or 3 < 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 24.7%

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

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

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

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

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

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

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

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

    if -6.3999999999999999e25 < y < 3

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{+25} \lor \neg \left(y \leq 3\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: 68.6% accurate, 12.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.8000000000000004e59 or 4400 < 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 24.2%

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

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

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

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

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

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

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

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

    if -4.8000000000000004e59 < y < 4400

    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 + -1 \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. associate-+r+94.4%

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

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

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

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

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

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

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

Alternative 10: 66.2% accurate, 13.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-14} \lor \neg \left(x \leq 0.00084\right):\\
\;\;\;\;x + 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2e-14 or 8.4000000000000003e-4 < 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 68.8%

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

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

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

        \[\leadsto \color{blue}{x + \left(1 + -1 \cdot \left(y \cdot z\right)\right)} \]
      4. mul-1-neg68.8%

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

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

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

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

    if -2e-14 < x < 8.4000000000000003e-4

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 59.6% accurate, 18.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.50000000000000036e-8 or 1 < 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 68.8%

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

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

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

        \[\leadsto \color{blue}{x + \left(1 + -1 \cdot \left(y \cdot z\right)\right)} \]
      4. mul-1-neg68.8%

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

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

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

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

    if -9.50000000000000036e-8 < x < 1

    1. Initial program 99.9%

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

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

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

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

      \[\leadsto \color{blue}{\cos y} \]
    7. Taylor expanded in y around 0 38.0%

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

Alternative 12: 61.1% accurate, 23.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 7.4 \cdot 10^{+245}:\\
\;\;\;\;x + 1\\

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


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

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

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

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

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

        \[\leadsto \color{blue}{x + \left(1 + -1 \cdot \left(y \cdot z\right)\right)} \]
      4. mul-1-neg62.6%

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

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

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

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

    if 7.4000000000000002e245 < z

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-y \cdot z} \]
      2. *-commutative46.0%

        \[\leadsto -\color{blue}{z \cdot y} \]
      3. distribute-rgt-neg-in46.0%

        \[\leadsto \color{blue}{z \cdot \left(-y\right)} \]
    8. Simplified46.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 21.4% 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 z around 0 70.0%

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

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

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

    \[\leadsto \color{blue}{\cos y} \]
  7. Taylor expanded in y around 0 18.9%

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

Reproduce

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