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

Percentage Accurate: 99.9% → 99.9%
Time: 8.3s
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, 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-define100.0%

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

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

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

Alternative 2: 99.9% accurate, 1.0× speedup?

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

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

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

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

Alternative 3: 69.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;y \leq -1.9 \cdot 10^{+194}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq -1.18 \cdot 10^{+48}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+27}:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+286} \lor \neg \left(y \leq 7.5 \cdot 10^{+304}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (cos y))))
   (if (<= y -1.9e+194)
     (+ z x)
     (if (<= y -1.18e+48)
       t_0
       (if (<= y 2e+27)
         (+ z (+ y x))
         (if (or (<= y 4.5e+286) (not (<= y 7.5e+304))) t_0 (+ z x)))))))
double code(double x, double y, double z) {
	double t_0 = z * cos(y);
	double tmp;
	if (y <= -1.9e+194) {
		tmp = z + x;
	} else if (y <= -1.18e+48) {
		tmp = t_0;
	} else if (y <= 2e+27) {
		tmp = z + (y + x);
	} else if ((y <= 4.5e+286) || !(y <= 7.5e+304)) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = z * cos(y)
    if (y <= (-1.9d+194)) then
        tmp = z + x
    else if (y <= (-1.18d+48)) then
        tmp = t_0
    else if (y <= 2d+27) then
        tmp = z + (y + x)
    else if ((y <= 4.5d+286) .or. (.not. (y <= 7.5d+304))) then
        tmp = t_0
    else
        tmp = z + x
    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 (y <= -1.9e+194) {
		tmp = z + x;
	} else if (y <= -1.18e+48) {
		tmp = t_0;
	} else if (y <= 2e+27) {
		tmp = z + (y + x);
	} else if ((y <= 4.5e+286) || !(y <= 7.5e+304)) {
		tmp = t_0;
	} else {
		tmp = z + x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * math.cos(y)
	tmp = 0
	if y <= -1.9e+194:
		tmp = z + x
	elif y <= -1.18e+48:
		tmp = t_0
	elif y <= 2e+27:
		tmp = z + (y + x)
	elif (y <= 4.5e+286) or not (y <= 7.5e+304):
		tmp = t_0
	else:
		tmp = z + x
	return tmp
function code(x, y, z)
	t_0 = Float64(z * cos(y))
	tmp = 0.0
	if (y <= -1.9e+194)
		tmp = Float64(z + x);
	elseif (y <= -1.18e+48)
		tmp = t_0;
	elseif (y <= 2e+27)
		tmp = Float64(z + Float64(y + x));
	elseif ((y <= 4.5e+286) || !(y <= 7.5e+304))
		tmp = t_0;
	else
		tmp = Float64(z + x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * cos(y);
	tmp = 0.0;
	if (y <= -1.9e+194)
		tmp = z + x;
	elseif (y <= -1.18e+48)
		tmp = t_0;
	elseif (y <= 2e+27)
		tmp = z + (y + x);
	elseif ((y <= 4.5e+286) || ~((y <= 7.5e+304)))
		tmp = t_0;
	else
		tmp = z + x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.9e+194], N[(z + x), $MachinePrecision], If[LessEqual[y, -1.18e+48], t$95$0, If[LessEqual[y, 2e+27], N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 4.5e+286], N[Not[LessEqual[y, 7.5e+304]], $MachinePrecision]], t$95$0, N[(z + x), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;y \leq -1.9 \cdot 10^{+194}:\\
\;\;\;\;z + x\\

\mathbf{elif}\;y \leq -1.18 \cdot 10^{+48}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y \leq 4.5 \cdot 10^{+286} \lor \neg \left(y \leq 7.5 \cdot 10^{+304}\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.8999999999999999e194 or 4.4999999999999998e286 < y < 7.49999999999999954e304

    1. Initial program 99.9%

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

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

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

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

    if -1.8999999999999999e194 < y < -1.18000000000000007e48 or 2e27 < y < 4.4999999999999998e286 or 7.49999999999999954e304 < y

    1. Initial program 99.9%

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

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

    if -1.18000000000000007e48 < y < 2e27

    1. Initial program 100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+194}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq -1.18 \cdot 10^{+48}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+27}:\\ \;\;\;\;z + \left(y + x\right)\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+286} \lor \neg \left(y \leq 7.5 \cdot 10^{+304}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 84.4% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -1.8 \cdot 10^{+150}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{+44}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq -5000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-34}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+129}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (cos y))))
   (if (<= z -1.8e+150)
     t_0
     (if (<= z -2.1e+44)
       (+ z x)
       (if (<= z -5000000.0)
         t_0
         (if (<= z 1.5e-34)
           (+ x (sin y))
           (if (<= z 1.02e+129) (+ z x) t_0)))))))
double code(double x, double y, double z) {
	double t_0 = z * cos(y);
	double tmp;
	if (z <= -1.8e+150) {
		tmp = t_0;
	} else if (z <= -2.1e+44) {
		tmp = z + x;
	} else if (z <= -5000000.0) {
		tmp = t_0;
	} else if (z <= 1.5e-34) {
		tmp = x + sin(y);
	} else if (z <= 1.02e+129) {
		tmp = z + x;
	} 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.8d+150)) then
        tmp = t_0
    else if (z <= (-2.1d+44)) then
        tmp = z + x
    else if (z <= (-5000000.0d0)) then
        tmp = t_0
    else if (z <= 1.5d-34) then
        tmp = x + sin(y)
    else if (z <= 1.02d+129) then
        tmp = z + x
    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.8e+150) {
		tmp = t_0;
	} else if (z <= -2.1e+44) {
		tmp = z + x;
	} else if (z <= -5000000.0) {
		tmp = t_0;
	} else if (z <= 1.5e-34) {
		tmp = x + Math.sin(y);
	} else if (z <= 1.02e+129) {
		tmp = z + x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * math.cos(y)
	tmp = 0
	if z <= -1.8e+150:
		tmp = t_0
	elif z <= -2.1e+44:
		tmp = z + x
	elif z <= -5000000.0:
		tmp = t_0
	elif z <= 1.5e-34:
		tmp = x + math.sin(y)
	elif z <= 1.02e+129:
		tmp = z + x
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(z * cos(y))
	tmp = 0.0
	if (z <= -1.8e+150)
		tmp = t_0;
	elseif (z <= -2.1e+44)
		tmp = Float64(z + x);
	elseif (z <= -5000000.0)
		tmp = t_0;
	elseif (z <= 1.5e-34)
		tmp = Float64(x + sin(y));
	elseif (z <= 1.02e+129)
		tmp = Float64(z + x);
	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.8e+150)
		tmp = t_0;
	elseif (z <= -2.1e+44)
		tmp = z + x;
	elseif (z <= -5000000.0)
		tmp = t_0;
	elseif (z <= 1.5e-34)
		tmp = x + sin(y);
	elseif (z <= 1.02e+129)
		tmp = z + x;
	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.8e+150], t$95$0, If[LessEqual[z, -2.1e+44], N[(z + x), $MachinePrecision], If[LessEqual[z, -5000000.0], t$95$0, If[LessEqual[z, 1.5e-34], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.02e+129], N[(z + x), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.1 \cdot 10^{+44}:\\
\;\;\;\;z + x\\

\mathbf{elif}\;z \leq -5000000:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 1.02 \cdot 10^{+129}:\\
\;\;\;\;z + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.79999999999999993e150 or -2.09999999999999987e44 < z < -5e6 or 1.01999999999999996e129 < 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 84.0%

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

    if -1.79999999999999993e150 < z < -2.09999999999999987e44 or 1.5e-34 < z < 1.01999999999999996e129

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

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

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

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

    if -5e6 < z < 1.5e-34

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\sin y + x} \]
    5. Simplified93.1%

      \[\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 -1.8 \cdot 10^{+150}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{+44}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;z \leq -5000000:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-34}:\\ \;\;\;\;x + \sin y\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+129}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 94.8% accurate, 1.8× speedup?

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x} + \left(\frac{\sin y}{x} + z \cdot \frac{\cos y}{x}\right) \cdot x \]
      4. clear-num77.3%

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

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

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

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

    if -1.35e-76 < z < 1.4500000000000001e-34

    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 2 regimes into one program.
  4. Final simplification96.4%

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

Alternative 6: 70.8% accurate, 9.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.5 or 1.2e16 < 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 35.6%

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

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

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

    if -3.5 < y < 1.2e16

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

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

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

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

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

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

Alternative 7: 70.4% accurate, 13.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.2499999999999999e32 or 5.79999999999999975e107 < 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 36.7%

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

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

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

    if -1.2499999999999999e32 < y < 5.79999999999999975e107

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 8: 45.1% accurate, 15.9× speedup?

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

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

\mathbf{elif}\;y \leq 8.2 \cdot 10^{+196}:\\
\;\;\;\;y + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -165 or 8.1999999999999993e196 < y

    1. Initial program 99.9%

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

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

    if -165 < y < 8.1999999999999993e196

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{1 \cdot x + \left(\frac{\sin y}{x} + z \cdot \frac{\cos y}{x}\right) \cdot x} \]
      3. *-un-lft-identity88.5%

        \[\leadsto \color{blue}{x} + \left(\frac{\sin y}{x} + z \cdot \frac{\cos y}{x}\right) \cdot x \]
      4. clear-num88.5%

        \[\leadsto x + \left(\frac{\sin y}{x} + z \cdot \color{blue}{\frac{1}{\frac{x}{\cos y}}}\right) \cdot x \]
      5. un-div-inv88.6%

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

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

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

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

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

Alternative 9: 66.6% 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 65.5%

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

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

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

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

Alternative 10: 42.3% 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 46.2%

    \[\leadsto \color{blue}{x} \]
  4. Final simplification46.2%

    \[\leadsto x \]
  5. Add Preprocessing

Reproduce

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