
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) (* (sin b) (- (sin a))))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (sin(b) * -sin(a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
(FPCore (r a b) :precision binary64 (/ r (- (/ (cos a) (tan b)) (sin a))))
double code(double r, double a, double b) {
return r / ((cos(a) / tan(b)) - sin(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r / ((cos(a) / tan(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) / Math.tan(b)) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(a) / math.tan(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / tan(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / tan(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\tan b} - \sin a}
\end{array}
(FPCore (r a b) :precision binary64 (if (or (<= a -950.0) (not (<= a 3.7e-25))) (* (sin b) (/ r (cos a))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -950.0) || !(a <= 3.7e-25)) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = r * tan(b);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-950.0d0)) .or. (.not. (a <= 3.7d-25))) then
tmp = sin(b) * (r / cos(a))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -950.0) || !(a <= 3.7e-25)) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -950.0) or not (a <= 3.7e-25): tmp = math.sin(b) * (r / math.cos(a)) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -950.0) || !(a <= 3.7e-25)) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -950.0) || ~((a <= 3.7e-25))) tmp = sin(b) * (r / cos(a)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -950.0], N[Not[LessEqual[a, 3.7e-25]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -950 \lor \neg \left(a \leq 3.7 \cdot 10^{-25}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
(FPCore (r a b) :precision binary64 (if (or (<= a -950.0) (not (<= a 3.7e-25))) (/ r (/ (cos a) (sin b))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -950.0) || !(a <= 3.7e-25)) {
tmp = r / (cos(a) / sin(b));
} else {
tmp = r * tan(b);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-950.0d0)) .or. (.not. (a <= 3.7d-25))) then
tmp = r / (cos(a) / sin(b))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -950.0) || !(a <= 3.7e-25)) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -950.0) or not (a <= 3.7e-25): tmp = r / (math.cos(a) / math.sin(b)) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -950.0) || !(a <= 3.7e-25)) tmp = Float64(r / Float64(cos(a) / sin(b))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -950.0) || ~((a <= 3.7e-25))) tmp = r / (cos(a) / sin(b)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -950.0], N[Not[LessEqual[a, 3.7e-25]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -950 \lor \neg \left(a \leq 3.7 \cdot 10^{-25}\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
(FPCore (r a b) :precision binary64 (if (<= a -950.0) (/ (* r (sin b)) (cos a)) (if (<= a 3.7e-25) (* r (tan b)) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -950.0) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 3.7e-25) {
tmp = r * tan(b);
} else {
tmp = r / (cos(a) / sin(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-950.0d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 3.7d-25) then
tmp = r * tan(b)
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -950.0) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 3.7e-25) {
tmp = r * Math.tan(b);
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -950.0: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 3.7e-25: tmp = r * math.tan(b) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -950.0) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 3.7e-25) tmp = Float64(r * tan(b)); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -950.0) tmp = (r * sin(b)) / cos(a); elseif (a <= 3.7e-25) tmp = r * tan(b); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -950.0], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.7e-25], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -950:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 3.7 \cdot 10^{-25}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ b a)))))
double code(double r, double a, double b) {
return sin(b) * (r / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((b + a)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((b + a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((b + a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(b + a\right)}
\end{array}
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ b a)))))
double code(double r, double a, double b) {
return r * (sin(b) / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos((b + a)));
}
def code(r, a, b): return r * (math.sin(b) / math.cos((b + a)))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos((b + a))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(b + a\right)}
\end{array}
(FPCore (r a b) :precision binary64 (if (or (<= b -0.0001) (not (<= b 2.5e-26))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0001) || !(b <= 2.5e-26)) {
tmp = r * tan(b);
} else {
tmp = r * (b / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-0.0001d0)) .or. (.not. (b <= 2.5d-26))) then
tmp = r * tan(b)
else
tmp = r * (b / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0001) || !(b <= 2.5e-26)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.0001) or not (b <= 2.5e-26): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.0001) || !(b <= 2.5e-26)) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.0001) || ~((b <= 2.5e-26))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.0001], N[Not[LessEqual[b, 2.5e-26]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0001 \lor \neg \left(b \leq 2.5 \cdot 10^{-26}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
(FPCore (r a b) :precision binary64 (if (or (<= b -8.5e-6) (not (<= b 2.5e-26))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -8.5e-6) || !(b <= 2.5e-26)) {
tmp = r * tan(b);
} else {
tmp = b * (r / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-8.5d-6)) .or. (.not. (b <= 2.5d-26))) then
tmp = r * tan(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -8.5e-6) || !(b <= 2.5e-26)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -8.5e-6) or not (b <= 2.5e-26): tmp = r * math.tan(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -8.5e-6) || !(b <= 2.5e-26)) tmp = Float64(r * tan(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -8.5e-6) || ~((b <= 2.5e-26))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -8.5e-6], N[Not[LessEqual[b, 2.5e-26]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.5 \cdot 10^{-6} \lor \neg \left(b \leq 2.5 \cdot 10^{-26}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
(FPCore (r a b) :precision binary64 (if (or (<= b -0.007) (not (<= b 2.5e-26))) (* r (tan b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.007) || !(b <= 2.5e-26)) {
tmp = r * tan(b);
} else {
tmp = (r * b) / cos(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-0.007d0)) .or. (.not. (b <= 2.5d-26))) then
tmp = r * tan(b)
else
tmp = (r * b) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.007) || !(b <= 2.5e-26)) {
tmp = r * Math.tan(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.007) or not (b <= 2.5e-26): tmp = r * math.tan(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.007) || !(b <= 2.5e-26)) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.007) || ~((b <= 2.5e-26))) tmp = r * tan(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.007], N[Not[LessEqual[b, 2.5e-26]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.007 \lor \neg \left(b \leq 2.5 \cdot 10^{-26}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
(FPCore (r a b) :precision binary64 (* r (tan b)))
double code(double r, double a, double b) {
return r * tan(b);
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * tan(b)
end function
public static double code(double r, double a, double b) {
return r * Math.tan(b);
}
def code(r, a, b): return r * math.tan(b)
function code(r, a, b) return Float64(r * tan(b)) end
function tmp = code(r, a, b) tmp = r * tan(b); end
code[r_, a_, b_] := N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \tan b
\end{array}
(FPCore (r a b) :precision binary64 (* r b))
double code(double r, double a, double b) {
return r * b;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * b
end function
public static double code(double r, double a, double b) {
return r * b;
}
def code(r, a, b): return r * b
function code(r, a, b) return Float64(r * b) end
function tmp = code(r, a, b) tmp = r * b; end
code[r_, a_, b_] := N[(r * b), $MachinePrecision]
\begin{array}{l}
\\
r \cdot b
\end{array}
herbie shell --seed 2023348
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))