
(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 (- (* 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.35e-94) (not (<= z 1.32e-48))) (- x (* z (sin y))) (* x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e-94) || !(z <= 1.32e-48)) {
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 <= (-1.35d-94)) .or. (.not. (z <= 1.32d-48))) 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 <= -1.35e-94) || !(z <= 1.32e-48)) {
tmp = x - (z * Math.sin(y));
} else {
tmp = x * Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.35e-94) or not (z <= 1.32e-48): tmp = x - (z * math.sin(y)) else: tmp = x * math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.35e-94) || !(z <= 1.32e-48)) 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 <= -1.35e-94) || ~((z <= 1.32e-48))) tmp = x - (z * sin(y)); else tmp = x * cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.35e-94], N[Not[LessEqual[z, 1.32e-48]], $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 -1.35 \cdot 10^{-94} \lor \neg \left(z \leq 1.32 \cdot 10^{-48}\right):\\
\;\;\;\;x - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \cos y\\
\end{array}
\end{array}
if z < -1.3500000000000001e-94 or 1.32e-48 < z Initial program 99.9%
Taylor expanded in y around 0 89.6%
if -1.3500000000000001e-94 < z < 1.32e-48Initial program 99.8%
Taylor expanded in y around 0 78.4%
Taylor expanded in x around inf 89.7%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.3e-73) (not (<= x 2.95e-139))) (* x (cos y)) (* (sin y) (- z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.3e-73) || !(x <= 2.95e-139)) {
tmp = x * cos(y);
} else {
tmp = sin(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 ((x <= (-2.3d-73)) .or. (.not. (x <= 2.95d-139))) then
tmp = x * cos(y)
else
tmp = sin(y) * -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.3e-73) || !(x <= 2.95e-139)) {
tmp = x * Math.cos(y);
} else {
tmp = Math.sin(y) * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.3e-73) or not (x <= 2.95e-139): tmp = x * math.cos(y) else: tmp = math.sin(y) * -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.3e-73) || !(x <= 2.95e-139)) tmp = Float64(x * cos(y)); else tmp = Float64(sin(y) * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.3e-73) || ~((x <= 2.95e-139))) tmp = x * cos(y); else tmp = sin(y) * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.3e-73], N[Not[LessEqual[x, 2.95e-139]], $MachinePrecision]], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{-73} \lor \neg \left(x \leq 2.95 \cdot 10^{-139}\right):\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \left(-z\right)\\
\end{array}
\end{array}
if x < -2.29999999999999988e-73 or 2.9499999999999999e-139 < x Initial program 99.8%
Taylor expanded in y around 0 71.9%
Taylor expanded in x around inf 78.0%
if -2.29999999999999988e-73 < x < 2.9499999999999999e-139Initial program 99.9%
Taylor expanded in y around 0 95.4%
Taylor expanded in x around 0 81.8%
associate-*r*81.8%
neg-mul-181.8%
*-commutative81.8%
Simplified81.8%
Final simplification79.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -25500000000.0) (not (<= y 0.0045))) (* x (cos y)) (- x (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -25500000000.0) || !(y <= 0.0045)) {
tmp = x * cos(y);
} else {
tmp = x - (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 <= (-25500000000.0d0)) .or. (.not. (y <= 0.0045d0))) then
tmp = x * cos(y)
else
tmp = x - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -25500000000.0) || !(y <= 0.0045)) {
tmp = x * Math.cos(y);
} else {
tmp = x - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -25500000000.0) or not (y <= 0.0045): tmp = x * math.cos(y) else: tmp = x - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -25500000000.0) || !(y <= 0.0045)) tmp = Float64(x * cos(y)); else tmp = Float64(x - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -25500000000.0) || ~((y <= 0.0045))) tmp = x * cos(y); else tmp = x - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -25500000000.0], N[Not[LessEqual[y, 0.0045]], $MachinePrecision]], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -25500000000 \lor \neg \left(y \leq 0.0045\right):\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot z\\
\end{array}
\end{array}
if y < -2.55e10 or 0.00449999999999999966 < y Initial program 99.7%
Taylor expanded in y around 0 29.9%
Taylor expanded in x around inf 49.7%
if -2.55e10 < y < 0.00449999999999999966Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 99.3%
+-commutative99.3%
*-commutative99.3%
neg-mul-199.3%
unsub-neg99.3%
Simplified99.3%
Final simplification75.5%
(FPCore (x y z) :precision binary64 (if (<= x -9e-74) x (if (<= x 1.32e-154) (* z (- y)) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -9e-74) {
tmp = x;
} else if (x <= 1.32e-154) {
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 (x <= (-9d-74)) then
tmp = x
else if (x <= 1.32d-154) 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 (x <= -9e-74) {
tmp = x;
} else if (x <= 1.32e-154) {
tmp = z * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9e-74: tmp = x elif x <= 1.32e-154: tmp = z * -y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9e-74) tmp = x; elseif (x <= 1.32e-154) tmp = Float64(z * Float64(-y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9e-74) tmp = x; elseif (x <= 1.32e-154) tmp = z * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9e-74], x, If[LessEqual[x, 1.32e-154], N[(z * (-y)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{-74}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.32 \cdot 10^{-154}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -8.9999999999999998e-74 or 1.31999999999999994e-154 < x Initial program 99.8%
Taylor expanded in y around 0 71.6%
Taylor expanded in x around inf 51.3%
if -8.9999999999999998e-74 < x < 1.31999999999999994e-154Initial program 99.9%
Taylor expanded in y around 0 53.1%
Taylor expanded in x around 0 39.3%
associate-*r*39.3%
neg-mul-139.3%
*-commutative39.3%
Simplified39.3%
Final simplification47.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.8%
Taylor expanded in y around 0 78.7%
Taylor expanded in y around 0 54.6%
+-commutative54.6%
*-commutative54.6%
neg-mul-154.6%
unsub-neg54.6%
Simplified54.6%
Final simplification54.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%
Taylor expanded in y around 0 78.7%
Taylor expanded in x around inf 41.2%
Final simplification41.2%
herbie shell --seed 2023252
(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))))