
(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 11 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 (fma z (cos y) (+ x (sin y))))
double code(double x, double y, double z) {
return fma(z, cos(y), (x + sin(y)));
}
function code(x, y, z) return fma(z, cos(y), Float64(x + sin(y))) end
code[x_, y_, z_] := N[(z * N[Cos[y], $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \cos y, x + \sin y\right)
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -4.3e+70)
t_0
(if (<= z 3.5e+105) (+ z (+ x (sin y))) (+ (sin y) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -4.3e+70) {
tmp = t_0;
} else if (z <= 3.5e+105) {
tmp = z + (x + sin(y));
} else {
tmp = sin(y) + 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.3d+70)) then
tmp = t_0
else if (z <= 3.5d+105) then
tmp = z + (x + sin(y))
else
tmp = sin(y) + 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.3e+70) {
tmp = t_0;
} else if (z <= 3.5e+105) {
tmp = z + (x + Math.sin(y));
} else {
tmp = Math.sin(y) + t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -4.3e+70: tmp = t_0 elif z <= 3.5e+105: tmp = z + (x + math.sin(y)) else: tmp = math.sin(y) + t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -4.3e+70) tmp = t_0; elseif (z <= 3.5e+105) tmp = Float64(z + Float64(x + sin(y))); else tmp = Float64(sin(y) + t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -4.3e+70) tmp = t_0; elseif (z <= 3.5e+105) tmp = z + (x + sin(y)); else tmp = sin(y) + 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.3e+70], t$95$0, If[LessEqual[z, 3.5e+105], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{+105}:\\
\;\;\;\;z + \left(x + \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;\sin y + t_0\\
\end{array}
\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}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -3e+70)
t_0
(if (<= z -4.3e-150)
(+ z x)
(if (<= z -1.4e-285) (+ z (+ y x)) (if (<= z 2.3e+105) (+ z x) t_0))))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -3e+70) {
tmp = t_0;
} else if (z <= -4.3e-150) {
tmp = z + x;
} else if (z <= -1.4e-285) {
tmp = z + (y + x);
} else if (z <= 2.3e+105) {
tmp = z + x;
} 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 <= (-3d+70)) then
tmp = t_0
else if (z <= (-4.3d-150)) then
tmp = z + x
else if (z <= (-1.4d-285)) then
tmp = z + (y + x)
else if (z <= 2.3d+105) then
tmp = z + x
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 <= -3e+70) {
tmp = t_0;
} else if (z <= -4.3e-150) {
tmp = z + x;
} else if (z <= -1.4e-285) {
tmp = z + (y + x);
} else if (z <= 2.3e+105) {
tmp = z + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -3e+70: tmp = t_0 elif z <= -4.3e-150: tmp = z + x elif z <= -1.4e-285: tmp = z + (y + x) elif z <= 2.3e+105: tmp = z + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -3e+70) tmp = t_0; elseif (z <= -4.3e-150) tmp = Float64(z + x); elseif (z <= -1.4e-285) tmp = Float64(z + Float64(y + x)); elseif (z <= 2.3e+105) tmp = Float64(z + x); 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 <= -3e+70) tmp = t_0; elseif (z <= -4.3e-150) tmp = z + x; elseif (z <= -1.4e-285) tmp = z + (y + x); elseif (z <= 2.3e+105) tmp = z + x; 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, -3e+70], t$95$0, If[LessEqual[z, -4.3e-150], N[(z + x), $MachinePrecision], If[LessEqual[z, -1.4e-285], N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.3e+105], N[(z + x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -3 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -4.3 \cdot 10^{-150}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{-285}:\\
\;\;\;\;z + \left(y + x\right)\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+105}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -1.02e+70)
t_0
(if (<= z -0.00064) (+ z x) (if (<= z 6.5e+104) (+ x (sin y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -1.02e+70) {
tmp = t_0;
} else if (z <= -0.00064) {
tmp = z + x;
} else if (z <= 6.5e+104) {
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 <= (-1.02d+70)) then
tmp = t_0
else if (z <= (-0.00064d0)) then
tmp = z + x
else if (z <= 6.5d+104) 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 <= -1.02e+70) {
tmp = t_0;
} else if (z <= -0.00064) {
tmp = z + x;
} else if (z <= 6.5e+104) {
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 <= -1.02e+70: tmp = t_0 elif z <= -0.00064: tmp = z + x elif z <= 6.5e+104: 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 <= -1.02e+70) tmp = t_0; elseif (z <= -0.00064) tmp = Float64(z + x); elseif (z <= 6.5e+104) 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 <= -1.02e+70) tmp = t_0; elseif (z <= -0.00064) tmp = z + x; elseif (z <= 6.5e+104) 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, -1.02e+70], t$95$0, If[LessEqual[z, -0.00064], N[(z + x), $MachinePrecision], If[LessEqual[z, 6.5e+104], 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 -1.02 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -0.00064:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+104}:\\
\;\;\;\;x + \sin y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -4.3e+70) (not (<= z 1.4e+105))) (* z (cos y)) (+ z (+ x (sin y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.3e+70) || !(z <= 1.4e+105)) {
tmp = z * cos(y);
} else {
tmp = z + (x + 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 ((z <= (-4.3d+70)) .or. (.not. (z <= 1.4d+105))) then
tmp = z * cos(y)
else
tmp = z + (x + sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.3e+70) || !(z <= 1.4e+105)) {
tmp = z * Math.cos(y);
} else {
tmp = z + (x + Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.3e+70) or not (z <= 1.4e+105): tmp = z * math.cos(y) else: tmp = z + (x + math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.3e+70) || !(z <= 1.4e+105)) tmp = Float64(z * cos(y)); else tmp = Float64(z + Float64(x + sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.3e+70) || ~((z <= 1.4e+105))) tmp = z * cos(y); else tmp = z + (x + sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.3e+70], N[Not[LessEqual[z, 1.4e+105]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{+70} \lor \neg \left(z \leq 1.4 \cdot 10^{+105}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;z + \left(x + \sin y\right)\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -9.2e+33) (not (<= y 1.04e+49))) (+ z x) (+ z (+ y x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.2e+33) || !(y <= 1.04e+49)) {
tmp = z + x;
} else {
tmp = z + (y + 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 ((y <= (-9.2d+33)) .or. (.not. (y <= 1.04d+49))) then
tmp = z + x
else
tmp = z + (y + x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -9.2e+33) || !(y <= 1.04e+49)) {
tmp = z + x;
} else {
tmp = z + (y + x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9.2e+33) or not (y <= 1.04e+49): tmp = z + x else: tmp = z + (y + x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9.2e+33) || !(y <= 1.04e+49)) tmp = Float64(z + x); else tmp = Float64(z + Float64(y + x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9.2e+33) || ~((y <= 1.04e+49))) tmp = z + x; else tmp = z + (y + x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.2e+33], N[Not[LessEqual[y, 1.04e+49]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+33} \lor \neg \left(y \leq 1.04 \cdot 10^{+49}\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;z + \left(y + x\right)\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= x -1.32e-104) x (if (<= x 7.5e-96) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.32e-104) {
tmp = x;
} else if (x <= 7.5e-96) {
tmp = 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 <= (-1.32d-104)) then
tmp = x
else if (x <= 7.5d-96) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.32e-104) {
tmp = x;
} else if (x <= 7.5e-96) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.32e-104: tmp = x elif x <= 7.5e-96: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.32e-104) tmp = x; elseif (x <= 7.5e-96) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.32e-104) tmp = x; elseif (x <= 7.5e-96) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.32e-104], x, If[LessEqual[x, 7.5e-96], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.32 \cdot 10^{-104}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-96}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= x -1.45e-39) x (if (<= x 2.9e+40) z x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.45e-39) {
tmp = x;
} else if (x <= 2.9e+40) {
tmp = z;
} 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 <= (-1.45d-39)) then
tmp = x
else if (x <= 2.9d+40) then
tmp = z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.45e-39) {
tmp = x;
} else if (x <= 2.9e+40) {
tmp = z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.45e-39: tmp = x elif x <= 2.9e+40: tmp = z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.45e-39) tmp = x; elseif (x <= 2.9e+40) tmp = z; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.45e-39) tmp = x; elseif (x <= 2.9e+40) tmp = z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.45e-39], x, If[LessEqual[x, 2.9e+40], z, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-39}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{+40}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (+ z x))
double code(double x, double y, double z) {
return z + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + x
end function
public static double code(double x, double y, double z) {
return z + x;
}
def code(x, y, z): return z + x
function code(x, y, z) return Float64(z + x) end
function tmp = code(x, y, z) tmp = z + x; end
code[x_, y_, z_] := N[(z + x), $MachinePrecision]
\begin{array}{l}
\\
z + x
\end{array}
(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}
herbie shell --seed 2023347
(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))))