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

Percentage Accurate: 99.9% → 99.9%
Time: 8.6s
Alternatives: 11
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 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.7× speedup?

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

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

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

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

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

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

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

Alternative 2: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+32}:\\ \;\;\;\;x + z \cdot \cos y\\ \mathbf{elif}\;z \leq 1.7:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, \cos y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.3e+32)
   (+ x (* z (cos y)))
   (if (<= z 1.7) (+ z (+ x (sin y))) (fma z (cos y) x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.3e+32) {
		tmp = x + (z * cos(y));
	} else if (z <= 1.7) {
		tmp = z + (x + sin(y));
	} else {
		tmp = fma(z, cos(y), x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.3e+32)
		tmp = Float64(x + Float64(z * cos(y)));
	elseif (z <= 1.7)
		tmp = Float64(z + Float64(x + sin(y)));
	else
		tmp = fma(z, cos(y), x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -1.3e+32], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.7], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[Cos[y], $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+32}:\\
\;\;\;\;x + z \cdot \cos y\\

\mathbf{elif}\;z \leq 1.7:\\
\;\;\;\;z + \left(x + \sin y\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \cos y, x\right)\\


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

    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} + z \cdot \cos y \]

    if -1.3000000000000001e32 < z < 1.69999999999999996

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

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

    if 1.69999999999999996 < z

    1. Initial program 99.8%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, \cos y, x + \sin y\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 99.7%

      \[\leadsto \mathsf{fma}\left(z, \cos y, \color{blue}{x}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+32}:\\ \;\;\;\;x + z \cdot \cos y\\ \mathbf{elif}\;z \leq 1.7:\\ \;\;\;\;z + \left(x + \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, \cos y, x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.9% accurate, 1.0× speedup?

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

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

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

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

Alternative 4: 84.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -7.2 \cdot 10^{+99}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -1.36 \cdot 10^{-6}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 52000000000:\\ \;\;\;\;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 -7.2e+99)
     t_0
     (if (<= z -1.36e-6)
       (+ z x)
       (if (<= z 52000000000.0) (+ x (sin y)) t_0)))))
double code(double x, double y, double z) {
	double t_0 = z * cos(y);
	double tmp;
	if (z <= -7.2e+99) {
		tmp = t_0;
	} else if (z <= -1.36e-6) {
		tmp = z + x;
	} else if (z <= 52000000000.0) {
		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 <= (-7.2d+99)) then
        tmp = t_0
    else if (z <= (-1.36d-6)) then
        tmp = z + x
    else if (z <= 52000000000.0d0) 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 <= -7.2e+99) {
		tmp = t_0;
	} else if (z <= -1.36e-6) {
		tmp = z + x;
	} else if (z <= 52000000000.0) {
		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 <= -7.2e+99:
		tmp = t_0
	elif z <= -1.36e-6:
		tmp = z + x
	elif z <= 52000000000.0:
		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 <= -7.2e+99)
		tmp = t_0;
	elseif (z <= -1.36e-6)
		tmp = Float64(z + x);
	elseif (z <= 52000000000.0)
		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 <= -7.2e+99)
		tmp = t_0;
	elseif (z <= -1.36e-6)
		tmp = z + x;
	elseif (z <= 52000000000.0)
		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, -7.2e+99], t$95$0, If[LessEqual[z, -1.36e-6], N[(z + x), $MachinePrecision], If[LessEqual[z, 52000000000.0], 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 -7.2 \cdot 10^{+99}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -1.36 \cdot 10^{-6}:\\
\;\;\;\;z + x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.2000000000000003e99 or 5.2e10 < 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 81.6%

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

    if -7.2000000000000003e99 < z < -1.3599999999999999e-6

    1. Initial program 99.9%

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

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

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

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

    if -1.3599999999999999e-6 < z < 5.2e10

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\sin y + x} \]
    5. Simplified95.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.2 \cdot 10^{+99}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;z \leq -1.36 \cdot 10^{-6}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq 52000000000:\\ \;\;\;\;x + \sin y\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 95.6% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.00000000000000033e-5 or 1.4999999999999999e-25 < z

    1. Initial program 99.9%

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

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

    if -4.00000000000000033e-5 < z < 1.4999999999999999e-25

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\sin y + x} \]
    5. Simplified96.7%

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

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

Alternative 6: 99.0% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.3000000000000001e32 or 2.7000000000000002 < z

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

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

    if -1.3000000000000001e32 < z < 2.7000000000000002

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

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

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

Alternative 7: 73.4% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.15 \cdot 10^{+102} \lor \neg \left(z \leq 5.6 \cdot 10^{+102}\right):\\
\;\;\;\;z \cdot \cos y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.15e102 or 5.60000000000000037e102 < 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 86.0%

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

    if -2.15e102 < z < 5.60000000000000037e102

    1. Initial program 100.0%

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

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

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

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

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

Alternative 8: 70.3% accurate, 7.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -160000000000 \lor \neg \left(y \leq 0.59\right):\\ \;\;\;\;z + x\\ \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 -160000000000.0) (not (<= y 0.59)))
   (+ z x)
   (+ x (+ z (* y (+ 1.0 (* y (+ (* z -0.5) (* y -0.16666666666666666)))))))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -160000000000.0) || !(y <= 0.59)) {
		tmp = z + x;
	} 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 <= (-160000000000.0d0)) .or. (.not. (y <= 0.59d0))) then
        tmp = z + x
    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 <= -160000000000.0) || !(y <= 0.59)) {
		tmp = z + x;
	} 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 <= -160000000000.0) or not (y <= 0.59):
		tmp = z + x
	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 <= -160000000000.0) || !(y <= 0.59))
		tmp = Float64(z + x);
	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 <= -160000000000.0) || ~((y <= 0.59)))
		tmp = z + x;
	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, -160000000000.0], N[Not[LessEqual[y, 0.59]], $MachinePrecision]], N[(z + x), $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 -160000000000 \lor \neg \left(y \leq 0.59\right):\\
\;\;\;\;z + x\\

\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 < -1.6e11 or 0.589999999999999969 < y

    1. Initial program 99.9%

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

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

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

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

    if -1.6e11 < y < 0.589999999999999969

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -160000000000 \lor \neg \left(y \leq 0.59\right):\\ \;\;\;\;z + x\\ \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 9: 54.6% accurate, 18.8× speedup?

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

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-76}:\\
\;\;\;\;z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.9000000000000002e28 or 5.1999999999999999e-76 < x

    1. Initial program 100.0%

      \[\left(x + \sin y\right) + z \cdot \cos y \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt99.5%

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

        \[\leadsto \left(x + \sin y\right) + \color{blue}{{\left(\sqrt[3]{z \cdot \cos y}\right)}^{3}} \]
    4. Applied egg-rr99.5%

      \[\leadsto \left(x + \sin y\right) + \color{blue}{{\left(\sqrt[3]{z \cdot \cos y}\right)}^{3}} \]
    5. Taylor expanded in x around inf 69.7%

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

    if -5.9000000000000002e28 < x < 5.1999999999999999e-76

    1. Initial program 99.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.9 \cdot 10^{+28}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-76}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 65.8% accurate, 69.0× speedup?

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

\\
z + 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 y around 0 63.6%

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

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

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

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

Alternative 11: 42.9% 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. Step-by-step derivation
    1. add-cube-cbrt99.2%

      \[\leadsto \left(x + \sin y\right) + \color{blue}{\left(\sqrt[3]{z \cdot \cos y} \cdot \sqrt[3]{z \cdot \cos y}\right) \cdot \sqrt[3]{z \cdot \cos y}} \]
    2. pow399.2%

      \[\leadsto \left(x + \sin y\right) + \color{blue}{{\left(\sqrt[3]{z \cdot \cos y}\right)}^{3}} \]
  4. Applied egg-rr99.2%

    \[\leadsto \left(x + \sin y\right) + \color{blue}{{\left(\sqrt[3]{z \cdot \cos y}\right)}^{3}} \]
  5. Taylor expanded in x around inf 41.9%

    \[\leadsto \color{blue}{x} \]
  6. Final simplification41.9%

    \[\leadsto x \]
  7. Add Preprocessing

Reproduce

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