
(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}
\\
x \cdot \cos y - 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}
\\
x \cdot \cos y - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (fma z (- (sin y)) (* x (cos y))))
double code(double x, double y, double z) {
return fma(z, -sin(y), (x * cos(y)));
}
function code(x, y, z) return fma(z, Float64(-sin(y)), Float64(x * cos(y))) end
code[x_, y_, z_] := N[(z * (-N[Sin[y], $MachinePrecision]) + N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, -\sin y, x \cdot \cos y\right)
\end{array}
Initial program 99.8%
cancel-sign-sub-inv99.8%
+-commutative99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
sin-neg99.8%
fma-def99.8%
sin-neg99.8%
Simplified99.8%
Final simplification99.8%
(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}
\\
x \cdot \cos y - z \cdot \sin y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.3e+217) (not (<= x 1.12e+62))) (- (* x (cos y)) (* z y)) (- x (* z (sin y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.3e+217) || !(x <= 1.12e+62)) {
tmp = (x * cos(y)) - (z * y);
} else {
tmp = x - (z * 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 ((x <= (-2.3d+217)) .or. (.not. (x <= 1.12d+62))) then
tmp = (x * cos(y)) - (z * y)
else
tmp = x - (z * sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.3e+217) || !(x <= 1.12e+62)) {
tmp = (x * Math.cos(y)) - (z * y);
} else {
tmp = x - (z * Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.3e+217) or not (x <= 1.12e+62): tmp = (x * math.cos(y)) - (z * y) else: tmp = x - (z * math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.3e+217) || !(x <= 1.12e+62)) tmp = Float64(Float64(x * cos(y)) - Float64(z * y)); else tmp = Float64(x - Float64(z * sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.3e+217) || ~((x <= 1.12e+62))) tmp = (x * cos(y)) - (z * y); else tmp = x - (z * sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.3e+217], N[Not[LessEqual[x, 1.12e+62]], $MachinePrecision]], N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+217} \lor \neg \left(x \leq 1.12 \cdot 10^{+62}\right):\\
\;\;\;\;x \cdot \cos y - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \sin y\\
\end{array}
\end{array}
if x < -2.2999999999999999e217 or 1.1200000000000001e62 < x Initial program 99.8%
Taylor expanded in y around 0 78.1%
if -2.2999999999999999e217 < x < 1.1200000000000001e62Initial program 99.8%
Taylor expanded in y around 0 88.9%
Final simplification85.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.4e+19) (not (<= y 2.4e-7))) (* z (- (sin y))) (- x (* z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.4e+19) || !(y <= 2.4e-7)) {
tmp = z * -sin(y);
} else {
tmp = x - (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 <= (-5.4d+19)) .or. (.not. (y <= 2.4d-7))) then
tmp = z * -sin(y)
else
tmp = x - (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.4e+19) || !(y <= 2.4e-7)) {
tmp = z * -Math.sin(y);
} else {
tmp = x - (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.4e+19) or not (y <= 2.4e-7): tmp = z * -math.sin(y) else: tmp = x - (z * y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.4e+19) || !(y <= 2.4e-7)) tmp = Float64(z * Float64(-sin(y))); else tmp = Float64(x - Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.4e+19) || ~((y <= 2.4e-7))) tmp = z * -sin(y); else tmp = x - (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.4e+19], N[Not[LessEqual[y, 2.4e-7]], $MachinePrecision]], N[(z * (-N[Sin[y], $MachinePrecision])), $MachinePrecision], N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+19} \lor \neg \left(y \leq 2.4 \cdot 10^{-7}\right):\\
\;\;\;\;z \cdot \left(-\sin y\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot y\\
\end{array}
\end{array}
if y < -5.4e19 or 2.39999999999999979e-7 < y Initial program 99.6%
cancel-sign-sub-inv99.6%
+-commutative99.6%
distribute-lft-neg-out99.6%
distribute-rgt-neg-in99.6%
sin-neg99.6%
fma-def99.6%
sin-neg99.6%
Simplified99.6%
Taylor expanded in z around inf 58.3%
neg-mul-158.3%
distribute-rgt-neg-in58.3%
Simplified58.3%
if -5.4e19 < y < 2.39999999999999979e-7Initial program 100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
sin-neg100.0%
fma-def100.0%
sin-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 98.1%
+-commutative98.1%
mul-1-neg98.1%
unsub-neg98.1%
Simplified98.1%
Final simplification79.3%
(FPCore (x y z) :precision binary64 (- x (* z (sin y))))
double code(double x, double y, double z) {
return x - (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 - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return x - (z * Math.sin(y));
}
def code(x, y, z): return x - (z * math.sin(y))
function code(x, y, z) return Float64(x - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = x - (z * sin(y)); end
code[x_, y_, z_] := N[(x - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - z \cdot \sin y
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 80.9%
Final simplification80.9%
(FPCore (x y z) :precision binary64 (- x (* z y)))
double code(double x, double y, double z) {
return x - (z * 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 - (z * y)
end function
public static double code(double x, double y, double z) {
return x - (z * y);
}
def code(x, y, z): return x - (z * y)
function code(x, y, z) return Float64(x - Float64(z * y)) end
function tmp = code(x, y, z) tmp = x - (z * y); end
code[x_, y_, z_] := N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - z \cdot y
\end{array}
Initial program 99.8%
cancel-sign-sub-inv99.8%
+-commutative99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
sin-neg99.8%
fma-def99.8%
sin-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 54.4%
+-commutative54.4%
mul-1-neg54.4%
unsub-neg54.4%
Simplified54.4%
Final simplification54.4%
(FPCore (x y z) :precision binary64 (* z (- y)))
double code(double x, double y, double z) {
return z * -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 * -y
end function
public static double code(double x, double y, double z) {
return z * -y;
}
def code(x, y, z): return z * -y
function code(x, y, z) return Float64(z * Float64(-y)) end
function tmp = code(x, y, z) tmp = z * -y; end
code[x_, y_, z_] := N[(z * (-y)), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \left(-y\right)
\end{array}
Initial program 99.8%
cancel-sign-sub-inv99.8%
+-commutative99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
sin-neg99.8%
fma-def99.8%
sin-neg99.8%
Simplified99.8%
Taylor expanded in z around inf 43.8%
neg-mul-143.8%
distribute-rgt-neg-in43.8%
Simplified43.8%
Taylor expanded in y around 0 18.3%
mul-1-neg18.3%
distribute-rgt-neg-in18.3%
Simplified18.3%
Final simplification18.3%
herbie shell --seed 2023274
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, A"
:precision binary64
(- (* x (cos y)) (* z (sin y))))