
(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 8 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 (<= z -1.2e-72) (not (<= z 6.5e-185))) (- x (* z (sin y))) (- (* x (cos y)) (* z y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.2e-72) || !(z <= 6.5e-185)) {
tmp = x - (z * sin(y));
} else {
tmp = (x * cos(y)) - (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 ((z <= (-1.2d-72)) .or. (.not. (z <= 6.5d-185))) then
tmp = x - (z * sin(y))
else
tmp = (x * cos(y)) - (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.2e-72) || !(z <= 6.5e-185)) {
tmp = x - (z * Math.sin(y));
} else {
tmp = (x * Math.cos(y)) - (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.2e-72) or not (z <= 6.5e-185): tmp = x - (z * math.sin(y)) else: tmp = (x * math.cos(y)) - (z * y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.2e-72) || !(z <= 6.5e-185)) tmp = Float64(x - Float64(z * sin(y))); else tmp = Float64(Float64(x * cos(y)) - Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.2e-72) || ~((z <= 6.5e-185))) tmp = x - (z * sin(y)); else tmp = (x * cos(y)) - (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.2e-72], N[Not[LessEqual[z, 6.5e-185]], $MachinePrecision]], N[(x - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{-72} \lor \neg \left(z \leq 6.5 \cdot 10^{-185}\right):\\
\;\;\;\;x - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \cos y - z \cdot y\\
\end{array}
\end{array}
if z < -1.2e-72 or 6.49999999999999946e-185 < z Initial program 99.8%
Taylor expanded in y around 0 86.3%
if -1.2e-72 < z < 6.49999999999999946e-185Initial program 99.7%
Taylor expanded in y around 0 84.5%
Final simplification85.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.8e-7) (not (<= y 0.0004))) (* z (- (sin y))) (+ (* -0.5 (* x (* y y))) (- x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.8e-7) || !(y <= 0.0004)) {
tmp = z * -sin(y);
} else {
tmp = (-0.5 * (x * (y * y))) + (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 <= (-6.8d-7)) .or. (.not. (y <= 0.0004d0))) then
tmp = z * -sin(y)
else
tmp = ((-0.5d0) * (x * (y * y))) + (x - (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.8e-7) || !(y <= 0.0004)) {
tmp = z * -Math.sin(y);
} else {
tmp = (-0.5 * (x * (y * y))) + (x - (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.8e-7) or not (y <= 0.0004): tmp = z * -math.sin(y) else: tmp = (-0.5 * (x * (y * y))) + (x - (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.8e-7) || !(y <= 0.0004)) tmp = Float64(z * Float64(-sin(y))); else tmp = Float64(Float64(-0.5 * Float64(x * Float64(y * y))) + Float64(x - Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.8e-7) || ~((y <= 0.0004))) tmp = z * -sin(y); else tmp = (-0.5 * (x * (y * y))) + (x - (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.8e-7], N[Not[LessEqual[y, 0.0004]], $MachinePrecision]], N[(z * (-N[Sin[y], $MachinePrecision])), $MachinePrecision], N[(N[(-0.5 * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{-7} \lor \neg \left(y \leq 0.0004\right):\\
\;\;\;\;z \cdot \left(-\sin y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(x \cdot \left(y \cdot y\right)\right) + \left(x - z \cdot y\right)\\
\end{array}
\end{array}
if y < -6.79999999999999948e-7 or 4.00000000000000019e-4 < 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 51.5%
neg-mul-151.5%
*-commutative51.5%
distribute-rgt-neg-in51.5%
Simplified51.5%
if -6.79999999999999948e-7 < y < 4.00000000000000019e-4Initial 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 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
fma-def99.8%
unpow299.8%
associate-*l*99.8%
Simplified99.8%
fma-udef99.8%
associate--l+99.8%
associate-*r*99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification75.6%
(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 77.7%
Final simplification77.7%
(FPCore (x y z) :precision binary64 (if (<= z -6.6e+181) (* z (- y)) x))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.6e+181) {
tmp = z * -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 (z <= (-6.6d+181)) then
tmp = z * -y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6.6e+181) {
tmp = z * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.6e+181: tmp = z * -y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.6e+181) tmp = Float64(z * Float64(-y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.6e+181) tmp = z * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.6e+181], N[(z * (-y)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.6 \cdot 10^{+181}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.60000000000000034e181Initial program 99.7%
cancel-sign-sub-inv99.7%
+-commutative99.7%
distribute-lft-neg-out99.7%
distribute-rgt-neg-in99.7%
sin-neg99.7%
fma-def99.7%
sin-neg99.7%
Simplified99.7%
Taylor expanded in y around 0 65.7%
+-commutative65.7%
mul-1-neg65.7%
unsub-neg65.7%
fma-def65.7%
unpow265.7%
associate-*l*65.7%
Simplified65.7%
Taylor expanded in x around 0 57.6%
mul-1-neg57.6%
*-commutative57.6%
distribute-rgt-neg-in57.6%
Simplified57.6%
if -6.60000000000000034e181 < z 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 50.7%
+-commutative50.7%
mul-1-neg50.7%
unsub-neg50.7%
fma-def50.7%
unpow250.7%
associate-*l*50.7%
Simplified50.7%
Taylor expanded in y around 0 44.5%
Final simplification45.7%
(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 53.5%
+-commutative53.5%
mul-1-neg53.5%
unsub-neg53.5%
Simplified53.5%
Final simplification53.5%
(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 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 52.0%
+-commutative52.0%
mul-1-neg52.0%
unsub-neg52.0%
fma-def52.0%
unpow252.0%
associate-*l*52.1%
Simplified52.1%
Taylor expanded in y around 0 41.7%
Final simplification41.7%
herbie shell --seed 2023275
(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))))