
(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)) (- (* (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}
Initial program 75.1%
+-commutative75.1%
Simplified75.1%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((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 = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 75.1%
+-commutative75.1%
Simplified75.1%
add-exp-log42.2%
Applied egg-rr42.2%
rem-exp-log75.1%
div-inv75.0%
*-commutative75.0%
associate-*r*74.9%
associate-*l/75.0%
*-un-lft-identity75.0%
Applied egg-rr75.0%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 75.1%
associate-/l*75.0%
remove-double-neg75.0%
remove-double-neg75.0%
+-commutative75.0%
Simplified75.0%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (fma (cos b) (cos a) 0.0))))
double code(double r, double a, double b) {
return sin(b) * (r / fma(cos(b), cos(a), 0.0));
}
function code(r, a, b) return Float64(sin(b) * Float64(r / fma(cos(b), cos(a), 0.0))) end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\mathsf{fma}\left(\cos b, \cos a, 0\right)}
\end{array}
Initial program 75.1%
+-commutative75.1%
Simplified75.1%
add-exp-log42.2%
Applied egg-rr42.2%
rem-exp-log75.1%
div-inv75.0%
*-commutative75.0%
associate-*r*74.9%
associate-*l/75.0%
*-un-lft-identity75.0%
Applied egg-rr75.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
add-sqr-sqrt50.1%
sqrt-unprod85.7%
sqr-neg85.7%
sqrt-unprod35.5%
add-sqr-sqrt75.1%
sin-mult76.6%
cos-diff75.6%
add-sqr-sqrt35.9%
sqrt-unprod76.2%
sqr-neg76.2%
sqrt-unprod40.3%
add-sqr-sqrt77.2%
distribute-lft-neg-out77.2%
unsub-neg77.2%
cos-sum76.4%
Applied egg-rr76.4%
+-inverses76.4%
metadata-eval76.4%
Simplified76.4%
Final simplification76.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.1e-5) (not (<= b 2100.0))) (/ (* r (sin b)) (cos b)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.1e-5) || !(b <= 2100.0)) {
tmp = (r * sin(b)) / cos(b);
} else {
tmp = (r * b) / cos((b + 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 <= (-4.1d-5)) .or. (.not. (b <= 2100.0d0))) then
tmp = (r * sin(b)) / cos(b)
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -4.1e-5) || !(b <= 2100.0)) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.1e-5) or not (b <= 2100.0): tmp = (r * math.sin(b)) / math.cos(b) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.1e-5) || !(b <= 2100.0)) tmp = Float64(Float64(r * sin(b)) / cos(b)); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.1e-5) || ~((b <= 2100.0))) tmp = (r * sin(b)) / cos(b); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.1e-5], N[Not[LessEqual[b, 2100.0]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.1 \cdot 10^{-5} \lor \neg \left(b \leq 2100\right):\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -4.10000000000000005e-5 or 2100 < b Initial program 47.8%
associate-/l*47.8%
remove-double-neg47.8%
remove-double-neg47.8%
+-commutative47.8%
Simplified47.8%
Taylor expanded in a around 0 48.3%
if -4.10000000000000005e-5 < b < 2100Initial program 97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in b around 0 97.0%
Final simplification75.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.000112) (not (<= b 2100.0))) (* r (/ (sin b) (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000112) || !(b <= 2100.0)) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = (r * b) / cos((b + 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.000112d0)) .or. (.not. (b <= 2100.0d0))) then
tmp = r * (sin(b) / cos(b))
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000112) || !(b <= 2100.0)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.000112) or not (b <= 2100.0): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.000112) || !(b <= 2100.0)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.000112) || ~((b <= 2100.0))) tmp = r * (sin(b) / cos(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.000112], N[Not[LessEqual[b, 2100.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.000112 \lor \neg \left(b \leq 2100\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -1.11999999999999998e-4 or 2100 < b Initial program 47.8%
associate-/l*47.8%
remove-double-neg47.8%
remove-double-neg47.8%
+-commutative47.8%
Simplified47.8%
Taylor expanded in a around 0 48.3%
associate-/l*48.3%
Simplified48.3%
if -1.11999999999999998e-4 < b < 2100Initial program 97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in b around 0 97.0%
Final simplification75.3%
(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}
Initial program 75.1%
+-commutative75.1%
Simplified75.1%
add-exp-log42.2%
Applied egg-rr42.2%
rem-exp-log75.1%
div-inv75.0%
*-commutative75.0%
associate-*r*74.9%
associate-*l/75.0%
*-un-lft-identity75.0%
Applied egg-rr75.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
fma-undefine99.5%
add-sqr-sqrt50.1%
sqrt-unprod85.7%
sqr-neg85.7%
sqrt-unprod35.5%
add-sqr-sqrt75.1%
cos-diff75.2%
Applied egg-rr75.2%
Final simplification75.2%
(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}
Initial program 75.1%
associate-/l*75.0%
remove-double-neg75.0%
remove-double-neg75.0%
+-commutative75.0%
Simplified75.0%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos a))))
double code(double r, double a, double b) {
return r * (sin(b) / cos(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(a))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos(a));
}
def code(r, a, b): return r * (math.sin(b) / math.cos(a))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(a))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos(a)); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a}
\end{array}
Initial program 75.1%
associate-/l*75.0%
remove-double-neg75.0%
remove-double-neg75.0%
+-commutative75.0%
Simplified75.0%
Taylor expanded in b around 0 58.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -24.0) (not (<= b 1.3e+31))) (* r (sin b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -24.0) || !(b <= 1.3e+31)) {
tmp = r * sin(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 <= (-24.0d0)) .or. (.not. (b <= 1.3d+31))) then
tmp = r * sin(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 <= -24.0) || !(b <= 1.3e+31)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -24.0) or not (b <= 1.3e+31): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -24.0) || !(b <= 1.3e+31)) tmp = Float64(r * sin(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 <= -24.0) || ~((b <= 1.3e+31))) tmp = r * sin(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -24.0], N[Not[LessEqual[b, 1.3e+31]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -24 \lor \neg \left(b \leq 1.3 \cdot 10^{+31}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -24 or 1.3e31 < b Initial program 48.3%
+-commutative48.3%
Simplified48.3%
clear-num48.2%
associate-/r/48.3%
Applied egg-rr48.3%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 13.8%
if -24 < b < 1.3e31Initial program 95.3%
associate-/l*95.2%
remove-double-neg95.2%
remove-double-neg95.2%
+-commutative95.2%
Simplified95.2%
Taylor expanded in b around 0 94.6%
Final simplification59.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -24.0) (not (<= b 1.3e+31))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -24.0) || !(b <= 1.3e+31)) {
tmp = r * sin(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 <= (-24.0d0)) .or. (.not. (b <= 1.3d+31))) then
tmp = r * sin(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 <= -24.0) || !(b <= 1.3e+31)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -24.0) or not (b <= 1.3e+31): tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -24.0) || !(b <= 1.3e+31)) tmp = Float64(r * sin(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 <= -24.0) || ~((b <= 1.3e+31))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -24.0], N[Not[LessEqual[b, 1.3e+31]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -24 \lor \neg \left(b \leq 1.3 \cdot 10^{+31}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -24 or 1.3e31 < b Initial program 48.3%
+-commutative48.3%
Simplified48.3%
clear-num48.2%
associate-/r/48.3%
Applied egg-rr48.3%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 13.8%
if -24 < b < 1.3e31Initial program 95.3%
associate-/l*95.2%
remove-double-neg95.2%
remove-double-neg95.2%
+-commutative95.2%
Simplified95.2%
Taylor expanded in b around 0 94.6%
associate-/l*94.6%
Simplified94.6%
Final simplification59.9%
(FPCore (r a b) :precision binary64 (* r (sin b)))
double code(double r, double a, double b) {
return r * sin(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)
end function
public static double code(double r, double a, double b) {
return r * Math.sin(b);
}
def code(r, a, b): return r * math.sin(b)
function code(r, a, b) return Float64(r * sin(b)) end
function tmp = code(r, a, b) tmp = r * sin(b); end
code[r_, a_, b_] := N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \sin b
\end{array}
Initial program 75.1%
+-commutative75.1%
Simplified75.1%
clear-num74.3%
associate-/r/75.0%
Applied egg-rr75.0%
Taylor expanded in b around 0 58.8%
Taylor expanded in a around 0 41.7%
(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}
Initial program 75.1%
associate-/l*75.0%
remove-double-neg75.0%
remove-double-neg75.0%
+-commutative75.0%
Simplified75.0%
Taylor expanded in b around 0 55.6%
associate-/l*55.5%
Simplified55.5%
Taylor expanded in a around 0 37.6%
Final simplification37.6%
herbie shell --seed 2024180
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))