
(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 5 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%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (cos y) (* z (sin y))))) (if (<= z -4.1e+58) t_0 (if (<= z 2.1e+133) (* x (cos y)) t_0))))
double code(double x, double y, double z) {
double t_0 = cos(y) - (z * sin(y));
double tmp;
if (z <= -4.1e+58) {
tmp = t_0;
} else if (z <= 2.1e+133) {
tmp = x * cos(y);
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = cos(y) - (z * sin(y))
if (z <= (-4.1d+58)) then
tmp = t_0
else if (z <= 2.1d+133) then
tmp = x * cos(y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.cos(y) - (z * Math.sin(y));
double tmp;
if (z <= -4.1e+58) {
tmp = t_0;
} else if (z <= 2.1e+133) {
tmp = x * Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.cos(y) - (z * math.sin(y)) tmp = 0 if z <= -4.1e+58: tmp = t_0 elif z <= 2.1e+133: tmp = x * math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(cos(y) - Float64(z * sin(y))) tmp = 0.0 if (z <= -4.1e+58) tmp = t_0; elseif (z <= 2.1e+133) tmp = Float64(x * cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = cos(y) - (z * sin(y)); tmp = 0.0; if (z <= -4.1e+58) tmp = t_0; elseif (z <= 2.1e+133) tmp = x * cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.1e+58], t$95$0, If[LessEqual[z, 2.1e+133], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y - z \cdot \sin y\\
\mathbf{if}\;z \leq -4.1 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+133}:\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.1e58 or 2.1e133 < z Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites70.2%
if -4.1e58 < z < 2.1e133Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites80.5%
(FPCore (x y z) :precision binary64 (* x (cos y)))
double code(double x, double y, double z) {
return x * cos(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)
end function
public static double code(double x, double y, double z) {
return x * Math.cos(y);
}
def code(x, y, z): return x * math.cos(y)
function code(x, y, z) return Float64(x * cos(y)) end
function tmp = code(x, y, z) tmp = x * cos(y); end
code[x_, y_, z_] := N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites60.9%
(FPCore (x y z) :precision binary64 (sin y))
double code(double x, double y, double z) {
return 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 = sin(y)
end function
public static double code(double x, double y, double z) {
return Math.sin(y);
}
def code(x, y, z): return math.sin(y)
function code(x, y, z) return sin(y) end
function tmp = code(x, y, z) tmp = sin(y); end
code[x_, y_, z_] := N[Sin[y], $MachinePrecision]
\begin{array}{l}
\\
\sin y
\end{array}
Initial program 99.8%
Taylor expanded in x around -inf
Applied rewrites3.3%
(FPCore (x y z) :precision binary64 (cos y))
double code(double x, double y, double z) {
return cos(y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = cos(y)
end function
public static double code(double x, double y, double z) {
return Math.cos(y);
}
def code(x, y, z): return math.cos(y)
function code(x, y, z) return cos(y) end
function tmp = code(x, y, z) tmp = cos(y); end
code[x_, y_, z_] := N[Cos[y], $MachinePrecision]
\begin{array}{l}
\\
\cos y
\end{array}
Initial program 99.8%
Taylor expanded in x around -inf
Applied rewrites3.3%
Taylor expanded in x around -inf
Applied rewrites3.3%
herbie shell --seed 2024321
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, A"
:precision binary64
:pre (TRUE)
(- (* x (cos y)) (* z (sin y))))