
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * 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 + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * 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 + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * 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 + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Initial program 99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ x (sin y)))) (if (<= x -1120.0) t_0 (if (<= x 0.8) (+ (sin y) (* z (cos y))) t_0))))
double code(double x, double y, double z) {
double t_0 = x + sin(y);
double tmp;
if (x <= -1120.0) {
tmp = t_0;
} else if (x <= 0.8) {
tmp = sin(y) + (z * 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 = x + sin(y)
if (x <= (-1120.0d0)) then
tmp = t_0
else if (x <= 0.8d0) then
tmp = sin(y) + (z * 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 = x + Math.sin(y);
double tmp;
if (x <= -1120.0) {
tmp = t_0;
} else if (x <= 0.8) {
tmp = Math.sin(y) + (z * Math.cos(y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + math.sin(y) tmp = 0 if x <= -1120.0: tmp = t_0 elif x <= 0.8: tmp = math.sin(y) + (z * math.cos(y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + sin(y)) tmp = 0.0 if (x <= -1120.0) tmp = t_0; elseif (x <= 0.8) tmp = Float64(sin(y) + Float64(z * cos(y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + sin(y); tmp = 0.0; if (x <= -1120.0) tmp = t_0; elseif (x <= 0.8) tmp = sin(y) + (z * cos(y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1120.0], t$95$0, If[LessEqual[x, 0.8], N[(N[Sin[y], $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \sin y\\
\mathbf{if}\;x \leq -1120:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.8:\\
\;\;\;\;\sin y + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1120 or 0.80000000000000004 < x Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites80.2%
if -1120 < x < 0.80000000000000004Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites94.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (cos y)))) (if (<= z -4.5e+73) t_0 (if (<= z 2.45e+32) (+ x (sin y)) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -4.5e+73) {
tmp = t_0;
} else if (z <= 2.45e+32) {
tmp = x + sin(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 = z * cos(y)
if (z <= (-4.5d+73)) then
tmp = t_0
else if (z <= 2.45d+32) then
tmp = x + sin(y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.cos(y);
double tmp;
if (z <= -4.5e+73) {
tmp = t_0;
} else if (z <= 2.45e+32) {
tmp = x + Math.sin(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -4.5e+73: tmp = t_0 elif z <= 2.45e+32: tmp = x + math.sin(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -4.5e+73) tmp = t_0; elseif (z <= 2.45e+32) tmp = Float64(x + sin(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -4.5e+73) tmp = t_0; elseif (z <= 2.45e+32) tmp = x + sin(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.5e+73], t$95$0, If[LessEqual[z, 2.45e+32], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -4.5 \cdot 10^{+73}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.45 \cdot 10^{+32}:\\
\;\;\;\;x + \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.49999999999999985e73 or 2.4500000000000001e32 < z Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites2.7%
Taylor expanded in x around -inf
Applied rewrites82.7%
if -4.49999999999999985e73 < z < 2.4500000000000001e32Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites82.8%
(FPCore (x y z) :precision binary64 (+ x (sin y)))
double code(double x, double y, double z) {
return x + 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 + sin(y)
end function
public static double code(double x, double y, double z) {
return x + Math.sin(y);
}
def code(x, y, z): return x + math.sin(y)
function code(x, y, z) return Float64(x + sin(y)) end
function tmp = code(x, y, z) tmp = x + sin(y); end
code[x_, y_, z_] := N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \sin y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites58.0%
(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.9%
Taylor expanded in x around inf
Applied rewrites4.2%
Taylor expanded in x around inf
Applied rewrites14.6%
(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.9%
Taylor expanded in x around inf
Applied rewrites4.2%
herbie shell --seed 2024313
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
(+ (+ x (sin y)) (* z (cos y))))