
(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 9 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-define99.8%
sin-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.9) (not (<= z 7.6e-78))) (fma z (- (sin y)) x) (* x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9) || !(z <= 7.6e-78)) {
tmp = fma(z, -sin(y), x);
} else {
tmp = x * cos(y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -1.9) || !(z <= 7.6e-78)) tmp = fma(z, Float64(-sin(y)), x); else tmp = Float64(x * cos(y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.9], N[Not[LessEqual[z, 7.6e-78]], $MachinePrecision]], N[(z * (-N[Sin[y], $MachinePrecision]) + x), $MachinePrecision], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \lor \neg \left(z \leq 7.6 \cdot 10^{-78}\right):\\
\;\;\;\;\mathsf{fma}\left(z, -\sin y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \cos y\\
\end{array}
\end{array}
if z < -1.8999999999999999 or 7.5999999999999998e-78 < 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-define99.8%
sin-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 87.0%
if -1.8999999999999999 < z < 7.5999999999999998e-78Initial program 99.8%
Taylor expanded in x around inf 90.9%
Final simplification88.9%
(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 -2.6) (not (<= z 8.2e-81))) (- x (* z (sin y))) (* x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.6) || !(z <= 8.2e-81)) {
tmp = x - (z * sin(y));
} else {
tmp = x * cos(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 <= (-2.6d0)) .or. (.not. (z <= 8.2d-81))) then
tmp = x - (z * sin(y))
else
tmp = x * cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.6) || !(z <= 8.2e-81)) {
tmp = x - (z * Math.sin(y));
} else {
tmp = x * Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.6) or not (z <= 8.2e-81): tmp = x - (z * math.sin(y)) else: tmp = x * math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.6) || !(z <= 8.2e-81)) tmp = Float64(x - Float64(z * sin(y))); else tmp = Float64(x * cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.6) || ~((z <= 8.2e-81))) tmp = x - (z * sin(y)); else tmp = x * cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.6], N[Not[LessEqual[z, 8.2e-81]], $MachinePrecision]], N[(x - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \lor \neg \left(z \leq 8.2 \cdot 10^{-81}\right):\\
\;\;\;\;x - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \cos y\\
\end{array}
\end{array}
if z < -2.60000000000000009 or 8.19999999999999968e-81 < z Initial program 99.8%
Taylor expanded in y around 0 87.0%
if -2.60000000000000009 < z < 8.19999999999999968e-81Initial program 99.8%
Taylor expanded in x around inf 90.9%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -8e+171) (not (<= z 2.7e+105))) (* z (- (sin y))) (* x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8e+171) || !(z <= 2.7e+105)) {
tmp = z * -sin(y);
} else {
tmp = x * cos(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 <= (-8d+171)) .or. (.not. (z <= 2.7d+105))) then
tmp = z * -sin(y)
else
tmp = x * cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8e+171) || !(z <= 2.7e+105)) {
tmp = z * -Math.sin(y);
} else {
tmp = x * Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8e+171) or not (z <= 2.7e+105): tmp = z * -math.sin(y) else: tmp = x * math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8e+171) || !(z <= 2.7e+105)) tmp = Float64(z * Float64(-sin(y))); else tmp = Float64(x * cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8e+171) || ~((z <= 2.7e+105))) tmp = z * -sin(y); else tmp = x * cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8e+171], N[Not[LessEqual[z, 2.7e+105]], $MachinePrecision]], N[(z * (-N[Sin[y], $MachinePrecision])), $MachinePrecision], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{+171} \lor \neg \left(z \leq 2.7 \cdot 10^{+105}\right):\\
\;\;\;\;z \cdot \left(-\sin y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \cos y\\
\end{array}
\end{array}
if z < -7.99999999999999963e171 or 2.70000000000000016e105 < z Initial program 99.8%
Taylor expanded in x around 0 77.5%
neg-mul-177.5%
distribute-rgt-neg-in77.5%
Simplified77.5%
if -7.99999999999999963e171 < z < 2.70000000000000016e105Initial program 99.8%
Taylor expanded in x around inf 80.9%
Final simplification79.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -3600000000.0) (not (<= y 1.06e-10))) (* x (cos y)) (- x (* z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3600000000.0) || !(y <= 1.06e-10)) {
tmp = x * cos(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 <= (-3600000000.0d0)) .or. (.not. (y <= 1.06d-10))) then
tmp = x * cos(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 <= -3600000000.0) || !(y <= 1.06e-10)) {
tmp = x * Math.cos(y);
} else {
tmp = x - (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3600000000.0) or not (y <= 1.06e-10): tmp = x * math.cos(y) else: tmp = x - (z * y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3600000000.0) || !(y <= 1.06e-10)) tmp = Float64(x * cos(y)); else tmp = Float64(x - Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3600000000.0) || ~((y <= 1.06e-10))) tmp = x * cos(y); else tmp = x - (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3600000000.0], N[Not[LessEqual[y, 1.06e-10]], $MachinePrecision]], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3600000000 \lor \neg \left(y \leq 1.06 \cdot 10^{-10}\right):\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot y\\
\end{array}
\end{array}
if y < -3.6e9 or 1.06e-10 < y Initial program 99.6%
Taylor expanded in x around inf 56.6%
if -3.6e9 < y < 1.06e-10Initial program 99.9%
Taylor expanded in y around 0 99.0%
mul-1-neg99.0%
unsub-neg99.0%
Simplified99.0%
Final simplification77.4%
(FPCore (x y z) :precision binary64 (if (<= z 1.85e+102) x (* z (- y))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.85e+102) {
tmp = x;
} else {
tmp = 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.85d+102) then
tmp = x
else
tmp = z * -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.85e+102) {
tmp = x;
} else {
tmp = z * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.85e+102: tmp = x else: tmp = z * -y return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.85e+102) tmp = x; else tmp = Float64(z * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.85e+102) tmp = x; else tmp = z * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.85e+102], x, N[(z * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.85 \cdot 10^{+102}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\end{array}
\end{array}
if z < 1.85000000000000011e102Initial program 99.8%
sub-neg99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
add-cube-cbrt99.3%
associate-*r*99.3%
fma-define99.3%
pow299.3%
Applied egg-rr99.3%
Taylor expanded in y around 0 45.0%
if 1.85000000000000011e102 < z Initial program 99.7%
Taylor expanded in y around 0 51.9%
mul-1-neg51.9%
unsub-neg51.9%
Simplified51.9%
Taylor expanded in x around 0 38.4%
associate-*r*38.4%
neg-mul-138.4%
Simplified38.4%
Final simplification43.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%
Taylor expanded in y around 0 52.6%
mul-1-neg52.6%
unsub-neg52.6%
Simplified52.6%
Final simplification52.6%
(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%
sub-neg99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
add-cube-cbrt99.1%
associate-*r*99.1%
fma-define99.1%
pow299.1%
Applied egg-rr99.1%
Taylor expanded in y around 0 39.6%
Final simplification39.6%
herbie shell --seed 2024039
(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))))