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

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

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

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

Alternative 2: 84.7% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;z \leq -5.4 \cdot 10^{-23}:\\
\;\;\;\;x + z\\

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

\mathbf{elif}\;z \leq 6.6 \cdot 10^{+165}:\\
\;\;\;\;x + z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.2499999999999999e174 or 6.5999999999999997e165 < z

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{x} + z \cdot \cos y \]
    4. Taylor expanded in x around inf 61.7%

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

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

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

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

    if -1.2499999999999999e174 < z < -5.3999999999999997e-23 or 2.99999999999999994e-16 < z < 6.5999999999999997e165

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

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

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

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

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

    if -5.3999999999999997e-23 < z < 2.99999999999999994e-16

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+174}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;z \leq -5.4 \cdot 10^{-23}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-16}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{+165}:\\ \;\;\;\;x + z\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 71.0% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{+175}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-94}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-57}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+165}:\\ \;\;\;\;x + z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (cos y))))
   (if (<= z -1.3e+175)
     t_0
     (if (<= z 3.6e-94)
       (+ x z)
       (if (<= z 1.6e-57) (sin y) (if (<= z 6.5e+165) (+ x z) t_0))))))
double code(double x, double y, double z) {
	double t_0 = z * cos(y);
	double tmp;
	if (z <= -1.3e+175) {
		tmp = t_0;
	} else if (z <= 3.6e-94) {
		tmp = x + z;
	} else if (z <= 1.6e-57) {
		tmp = sin(y);
	} else if (z <= 6.5e+165) {
		tmp = x + z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = z * cos(y)
    if (z <= (-1.3d+175)) then
        tmp = t_0
    else if (z <= 3.6d-94) then
        tmp = x + z
    else if (z <= 1.6d-57) then
        tmp = sin(y)
    else if (z <= 6.5d+165) then
        tmp = x + z
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * Math.cos(y);
	double tmp;
	if (z <= -1.3e+175) {
		tmp = t_0;
	} else if (z <= 3.6e-94) {
		tmp = x + z;
	} else if (z <= 1.6e-57) {
		tmp = Math.sin(y);
	} else if (z <= 6.5e+165) {
		tmp = x + z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * math.cos(y)
	tmp = 0
	if z <= -1.3e+175:
		tmp = t_0
	elif z <= 3.6e-94:
		tmp = x + z
	elif z <= 1.6e-57:
		tmp = math.sin(y)
	elif z <= 6.5e+165:
		tmp = x + z
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(z * cos(y))
	tmp = 0.0
	if (z <= -1.3e+175)
		tmp = t_0;
	elseif (z <= 3.6e-94)
		tmp = Float64(x + z);
	elseif (z <= 1.6e-57)
		tmp = sin(y);
	elseif (z <= 6.5e+165)
		tmp = Float64(x + z);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * cos(y);
	tmp = 0.0;
	if (z <= -1.3e+175)
		tmp = t_0;
	elseif (z <= 3.6e-94)
		tmp = x + z;
	elseif (z <= 1.6e-57)
		tmp = sin(y);
	elseif (z <= 6.5e+165)
		tmp = x + z;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.3e+175], t$95$0, If[LessEqual[z, 3.6e-94], N[(x + z), $MachinePrecision], If[LessEqual[z, 1.6e-57], N[Sin[y], $MachinePrecision], If[LessEqual[z, 6.5e+165], N[(x + z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 3.6 \cdot 10^{-94}:\\
\;\;\;\;x + z\\

\mathbf{elif}\;z \leq 1.6 \cdot 10^{-57}:\\
\;\;\;\;\sin y\\

\mathbf{elif}\;z \leq 6.5 \cdot 10^{+165}:\\
\;\;\;\;x + z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.3e175 or 6.4999999999999999e165 < z

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{x} + z \cdot \cos y \]
    4. Taylor expanded in x around inf 61.7%

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

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

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

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

    if -1.3e175 < z < 3.6e-94 or 1.6e-57 < z < 6.4999999999999999e165

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{z + x} \]
    6. Simplified79.0%

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

    if 3.6e-94 < z < 1.6e-57

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+175}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-94}:\\ \;\;\;\;x + z\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-57}:\\ \;\;\;\;\sin y\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+165}:\\ \;\;\;\;x + z\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-12} \lor \neg \left(z \leq 4.5 \cdot 10^{+18}\right):\\
\;\;\;\;x + z \cdot \cos y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.7e-12 or 4.5e18 < z

    1. Initial program 99.8%

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

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

    if -1.7e-12 < z < 4.5e18

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

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

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

Alternative 5: 95.4% accurate, 1.8× speedup?

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

    1. Initial program 99.8%

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

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

    if -4.3000000000000002e-18 < z < 5.99999999999999987e-16

    1. Initial program 100.0%

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

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

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

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

Alternative 6: 70.0% accurate, 10.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.1:\\ \;\;\;\;x + z\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{+20}:\\ \;\;\;\;z + \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(x \cdot \frac{1}{x}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.1)
   (+ x z)
   (if (<= y 1.45e+20) (+ z (+ x y)) (+ x (* z (* x (/ 1.0 x)))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.1) {
		tmp = x + z;
	} else if (y <= 1.45e+20) {
		tmp = z + (x + y);
	} else {
		tmp = x + (z * (x * (1.0 / x)));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-3.1d0)) then
        tmp = x + z
    else if (y <= 1.45d+20) then
        tmp = z + (x + y)
    else
        tmp = x + (z * (x * (1.0d0 / x)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.1) {
		tmp = x + z;
	} else if (y <= 1.45e+20) {
		tmp = z + (x + y);
	} else {
		tmp = x + (z * (x * (1.0 / x)));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -3.1:
		tmp = x + z
	elif y <= 1.45e+20:
		tmp = z + (x + y)
	else:
		tmp = x + (z * (x * (1.0 / x)))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.1)
		tmp = Float64(x + z);
	elseif (y <= 1.45e+20)
		tmp = Float64(z + Float64(x + y));
	else
		tmp = Float64(x + Float64(z * Float64(x * Float64(1.0 / x))));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -3.1)
		tmp = x + z;
	elseif (y <= 1.45e+20)
		tmp = z + (x + y);
	else
		tmp = x + (z * (x * (1.0 / x)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -3.1], N[(x + z), $MachinePrecision], If[LessEqual[y, 1.45e+20], N[(z + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(x * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1:\\
\;\;\;\;x + z\\

\mathbf{elif}\;y \leq 1.45 \cdot 10^{+20}:\\
\;\;\;\;z + \left(x + y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.10000000000000009

    1. Initial program 99.8%

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

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

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

        \[\leadsto \color{blue}{z + x} \]
    6. Simplified53.8%

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

    if -3.10000000000000009 < y < 1.45e20

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

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

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

        \[\leadsto \color{blue}{\left(y + x\right)} + z \]
    6. Simplified96.7%

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

    if 1.45e20 < y

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{x} + z \cdot \cos y \]
    4. Taylor expanded in x around inf 74.7%

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(z \cdot \frac{\cos y}{x} + 1\right)} \]
      2. distribute-rgt-in74.7%

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

        \[\leadsto \color{blue}{z \cdot \left(\frac{\cos y}{x} \cdot x\right)} + 1 \cdot x \]
      4. *-un-lft-identity79.8%

        \[\leadsto z \cdot \left(\frac{\cos y}{x} \cdot x\right) + \color{blue}{x} \]
    8. Applied egg-rr79.8%

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

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

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

Alternative 7: 70.0% accurate, 13.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.10000000000000009 or 3.4e20 < y

    1. Initial program 99.8%

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

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

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

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

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

    if -3.10000000000000009 < y < 3.4e20

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

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

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

        \[\leadsto \color{blue}{\left(y + x\right)} + z \]
    6. Simplified96.7%

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

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

Alternative 8: 45.8% accurate, 15.9× speedup?

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

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

\mathbf{elif}\;y \leq 2 \cdot 10^{+52}:\\
\;\;\;\;x + y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.5 or 2e52 < y

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{x} + z \cdot \cos y \]
    4. Taylor expanded in x around inf 50.9%

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

    if -9.5 < y < 2e52

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

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

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

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

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

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

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

Alternative 9: 65.7% 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 x around inf 85.8%

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

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

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

    \[\leadsto \color{blue}{z + x} \]
  7. Final simplification71.4%

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

Alternative 10: 41.7% 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 85.8%

    \[\leadsto \color{blue}{x} + z \cdot \cos y \]
  4. Taylor expanded in x around inf 47.4%

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

Reproduce

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