
(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 9 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 (- (+ 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 (<= x -1.05e+39) x (if (<= x 1e+38) (- (cos y) (* z (sin y))) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.05e+39) {
tmp = x;
} else if (x <= 1e+38) {
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 <= (-1.05d+39)) then
tmp = x
else if (x <= 1d+38) 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 <= -1.05e+39) {
tmp = x;
} else if (x <= 1e+38) {
tmp = Math.cos(y) - (z * Math.sin(y));
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.05e+39: tmp = x elif x <= 1e+38: 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 <= -1.05e+39) tmp = x; elseif (x <= 1e+38) 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 <= -1.05e+39) tmp = x; elseif (x <= 1e+38) tmp = cos(y) - (z * sin(y)); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.05e+39], x, If[LessEqual[x, 1e+38], 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 -1.05 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 10^{+38}:\\
\;\;\;\;\cos y - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -4.3e+70) (not (<= z 6.5e+105))) (* z (- (sin y))) (+ x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.3e+70) || !(z <= 6.5e+105)) {
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.3d+70)) .or. (.not. (z <= 6.5d+105))) 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.3e+70) || !(z <= 6.5e+105)) {
tmp = z * -Math.sin(y);
} else {
tmp = x + Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.3e+70) or not (z <= 6.5e+105): tmp = z * -math.sin(y) else: tmp = x + math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.3e+70) || !(z <= 6.5e+105)) 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.3e+70) || ~((z <= 6.5e+105))) tmp = z * -sin(y); else tmp = x + cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.3e+70], N[Not[LessEqual[z, 6.5e+105]], $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.3 \cdot 10^{+70} \lor \neg \left(z \leq 6.5 \cdot 10^{+105}\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 -7.6e+33) (not (<= y 0.033))) (+ x (cos y)) (+ x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.6e+33) || !(y <= 0.033)) {
tmp = x + cos(y);
} else {
tmp = x + (1.0 - (y * z));
}
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 <= (-7.6d+33)) .or. (.not. (y <= 0.033d0))) then
tmp = x + cos(y)
else
tmp = x + (1.0d0 - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7.6e+33) || !(y <= 0.033)) {
tmp = x + Math.cos(y);
} else {
tmp = x + (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.6e+33) or not (y <= 0.033): tmp = x + math.cos(y) else: tmp = x + (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.6e+33) || !(y <= 0.033)) tmp = Float64(x + cos(y)); else tmp = Float64(x + Float64(1.0 - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.6e+33) || ~((y <= 0.033))) tmp = x + cos(y); else tmp = x + (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.6e+33], N[Not[LessEqual[y, 0.033]], $MachinePrecision]], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.6 \cdot 10^{+33} \lor \neg \left(y \leq 0.033\right):\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;x + \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -2e+118) (not (<= y 3.1))) (+ x 1.0) (+ x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2e+118) || !(y <= 3.1)) {
tmp = x + 1.0;
} else {
tmp = x + (1.0 - (y * z));
}
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 <= (-2d+118)) .or. (.not. (y <= 3.1d0))) then
tmp = x + 1.0d0
else
tmp = x + (1.0d0 - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2e+118) || !(y <= 3.1)) {
tmp = x + 1.0;
} else {
tmp = x + (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2e+118) or not (y <= 3.1): tmp = x + 1.0 else: tmp = x + (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2e+118) || !(y <= 3.1)) tmp = Float64(x + 1.0); else tmp = Float64(x + Float64(1.0 - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2e+118) || ~((y <= 3.1))) tmp = x + 1.0; else tmp = x + (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2e+118], N[Not[LessEqual[y, 3.1]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[(x + N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+118} \lor \neg \left(y \leq 3.1\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;x + \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= x -2700000000.0) (not (<= x 0.0003))) (+ x 1.0) (- 1.0 (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2700000000.0) || !(x <= 0.0003)) {
tmp = x + 1.0;
} else {
tmp = 1.0 - (y * z);
}
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 <= (-2700000000.0d0)) .or. (.not. (x <= 0.0003d0))) then
tmp = x + 1.0d0
else
tmp = 1.0d0 - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2700000000.0) || !(x <= 0.0003)) {
tmp = x + 1.0;
} else {
tmp = 1.0 - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2700000000.0) or not (x <= 0.0003): tmp = x + 1.0 else: tmp = 1.0 - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2700000000.0) || !(x <= 0.0003)) tmp = Float64(x + 1.0); else tmp = Float64(1.0 - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2700000000.0) || ~((x <= 0.0003))) tmp = x + 1.0; else tmp = 1.0 - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2700000000.0], N[Not[LessEqual[x, 0.0003]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2700000000 \lor \neg \left(x \leq 0.0003\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;1 - y \cdot z\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -4.8e+159) (not (<= z 1.75e+172))) (* y (- z)) (+ x 1.0)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.8e+159) || !(z <= 1.75e+172)) {
tmp = y * -z;
} 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 ((z <= (-4.8d+159)) .or. (.not. (z <= 1.75d+172))) then
tmp = y * -z
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.8e+159) || !(z <= 1.75e+172)) {
tmp = y * -z;
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.8e+159) or not (z <= 1.75e+172): tmp = y * -z else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.8e+159) || !(z <= 1.75e+172)) tmp = Float64(y * Float64(-z)); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.8e+159) || ~((z <= 1.75e+172))) tmp = y * -z; else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.8e+159], N[Not[LessEqual[z, 1.75e+172]], $MachinePrecision]], N[(y * (-z)), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+159} \lor \neg \left(z \leq 1.75 \cdot 10^{+172}\right):\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\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 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, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))