
(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}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 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}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (fma z (- (sin y)) (+ x (cos y))))
double code(double x, double y, double z) {
return fma(z, -sin(y), (x + cos(y)));
}
function code(x, y, z) return fma(z, Float64(-sin(y)), Float64(x + cos(y))) end
code[x_, y_, z_] := N[(z * (-N[Sin[y], $MachinePrecision]) + N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, -\sin y, x + \cos y\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (<= x -0.00046) (+ x (cos y)) (if (<= x 18000.0) (- (cos y) (* z (sin y))) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.00046) {
tmp = x + cos(y);
} else if (x <= 18000.0) {
tmp = cos(y) - (z * sin(y));
} else {
tmp = x + 1.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) :: tmp
if (x <= (-0.00046d0)) then
tmp = x + cos(y)
else if (x <= 18000.0d0) then
tmp = cos(y) - (z * sin(y))
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -0.00046) {
tmp = x + Math.cos(y);
} else if (x <= 18000.0) {
tmp = Math.cos(y) - (z * Math.sin(y));
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.00046: tmp = x + math.cos(y) elif x <= 18000.0: tmp = math.cos(y) - (z * math.sin(y)) else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.00046) tmp = Float64(x + cos(y)); elseif (x <= 18000.0) tmp = Float64(cos(y) - Float64(z * sin(y))); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -0.00046) tmp = x + cos(y); elseif (x <= 18000.0) tmp = cos(y) - (z * sin(y)); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -0.00046], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 18000.0], N[(N[Cos[y], $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00046:\\
\;\;\;\;x + \cos y\\
\mathbf{elif}\;x \leq 18000:\\
\;\;\;\;\cos y - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\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}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -4.4e+64) (not (<= z 8.6e+240))) (* z (- (sin y))) (+ x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.4e+64) || !(z <= 8.6e+240)) {
tmp = 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 <= (-4.4d+64)) .or. (.not. (z <= 8.6d+240))) then
tmp = 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 <= -4.4e+64) || !(z <= 8.6e+240)) {
tmp = z * -Math.sin(y);
} else {
tmp = x + Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.4e+64) or not (z <= 8.6e+240): tmp = z * -math.sin(y) else: tmp = x + math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.4e+64) || !(z <= 8.6e+240)) tmp = Float64(z * Float64(-sin(y))); else tmp = Float64(x + cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.4e+64) || ~((z <= 8.6e+240))) tmp = z * -sin(y); else tmp = x + cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.4e+64], N[Not[LessEqual[z, 8.6e+240]], $MachinePrecision]], N[(z * (-N[Sin[y], $MachinePrecision])), $MachinePrecision], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+64} \lor \neg \left(z \leq 8.6 \cdot 10^{+240}\right):\\
\;\;\;\;z \cdot \left(-\sin y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \cos y\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -420000000.0) (not (<= y 8.6e+35))) (+ x (cos y)) (+ 1.0 (- x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -420000000.0) || !(y <= 8.6e+35)) {
tmp = x + cos(y);
} else {
tmp = 1.0 + (x - (z * 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 ((y <= (-420000000.0d0)) .or. (.not. (y <= 8.6d+35))) then
tmp = x + cos(y)
else
tmp = 1.0d0 + (x - (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -420000000.0) || !(y <= 8.6e+35)) {
tmp = x + Math.cos(y);
} else {
tmp = 1.0 + (x - (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -420000000.0) or not (y <= 8.6e+35): tmp = x + math.cos(y) else: tmp = 1.0 + (x - (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -420000000.0) || !(y <= 8.6e+35)) tmp = Float64(x + cos(y)); else tmp = Float64(1.0 + Float64(x - Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -420000000.0) || ~((y <= 8.6e+35))) tmp = x + cos(y); else tmp = 1.0 + (x - (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -420000000.0], N[Not[LessEqual[y, 8.6e+35]], $MachinePrecision]], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -420000000 \lor \neg \left(y \leq 8.6 \cdot 10^{+35}\right):\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x - z \cdot y\right)\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -6e+39) (not (<= y 3.6e+94))) (+ x 1.0) (+ 1.0 (- x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+39) || !(y <= 3.6e+94)) {
tmp = x + 1.0;
} else {
tmp = 1.0 + (x - (z * 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 ((y <= (-6d+39)) .or. (.not. (y <= 3.6d+94))) then
tmp = x + 1.0d0
else
tmp = 1.0d0 + (x - (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+39) || !(y <= 3.6e+94)) {
tmp = x + 1.0;
} else {
tmp = 1.0 + (x - (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6e+39) or not (y <= 3.6e+94): tmp = x + 1.0 else: tmp = 1.0 + (x - (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6e+39) || !(y <= 3.6e+94)) tmp = Float64(x + 1.0); else tmp = Float64(1.0 + Float64(x - Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6e+39) || ~((y <= 3.6e+94))) tmp = x + 1.0; else tmp = 1.0 + (x - (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6e+39], N[Not[LessEqual[y, 3.6e+94]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[(1.0 + N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+39} \lor \neg \left(y \leq 3.6 \cdot 10^{+94}\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x - z \cdot y\right)\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= x -8.2e-8) (not (<= x 17500.0))) (+ x 1.0) (- 1.0 (* z y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.2e-8) || !(x <= 17500.0)) {
tmp = x + 1.0;
} else {
tmp = 1.0 - (z * 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 <= (-8.2d-8)) .or. (.not. (x <= 17500.0d0))) then
tmp = x + 1.0d0
else
tmp = 1.0d0 - (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.2e-8) || !(x <= 17500.0)) {
tmp = x + 1.0;
} else {
tmp = 1.0 - (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.2e-8) or not (x <= 17500.0): tmp = x + 1.0 else: tmp = 1.0 - (z * y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.2e-8) || !(x <= 17500.0)) tmp = Float64(x + 1.0); else tmp = Float64(1.0 - Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.2e-8) || ~((x <= 17500.0))) tmp = x + 1.0; else tmp = 1.0 - (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.2e-8], N[Not[LessEqual[x, 17500.0]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{-8} \lor \neg \left(x \leq 17500\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;1 - z \cdot y\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= x -0.0275) x (if (<= x 6.5e-8) 1.0 x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.0275) {
tmp = x;
} else if (x <= 6.5e-8) {
tmp = 1.0;
} 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 <= (-0.0275d0)) then
tmp = x
else if (x <= 6.5d-8) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -0.0275) {
tmp = x;
} else if (x <= 6.5e-8) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.0275: tmp = x elif x <= 6.5e-8: tmp = 1.0 else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.0275) tmp = x; elseif (x <= 6.5e-8) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -0.0275) tmp = x; elseif (x <= 6.5e-8) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -0.0275], x, If[LessEqual[x, 6.5e-8], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0275:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-8}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
return x + 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + 1.0d0
end function
public static double code(double x, double y, double z) {
return x + 1.0;
}
def code(x, y, z): return x + 1.0
function code(x, y, z) return Float64(x + 1.0) end
function tmp = code(x, y, z) tmp = x + 1.0; end
code[x_, y_, z_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
herbie shell --seed 2023343
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))