
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (sin y))))
(if (or (<= x -0.00031) (not (<= x 1.42e-21)))
(- (+ x 1.0) t_0)
(- (cos y) t_0))))
double code(double x, double y, double z) {
double t_0 = z * sin(y);
double tmp;
if ((x <= -0.00031) || !(x <= 1.42e-21)) {
tmp = (x + 1.0) - t_0;
} else {
tmp = cos(y) - t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = z * sin(y)
if ((x <= (-0.00031d0)) .or. (.not. (x <= 1.42d-21))) then
tmp = (x + 1.0d0) - t_0
else
tmp = cos(y) - t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.sin(y);
double tmp;
if ((x <= -0.00031) || !(x <= 1.42e-21)) {
tmp = (x + 1.0) - t_0;
} else {
tmp = Math.cos(y) - t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.sin(y) tmp = 0 if (x <= -0.00031) or not (x <= 1.42e-21): tmp = (x + 1.0) - t_0 else: tmp = math.cos(y) - t_0 return tmp
function code(x, y, z) t_0 = Float64(z * sin(y)) tmp = 0.0 if ((x <= -0.00031) || !(x <= 1.42e-21)) tmp = Float64(Float64(x + 1.0) - t_0); else tmp = Float64(cos(y) - t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * sin(y); tmp = 0.0; if ((x <= -0.00031) || ~((x <= 1.42e-21))) tmp = (x + 1.0) - t_0; else tmp = cos(y) - t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x, -0.00031], N[Not[LessEqual[x, 1.42e-21]], $MachinePrecision]], N[(N[(x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \sin y\\
\mathbf{if}\;x \leq -0.00031 \lor \neg \left(x \leq 1.42 \cdot 10^{-21}\right):\\
\;\;\;\;\left(x + 1\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\cos y - t_0\\
\end{array}
\end{array}
if x < -3.1e-4 or 1.42e-21 < x Initial program 100.0%
Taylor expanded in y around 0 99.2%
+-commutative99.2%
Simplified99.2%
if -3.1e-4 < x < 1.42e-21Initial program 99.8%
Taylor expanded in x around 0 99.2%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05e-77) (not (<= z 5e-121))) (- (+ x 1.0) (* z (sin y))) (- (+ x (cos y)) (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e-77) || !(z <= 5e-121)) {
tmp = (x + 1.0) - (z * sin(y));
} else {
tmp = (x + cos(y)) - (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.05d-77)) .or. (.not. (z <= 5d-121))) then
tmp = (x + 1.0d0) - (z * sin(y))
else
tmp = (x + cos(y)) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e-77) || !(z <= 5e-121)) {
tmp = (x + 1.0) - (z * Math.sin(y));
} else {
tmp = (x + Math.cos(y)) - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05e-77) or not (z <= 5e-121): tmp = (x + 1.0) - (z * math.sin(y)) else: tmp = (x + math.cos(y)) - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05e-77) || !(z <= 5e-121)) tmp = Float64(Float64(x + 1.0) - Float64(z * sin(y))); else tmp = Float64(Float64(x + cos(y)) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.05e-77) || ~((z <= 5e-121))) tmp = (x + 1.0) - (z * sin(y)); else tmp = (x + cos(y)) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05e-77], N[Not[LessEqual[z, 5e-121]], $MachinePrecision]], N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-77} \lor \neg \left(z \leq 5 \cdot 10^{-121}\right):\\
\;\;\;\;\left(x + 1\right) - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;\left(x + \cos y\right) - y \cdot z\\
\end{array}
\end{array}
if z < -1.05000000000000008e-77 or 4.99999999999999989e-121 < z Initial program 99.9%
Taylor expanded in y around 0 96.1%
+-commutative96.1%
Simplified96.1%
if -1.05000000000000008e-77 < z < 4.99999999999999989e-121Initial program 100.0%
Taylor expanded in y around 0 91.7%
Final simplification94.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.054) (not (<= y 225.0))) (- x (* z (sin y))) (- (+ x 1.0) (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.054) || !(y <= 225.0)) {
tmp = x - (z * sin(y));
} else {
tmp = (x + 1.0) - (y * z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-0.054d0)) .or. (.not. (y <= 225.0d0))) then
tmp = x - (z * sin(y))
else
tmp = (x + 1.0d0) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.054) || !(y <= 225.0)) {
tmp = x - (z * Math.sin(y));
} else {
tmp = (x + 1.0) - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.054) or not (y <= 225.0): tmp = x - (z * math.sin(y)) else: tmp = (x + 1.0) - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.054) || !(y <= 225.0)) tmp = Float64(x - Float64(z * sin(y))); else tmp = Float64(Float64(x + 1.0) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.054) || ~((y <= 225.0))) tmp = x - (z * sin(y)); else tmp = (x + 1.0) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.054], N[Not[LessEqual[y, 225.0]], $MachinePrecision]], N[(x - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.054 \lor \neg \left(y \leq 225\right):\\
\;\;\;\;x - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;\left(x + 1\right) - y \cdot z\\
\end{array}
\end{array}
if y < -0.0539999999999999994 or 225 < y Initial program 99.8%
Taylor expanded in x around inf 79.1%
if -0.0539999999999999994 < y < 225Initial program 100.0%
Taylor expanded in y around 0 98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in y around 0 98.4%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (- (+ x 1.0) (* z (sin y))))
double code(double x, double y, double z) {
return (x + 1.0) - (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + 1.0d0) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + 1.0) - (z * Math.sin(y));
}
def code(x, y, z): return (x + 1.0) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + 1.0) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + 1.0) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + 1\right) - z \cdot \sin y
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 89.6%
+-commutative89.6%
Simplified89.6%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (- (+ x 1.0) (* y z)))
double code(double x, double y, double z) {
return (x + 1.0) - (y * 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 + 1.0d0) - (y * z)
end function
public static double code(double x, double y, double z) {
return (x + 1.0) - (y * z);
}
def code(x, y, z): return (x + 1.0) - (y * z)
function code(x, y, z) return Float64(Float64(x + 1.0) - Float64(y * z)) end
function tmp = code(x, y, z) tmp = (x + 1.0) - (y * z); end
code[x_, y_, z_] := N[(N[(x + 1.0), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + 1\right) - y \cdot z
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 89.6%
+-commutative89.6%
Simplified89.6%
Taylor expanded in y around 0 66.7%
Final simplification66.7%
(FPCore (x y z) :precision binary64 (- x (* y z)))
double code(double x, double y, double z) {
return x - (y * 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 - (y * z)
end function
public static double code(double x, double y, double z) {
return x - (y * z);
}
def code(x, y, z): return x - (y * z)
function code(x, y, z) return Float64(x - Float64(y * z)) end
function tmp = code(x, y, z) tmp = x - (y * z); end
code[x_, y_, z_] := N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot z
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 68.9%
Taylor expanded in y around 0 46.3%
Final simplification46.3%
herbie shell --seed 2023257
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))