
(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 100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ x (sin y)))) (if (<= x -2.8e-15) t_0 (if (<= x 5.7e-47) (+ (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 <= -2.8e-15) {
tmp = t_0;
} else if (x <= 5.7e-47) {
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 <= (-2.8d-15)) then
tmp = t_0
else if (x <= 5.7d-47) 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 <= -2.8e-15) {
tmp = t_0;
} else if (x <= 5.7e-47) {
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 <= -2.8e-15: tmp = t_0 elif x <= 5.7e-47: 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 <= -2.8e-15) tmp = t_0; elseif (x <= 5.7e-47) 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 <= -2.8e-15) tmp = t_0; elseif (x <= 5.7e-47) 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, -2.8e-15], t$95$0, If[LessEqual[x, 5.7e-47], 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 -2.8 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{-47}:\\
\;\;\;\;\sin y + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.80000000000000014e-15 or 5.70000000000000046e-47 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites78.4%
if -2.80000000000000014e-15 < x < 5.70000000000000046e-47Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites95.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (cos y)))) (if (<= z -12.0) t_0 (if (<= z 7.5e+74) (+ x (sin y)) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -12.0) {
tmp = t_0;
} else if (z <= 7.5e+74) {
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 <= (-12.0d0)) then
tmp = t_0
else if (z <= 7.5d+74) 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 <= -12.0) {
tmp = t_0;
} else if (z <= 7.5e+74) {
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 <= -12.0: tmp = t_0 elif z <= 7.5e+74: 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 <= -12.0) tmp = t_0; elseif (z <= 7.5e+74) 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 <= -12.0) tmp = t_0; elseif (z <= 7.5e+74) 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, -12.0], t$95$0, If[LessEqual[z, 7.5e+74], 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 -12:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+74}:\\
\;\;\;\;x + \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -12 or 7.5e74 < z Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites2.5%
Taylor expanded in x around -inf
Applied rewrites81.7%
if -12 < z < 7.5e74Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites88.6%
(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 100.0%
Taylor expanded in x around 0
Applied rewrites59.6%
(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 100.0%
Taylor expanded in x around inf
Applied rewrites4.0%
Taylor expanded in x around inf
Applied rewrites16.4%
(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 100.0%
Taylor expanded in x around inf
Applied rewrites4.0%
herbie shell --seed 2024321
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
:pre (TRUE)
(+ (+ x (sin y)) (* z (cos y))))