
(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:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (<= x -3.6e-16) (+ x z) (if (<= x 6.2e-15) (+ (sin y) (* z (cos y))) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.6e-16) {
tmp = x + z;
} else if (x <= 6.2e-15) {
tmp = sin(y) + (z * cos(y));
} else {
tmp = x + z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-3.6d-16)) then
tmp = x + z
else if (x <= 6.2d-15) then
tmp = sin(y) + (z * cos(y))
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.6e-16) {
tmp = x + z;
} else if (x <= 6.2e-15) {
tmp = Math.sin(y) + (z * Math.cos(y));
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.6e-16: tmp = x + z elif x <= 6.2e-15: tmp = math.sin(y) + (z * math.cos(y)) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.6e-16) tmp = Float64(x + z); elseif (x <= 6.2e-15) tmp = Float64(sin(y) + Float64(z * cos(y))); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.6e-16) tmp = x + z; elseif (x <= 6.2e-15) tmp = sin(y) + (z * cos(y)); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.6e-16], N[(x + z), $MachinePrecision], If[LessEqual[x, 6.2e-15], N[(N[Sin[y], $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{-16}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-15}:\\
\;\;\;\;\sin y + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if x < -3.59999999999999983e-16 or 6.1999999999999998e-15 < x Initial program 100.0%
Taylor expanded in y around 0 88.7%
+-commutative88.7%
Simplified88.7%
if -3.59999999999999983e-16 < x < 6.1999999999999998e-15Initial program 99.9%
Taylor expanded in x around 0 88.8%
Final simplification88.7%
(FPCore (x y z)
:precision binary64
(if (<= y -11.0)
(+ x z)
(if (<= y 1.7e+29)
(+ x (+ y (+ z (* -0.5 (* z (* y y))))))
(if (<= y 8e+140) (sin y) (+ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -11.0) {
tmp = x + z;
} else if (y <= 1.7e+29) {
tmp = x + (y + (z + (-0.5 * (z * (y * y)))));
} else if (y <= 8e+140) {
tmp = sin(y);
} else {
tmp = x + z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-11.0d0)) then
tmp = x + z
else if (y <= 1.7d+29) then
tmp = x + (y + (z + ((-0.5d0) * (z * (y * y)))))
else if (y <= 8d+140) then
tmp = sin(y)
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -11.0) {
tmp = x + z;
} else if (y <= 1.7e+29) {
tmp = x + (y + (z + (-0.5 * (z * (y * y)))));
} else if (y <= 8e+140) {
tmp = Math.sin(y);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -11.0: tmp = x + z elif y <= 1.7e+29: tmp = x + (y + (z + (-0.5 * (z * (y * y))))) elif y <= 8e+140: tmp = math.sin(y) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -11.0) tmp = Float64(x + z); elseif (y <= 1.7e+29) tmp = Float64(x + Float64(y + Float64(z + Float64(-0.5 * Float64(z * Float64(y * y)))))); elseif (y <= 8e+140) tmp = sin(y); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -11.0) tmp = x + z; elseif (y <= 1.7e+29) tmp = x + (y + (z + (-0.5 * (z * (y * y))))); elseif (y <= 8e+140) tmp = sin(y); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -11.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 1.7e+29], N[(x + N[(y + N[(z + N[(-0.5 * N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e+140], N[Sin[y], $MachinePrecision], N[(x + z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -11:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+29}:\\
\;\;\;\;x + \left(y + \left(z + -0.5 \cdot \left(z \cdot \left(y \cdot y\right)\right)\right)\right)\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+140}:\\
\;\;\;\;\sin y\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -11 or 8.00000000000000047e140 < y Initial program 99.9%
Taylor expanded in y around 0 43.3%
+-commutative43.3%
Simplified43.3%
if -11 < y < 1.69999999999999991e29Initial program 100.0%
Taylor expanded in y around 0 97.2%
*-commutative97.2%
unpow297.2%
Simplified97.2%
if 1.69999999999999991e29 < y < 8.00000000000000047e140Initial program 100.0%
Taylor expanded in x around 0 73.0%
Taylor expanded in z around 0 59.7%
Final simplification73.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.3e+54) (not (<= z 5.5e+136))) (* z (cos y)) (+ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e+54) || !(z <= 5.5e+136)) {
tmp = z * cos(y);
} else {
tmp = x + z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.3d+54)) .or. (.not. (z <= 5.5d+136))) then
tmp = z * cos(y)
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e+54) || !(z <= 5.5e+136)) {
tmp = z * Math.cos(y);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.3e+54) or not (z <= 5.5e+136): tmp = z * math.cos(y) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.3e+54) || !(z <= 5.5e+136)) tmp = Float64(z * cos(y)); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.3e+54) || ~((z <= 5.5e+136))) tmp = z * cos(y); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.3e+54], N[Not[LessEqual[z, 5.5e+136]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+54} \lor \neg \left(z \leq 5.5 \cdot 10^{+136}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if z < -1.30000000000000003e54 or 5.50000000000000039e136 < z Initial program 99.9%
Taylor expanded in z around inf 88.5%
if -1.30000000000000003e54 < z < 5.50000000000000039e136Initial program 100.0%
Taylor expanded in y around 0 70.7%
+-commutative70.7%
Simplified70.7%
Final simplification76.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -3700000000000.0) (not (<= z 3.3e-12))) (* z (cos y)) (+ x (sin y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3700000000000.0) || !(z <= 3.3e-12)) {
tmp = z * cos(y);
} else {
tmp = x + sin(y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-3700000000000.0d0)) .or. (.not. (z <= 3.3d-12))) then
tmp = z * cos(y)
else
tmp = x + sin(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3700000000000.0) || !(z <= 3.3e-12)) {
tmp = z * Math.cos(y);
} else {
tmp = x + Math.sin(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3700000000000.0) or not (z <= 3.3e-12): tmp = z * math.cos(y) else: tmp = x + math.sin(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3700000000000.0) || !(z <= 3.3e-12)) tmp = Float64(z * cos(y)); else tmp = Float64(x + sin(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3700000000000.0) || ~((z <= 3.3e-12))) tmp = z * cos(y); else tmp = x + sin(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3700000000000.0], N[Not[LessEqual[z, 3.3e-12]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3700000000000 \lor \neg \left(z \leq 3.3 \cdot 10^{-12}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + \sin y\\
\end{array}
\end{array}
if z < -3.7e12 or 3.3000000000000001e-12 < z Initial program 99.9%
Taylor expanded in z around inf 81.7%
if -3.7e12 < z < 3.3000000000000001e-12Initial program 100.0%
Taylor expanded in z around 0 92.0%
+-commutative92.0%
Simplified92.0%
Final simplification87.2%
(FPCore (x y z)
:precision binary64
(if (<= y -11.0)
(+ x z)
(if (<= y 980000000000.0)
(+ x (+ y (+ z (* -0.5 (* z (* y y))))))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -11.0) {
tmp = x + z;
} else if (y <= 980000000000.0) {
tmp = x + (y + (z + (-0.5 * (z * (y * y)))));
} else {
tmp = x + z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-11.0d0)) then
tmp = x + z
else if (y <= 980000000000.0d0) then
tmp = x + (y + (z + ((-0.5d0) * (z * (y * y)))))
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -11.0) {
tmp = x + z;
} else if (y <= 980000000000.0) {
tmp = x + (y + (z + (-0.5 * (z * (y * y)))));
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -11.0: tmp = x + z elif y <= 980000000000.0: tmp = x + (y + (z + (-0.5 * (z * (y * y))))) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -11.0) tmp = Float64(x + z); elseif (y <= 980000000000.0) tmp = Float64(x + Float64(y + Float64(z + Float64(-0.5 * Float64(z * Float64(y * y)))))); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -11.0) tmp = x + z; elseif (y <= 980000000000.0) tmp = x + (y + (z + (-0.5 * (z * (y * y))))); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -11.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 980000000000.0], N[(x + N[(y + N[(z + N[(-0.5 * N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -11:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 980000000000:\\
\;\;\;\;x + \left(y + \left(z + -0.5 \cdot \left(z \cdot \left(y \cdot y\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -11 or 9.8e11 < y Initial program 99.9%
Taylor expanded in y around 0 42.2%
+-commutative42.2%
Simplified42.2%
if -11 < y < 9.8e11Initial program 100.0%
Taylor expanded in y around 0 97.9%
*-commutative97.9%
unpow297.9%
Simplified97.9%
Final simplification71.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.4e+33) (+ x z) (if (<= y 0.0031) (+ z (+ x y)) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e+33) {
tmp = x + z;
} else if (y <= 0.0031) {
tmp = z + (x + y);
} else {
tmp = x + z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.4d+33)) then
tmp = x + z
else if (y <= 0.0031d0) then
tmp = z + (x + y)
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e+33) {
tmp = x + z;
} else if (y <= 0.0031) {
tmp = z + (x + y);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.4e+33: tmp = x + z elif y <= 0.0031: tmp = z + (x + y) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.4e+33) tmp = Float64(x + z); elseif (y <= 0.0031) tmp = Float64(z + Float64(x + y)); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.4e+33) tmp = x + z; elseif (y <= 0.0031) tmp = z + (x + y); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.4e+33], N[(x + z), $MachinePrecision], If[LessEqual[y, 0.0031], N[(z + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+33}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 0.0031:\\
\;\;\;\;z + \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -1.4e33 or 0.00309999999999999989 < y Initial program 99.9%
Taylor expanded in y around 0 42.3%
+-commutative42.3%
Simplified42.3%
if -1.4e33 < y < 0.00309999999999999989Initial program 100.0%
Taylor expanded in y around 0 96.1%
+-commutative96.1%
+-commutative96.1%
associate-+l+96.1%
Simplified96.1%
Final simplification71.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.5e+17) z (if (<= z 3.8e+92) x z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.5e+17) {
tmp = z;
} else if (z <= 3.8e+92) {
tmp = x;
} else {
tmp = 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.5d+17)) then
tmp = z
else if (z <= 3.8d+92) then
tmp = x
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.5e+17) {
tmp = z;
} else if (z <= 3.8e+92) {
tmp = x;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.5e+17: tmp = z elif z <= 3.8e+92: tmp = x else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.5e+17) tmp = z; elseif (z <= 3.8e+92) tmp = x; else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.5e+17) tmp = z; elseif (z <= 3.8e+92) tmp = x; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.5e+17], z, If[LessEqual[z, 3.8e+92], x, z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+17}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+92}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -1.5e17 or 3.8e92 < z Initial program 99.9%
Taylor expanded in z around inf 85.8%
Taylor expanded in y around 0 51.5%
if -1.5e17 < z < 3.8e92Initial program 100.0%
Taylor expanded in x around inf 60.2%
Final simplification56.7%
(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}
Initial program 100.0%
Taylor expanded in y around 0 67.7%
+-commutative67.7%
Simplified67.7%
Final simplification67.7%
(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}
Initial program 100.0%
Taylor expanded in x around inf 42.6%
Final simplification42.6%
herbie shell --seed 2023279
(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))))