
(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 6 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.7%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.05e+51)
(and (not (<= x -5.4e-39))
(or (<= x -6.8e-123) (not (<= x 4.2e-113)))))
(* x (cos y))
(* z (- (sin y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.05e+51) || (!(x <= -5.4e-39) && ((x <= -6.8e-123) || !(x <= 4.2e-113)))) {
tmp = x * cos(y);
} else {
tmp = 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 <= (-1.05d+51)) .or. (.not. (x <= (-5.4d-39))) .and. (x <= (-6.8d-123)) .or. (.not. (x <= 4.2d-113))) then
tmp = x * cos(y)
else
tmp = z * -sin(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.05e+51) || (!(x <= -5.4e-39) && ((x <= -6.8e-123) || !(x <= 4.2e-113)))) {
tmp = x * Math.cos(y);
} else {
tmp = z * -Math.sin(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.05e+51) or (not (x <= -5.4e-39) and ((x <= -6.8e-123) or not (x <= 4.2e-113))): tmp = x * math.cos(y) else: tmp = z * -math.sin(y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.05e+51) || (!(x <= -5.4e-39) && ((x <= -6.8e-123) || !(x <= 4.2e-113)))) tmp = Float64(x * cos(y)); else tmp = Float64(z * Float64(-sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.05e+51) || (~((x <= -5.4e-39)) && ((x <= -6.8e-123) || ~((x <= 4.2e-113))))) tmp = x * cos(y); else tmp = z * -sin(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.05e+51], And[N[Not[LessEqual[x, -5.4e-39]], $MachinePrecision], Or[LessEqual[x, -6.8e-123], N[Not[LessEqual[x, 4.2e-113]], $MachinePrecision]]]], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(z * (-N[Sin[y], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+51} \lor \neg \left(x \leq -5.4 \cdot 10^{-39}\right) \land \left(x \leq -6.8 \cdot 10^{-123} \lor \neg \left(x \leq 4.2 \cdot 10^{-113}\right)\right):\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-\sin y\right)\\
\end{array}
\end{array}
if x < -1.0500000000000001e51 or -5.4000000000000001e-39 < x < -6.8000000000000001e-123 or 4.2e-113 < x Initial program 99.8%
Taylor expanded in x around inf 83.3%
if -1.0500000000000001e51 < x < -5.4000000000000001e-39 or -6.8000000000000001e-123 < x < 4.2e-113Initial program 99.6%
Taylor expanded in x around 0 82.0%
associate-*r*82.0%
neg-mul-182.0%
Simplified82.0%
Final simplification82.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -3e-27) (not (<= z 7800000000.0))) (- x (* z (sin y))) (* x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3e-27) || !(z <= 7800000000.0)) {
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 <= (-3d-27)) .or. (.not. (z <= 7800000000.0d0))) 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 <= -3e-27) || !(z <= 7800000000.0)) {
tmp = x - (z * Math.sin(y));
} else {
tmp = x * Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3e-27) or not (z <= 7800000000.0): tmp = x - (z * math.sin(y)) else: tmp = x * math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3e-27) || !(z <= 7800000000.0)) 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 <= -3e-27) || ~((z <= 7800000000.0))) tmp = x - (z * sin(y)); else tmp = x * cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3e-27], N[Not[LessEqual[z, 7800000000.0]], $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 -3 \cdot 10^{-27} \lor \neg \left(z \leq 7800000000\right):\\
\;\;\;\;x - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \cos y\\
\end{array}
\end{array}
if z < -3.0000000000000001e-27 or 7.8e9 < z Initial program 99.7%
Taylor expanded in y around 0 90.9%
if -3.0000000000000001e-27 < z < 7.8e9Initial program 99.8%
Taylor expanded in x around inf 91.3%
Final simplification91.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -9000000.0) (not (<= y 2.5e-8))) (* x (cos y)) (+ x (- (* -0.5 (* y (* x y))) (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9000000.0) || !(y <= 2.5e-8)) {
tmp = x * cos(y);
} else {
tmp = x + ((-0.5 * (y * (x * 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 ((y <= (-9000000.0d0)) .or. (.not. (y <= 2.5d-8))) then
tmp = x * cos(y)
else
tmp = x + (((-0.5d0) * (y * (x * y))) - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -9000000.0) || !(y <= 2.5e-8)) {
tmp = x * Math.cos(y);
} else {
tmp = x + ((-0.5 * (y * (x * y))) - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9000000.0) or not (y <= 2.5e-8): tmp = x * math.cos(y) else: tmp = x + ((-0.5 * (y * (x * y))) - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9000000.0) || !(y <= 2.5e-8)) tmp = Float64(x * cos(y)); else tmp = Float64(x + Float64(Float64(-0.5 * Float64(y * Float64(x * y))) - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9000000.0) || ~((y <= 2.5e-8))) tmp = x * cos(y); else tmp = x + ((-0.5 * (y * (x * y))) - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9000000.0], N[Not[LessEqual[y, 2.5e-8]], $MachinePrecision]], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(-0.5 * N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9000000 \lor \neg \left(y \leq 2.5 \cdot 10^{-8}\right):\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + \left(-0.5 \cdot \left(y \cdot \left(x \cdot y\right)\right) - y \cdot z\right)\\
\end{array}
\end{array}
if y < -9e6 or 2.4999999999999999e-8 < y Initial program 99.6%
Taylor expanded in x around inf 47.8%
if -9e6 < y < 2.4999999999999999e-8Initial program 100.0%
Taylor expanded in y around 0 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.0%
Simplified99.0%
Final simplification70.0%
(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.7%
Taylor expanded in y around 0 46.3%
mul-1-neg46.3%
unsub-neg46.3%
Simplified46.3%
Final simplification46.3%
(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.7%
Taylor expanded in y around 0 76.3%
Taylor expanded in x around inf 35.3%
Final simplification35.3%
herbie shell --seed 2023285
(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))))