
(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 14 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 (* (/ (sin b) (fma (cos b) (cos a) (* (sin b) (- (sin a))))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(cos(b), cos(a), (sin(b) * -sin(a)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) * r) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)} \cdot r
\end{array}
Initial program 78.6%
associate-/l*78.6%
remove-double-neg78.6%
sin-neg78.6%
neg-mul-178.6%
associate-/r*78.6%
associate-/l*78.6%
*-commutative78.6%
associate-*l/78.6%
associate-/l*78.6%
sin-neg78.6%
distribute-lft-neg-in78.6%
distribute-rgt-neg-in78.6%
associate-/l*78.6%
metadata-eval78.6%
/-rgt-identity78.6%
+-commutative78.6%
Simplified78.6%
cos-sum99.4%
fma-neg99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ r (fma (/ 1.0 (tan b)) (cos a) (- (sin a)))))
double code(double r, double a, double b) {
return r / fma((1.0 / tan(b)), cos(a), -sin(a));
}
function code(r, a, b) return Float64(r / fma(Float64(1.0 / tan(b)), cos(a), Float64(-sin(a)))) end
code[r_, a_, b_] := N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] * N[Cos[a], $MachinePrecision] + (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\mathsf{fma}\left(\frac{1}{\tan b}, \cos a, -\sin a\right)}
\end{array}
Initial program 78.6%
associate-/l*78.6%
+-commutative78.6%
Simplified78.6%
cos-sum99.3%
Applied egg-rr99.3%
div-sub99.3%
sub-neg99.3%
associate-/l*99.3%
*-commutative99.3%
associate-/l*99.3%
Applied egg-rr99.3%
sub-neg99.3%
associate-/r/99.3%
*-inverses99.3%
Simplified99.3%
fma-neg99.3%
clear-num99.3%
quot-tan99.4%
/-rgt-identity99.4%
Applied egg-rr99.4%
Final simplification99.4%
(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}
Initial program 78.6%
associate-/l*78.6%
+-commutative78.6%
Simplified78.6%
cos-sum99.3%
Applied egg-rr99.3%
div-sub99.3%
sub-neg99.3%
associate-/l*99.3%
*-commutative99.3%
associate-/l*99.3%
Applied egg-rr99.3%
sub-neg99.3%
associate-/r/99.3%
*-inverses99.3%
Simplified99.3%
sub-neg99.3%
/-rgt-identity99.3%
*-commutative99.3%
clear-num99.3%
un-div-inv99.3%
quot-tan99.4%
Applied egg-rr99.4%
unsub-neg99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -7.6e-6) (not (<= b 2.4e-14))) (* r (/ (sin b) (cos b))) (/ (* b r) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -7.6e-6) || !(b <= 2.4e-14)) {
tmp = r * (sin(b) / cos(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 <= (-7.6d-6)) .or. (.not. (b <= 2.4d-14))) then
tmp = r * (sin(b) / cos(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 <= -7.6e-6) || !(b <= 2.4e-14)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = (b * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -7.6e-6) or not (b <= 2.4e-14): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = (b * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -7.6e-6) || !(b <= 2.4e-14)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(Float64(b * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -7.6e-6) || ~((b <= 2.4e-14))) tmp = r * (sin(b) / cos(b)); else tmp = (b * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -7.6e-6], N[Not[LessEqual[b, 2.4e-14]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{-6} \lor \neg \left(b \leq 2.4 \cdot 10^{-14}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\end{array}
\end{array}
if b < -7.6000000000000001e-6 or 2.4e-14 < b Initial program 61.1%
associate-/l*61.1%
remove-double-neg61.1%
sin-neg61.1%
neg-mul-161.1%
associate-/r*61.1%
associate-/l*61.1%
*-commutative61.1%
associate-*l/61.1%
associate-/l*61.1%
sin-neg61.1%
distribute-lft-neg-in61.1%
distribute-rgt-neg-in61.1%
associate-/l*61.1%
metadata-eval61.1%
/-rgt-identity61.1%
+-commutative61.1%
Simplified61.1%
Taylor expanded in a around 0 61.1%
if -7.6000000000000001e-6 < b < 2.4e-14Initial program 99.8%
associate-/l*99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/l*99.8%
*-commutative99.8%
associate-*l/99.7%
associate-/l*99.7%
sin-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in b around 0 99.8%
Final simplification78.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.05e-6) (not (<= b 4.2e-6))) (/ r (/ (cos b) (sin b))) (/ (* b r) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.05e-6) || !(b <= 4.2e-6)) {
tmp = r / (cos(b) / 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 <= (-2.05d-6)) .or. (.not. (b <= 4.2d-6))) then
tmp = r / (cos(b) / 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 <= -2.05e-6) || !(b <= 4.2e-6)) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else {
tmp = (b * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.05e-6) or not (b <= 4.2e-6): tmp = r / (math.cos(b) / math.sin(b)) else: tmp = (b * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.05e-6) || !(b <= 4.2e-6)) tmp = Float64(r / Float64(cos(b) / sin(b))); else tmp = Float64(Float64(b * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.05e-6) || ~((b <= 4.2e-6))) tmp = r / (cos(b) / sin(b)); else tmp = (b * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.05e-6], N[Not[LessEqual[b, 4.2e-6]], $MachinePrecision]], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.05 \cdot 10^{-6} \lor \neg \left(b \leq 4.2 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\end{array}
\end{array}
if b < -2.0499999999999999e-6 or 4.1999999999999996e-6 < b Initial program 60.8%
associate-/l*60.9%
+-commutative60.9%
Simplified60.9%
Taylor expanded in a around 0 60.9%
if -2.0499999999999999e-6 < b < 4.1999999999999996e-6Initial program 99.8%
associate-/l*99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/l*99.8%
*-commutative99.8%
associate-*l/99.7%
associate-/l*99.7%
sin-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in b around 0 99.8%
Final simplification78.7%
(FPCore (r a b) :precision binary64 (if (<= b -9.5e-7) (/ (sin b) (/ (cos b) r)) (if (<= b 5e-5) (/ (* b r) (cos a)) (/ r (/ (cos b) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -9.5e-7) {
tmp = sin(b) / (cos(b) / r);
} else if (b <= 5e-5) {
tmp = (b * r) / cos(a);
} else {
tmp = r / (cos(b) / 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 (b <= (-9.5d-7)) then
tmp = sin(b) / (cos(b) / r)
else if (b <= 5d-5) then
tmp = (b * r) / cos(a)
else
tmp = r / (cos(b) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -9.5e-7) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else if (b <= 5e-5) {
tmp = (b * r) / Math.cos(a);
} else {
tmp = r / (Math.cos(b) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -9.5e-7: tmp = math.sin(b) / (math.cos(b) / r) elif b <= 5e-5: tmp = (b * r) / math.cos(a) else: tmp = r / (math.cos(b) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -9.5e-7) tmp = Float64(sin(b) / Float64(cos(b) / r)); elseif (b <= 5e-5) tmp = Float64(Float64(b * r) / cos(a)); else tmp = Float64(r / Float64(cos(b) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -9.5e-7) tmp = sin(b) / (cos(b) / r); elseif (b <= 5e-5) tmp = (b * r) / cos(a); else tmp = r / (cos(b) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -9.5e-7], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e-5], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\end{array}
\end{array}
if b < -9.5000000000000001e-7Initial program 60.8%
associate-/l*60.8%
remove-double-neg60.8%
sin-neg60.8%
neg-mul-160.8%
associate-/r*60.8%
associate-/l*60.8%
*-commutative60.8%
associate-*l/60.7%
associate-/l*60.7%
sin-neg60.7%
distribute-lft-neg-in60.7%
distribute-rgt-neg-in60.7%
associate-/l*60.7%
metadata-eval60.7%
/-rgt-identity60.7%
+-commutative60.7%
Simplified60.7%
associate-*l/60.8%
associate-/l*60.8%
Applied egg-rr60.8%
Taylor expanded in a around 0 61.0%
if -9.5000000000000001e-7 < b < 5.00000000000000024e-5Initial program 99.8%
associate-/l*99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/l*99.8%
*-commutative99.8%
associate-*l/99.7%
associate-/l*99.7%
sin-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in b around 0 99.8%
if 5.00000000000000024e-5 < b Initial program 60.8%
associate-/l*61.0%
+-commutative61.0%
Simplified61.0%
Taylor expanded in a around 0 60.9%
Final simplification78.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -7.4e+15) (not (<= b 1.86))) (fabs (* (sin b) r)) (/ (* b r) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -7.4e+15) || !(b <= 1.86)) {
tmp = fabs((sin(b) * r));
} else {
tmp = (b * r) / 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 <= (-7.4d+15)) .or. (.not. (b <= 1.86d0))) then
tmp = abs((sin(b) * r))
else
tmp = (b * r) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -7.4e+15) || !(b <= 1.86)) {
tmp = Math.abs((Math.sin(b) * r));
} else {
tmp = (b * r) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -7.4e+15) or not (b <= 1.86): tmp = math.fabs((math.sin(b) * r)) else: tmp = (b * r) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -7.4e+15) || !(b <= 1.86)) tmp = abs(Float64(sin(b) * r)); else tmp = Float64(Float64(b * r) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -7.4e+15) || ~((b <= 1.86))) tmp = abs((sin(b) * r)); else tmp = (b * r) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -7.4e+15], N[Not[LessEqual[b, 1.86]], $MachinePrecision]], N[Abs[N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]], $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.4 \cdot 10^{+15} \lor \neg \left(b \leq 1.86\right):\\
\;\;\;\;\left|\sin b \cdot r\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -7.4e15 or 1.8600000000000001 < b Initial program 59.3%
associate-/l*59.4%
remove-double-neg59.4%
sin-neg59.4%
neg-mul-159.4%
associate-/r*59.4%
associate-/l*59.3%
*-commutative59.3%
associate-*l/59.4%
associate-/l*59.4%
sin-neg59.4%
distribute-lft-neg-in59.4%
distribute-rgt-neg-in59.4%
associate-/l*59.4%
metadata-eval59.4%
/-rgt-identity59.4%
+-commutative59.4%
Simplified59.4%
associate-*l/59.3%
associate-/l*59.4%
Applied egg-rr59.4%
Taylor expanded in b around 0 11.7%
add-sqr-sqrt6.5%
sqrt-unprod9.1%
pow29.1%
div-inv9.1%
clear-num9.1%
Applied egg-rr9.1%
unpow29.1%
rem-sqrt-square12.2%
Simplified12.2%
Taylor expanded in a around 0 12.7%
if -7.4e15 < b < 1.8600000000000001Initial program 99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 97.5%
Final simplification53.1%
(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 78.6%
associate-/l*78.6%
+-commutative78.6%
Simplified78.6%
associate-/r/78.6%
Applied egg-rr78.6%
Final simplification78.6%
(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 78.6%
associate-/l*78.6%
remove-double-neg78.6%
sin-neg78.6%
neg-mul-178.6%
associate-/r*78.6%
associate-/l*78.6%
*-commutative78.6%
associate-*l/78.6%
associate-/l*78.6%
sin-neg78.6%
distribute-lft-neg-in78.6%
distribute-rgt-neg-in78.6%
associate-/l*78.6%
metadata-eval78.6%
/-rgt-identity78.6%
+-commutative78.6%
Simplified78.6%
associate-*l/78.6%
associate-/l*78.6%
Applied egg-rr78.6%
clear-num78.0%
cos-sum98.8%
associate-/r/99.3%
clear-num99.4%
sub-neg99.4%
add-sqr-sqrt51.2%
sqrt-unprod89.1%
sqr-neg89.1%
sqrt-unprod48.0%
add-sqr-sqrt78.5%
cos-diff78.7%
Applied egg-rr78.7%
Final simplification78.7%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(b) * (r / 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 = sin(b) * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 78.6%
associate-/l*78.6%
remove-double-neg78.6%
sin-neg78.6%
neg-mul-178.6%
associate-/r*78.6%
associate-/l*78.6%
*-commutative78.6%
associate-*l/78.6%
associate-/l*78.6%
sin-neg78.6%
distribute-lft-neg-in78.6%
distribute-rgt-neg-in78.6%
associate-/l*78.6%
metadata-eval78.6%
/-rgt-identity78.6%
+-commutative78.6%
Simplified78.6%
associate-*l/78.6%
associate-/l*78.6%
Applied egg-rr78.6%
Taylor expanded in b around 0 52.5%
Taylor expanded in b around inf 52.5%
*-commutative52.5%
associate-*r/52.5%
Simplified52.5%
Final simplification52.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -9.8e+27) (not (<= b 9.4e+27))) (* (sin b) r) (/ b (/ (cos a) r))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -9.8e+27) || !(b <= 9.4e+27)) {
tmp = sin(b) * r;
} else {
tmp = b / (cos(a) / r);
}
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 <= (-9.8d+27)) .or. (.not. (b <= 9.4d+27))) then
tmp = sin(b) * r
else
tmp = b / (cos(a) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -9.8e+27) || !(b <= 9.4e+27)) {
tmp = Math.sin(b) * r;
} else {
tmp = b / (Math.cos(a) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -9.8e+27) or not (b <= 9.4e+27): tmp = math.sin(b) * r else: tmp = b / (math.cos(a) / r) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -9.8e+27) || !(b <= 9.4e+27)) tmp = Float64(sin(b) * r); else tmp = Float64(b / Float64(cos(a) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -9.8e+27) || ~((b <= 9.4e+27))) tmp = sin(b) * r; else tmp = b / (cos(a) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -9.8e+27], N[Not[LessEqual[b, 9.4e+27]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(b / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.8 \cdot 10^{+27} \lor \neg \left(b \leq 9.4 \cdot 10^{+27}\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if b < -9.8000000000000003e27 or 9.39999999999999952e27 < b Initial program 59.2%
associate-/l*59.3%
remove-double-neg59.3%
sin-neg59.3%
neg-mul-159.3%
associate-/r*59.3%
associate-/l*59.2%
*-commutative59.2%
associate-*l/59.3%
associate-/l*59.3%
sin-neg59.3%
distribute-lft-neg-in59.3%
distribute-rgt-neg-in59.3%
associate-/l*59.3%
metadata-eval59.3%
/-rgt-identity59.3%
+-commutative59.3%
Simplified59.3%
associate-*l/59.2%
associate-/l*59.3%
Applied egg-rr59.3%
Taylor expanded in b around 0 11.9%
Taylor expanded in a around 0 11.7%
if -9.8000000000000003e27 < b < 9.39999999999999952e27Initial program 97.7%
associate-/l*97.5%
remove-double-neg97.5%
sin-neg97.5%
neg-mul-197.5%
associate-/r*97.5%
associate-/l*97.7%
*-commutative97.7%
associate-*l/97.6%
associate-/l*97.6%
sin-neg97.6%
distribute-lft-neg-in97.6%
distribute-rgt-neg-in97.6%
associate-/l*97.6%
metadata-eval97.6%
/-rgt-identity97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in b around 0 92.6%
associate-/l*92.5%
Simplified92.5%
Final simplification52.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.6e+27) (not (<= b 8.8e+27))) (* (sin b) r) (/ (* b r) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.6e+27) || !(b <= 8.8e+27)) {
tmp = sin(b) * r;
} 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 <= (-1.6d+27)) .or. (.not. (b <= 8.8d+27))) then
tmp = sin(b) * r
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 <= -1.6e+27) || !(b <= 8.8e+27)) {
tmp = Math.sin(b) * r;
} else {
tmp = (b * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.6e+27) or not (b <= 8.8e+27): tmp = math.sin(b) * r else: tmp = (b * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.6e+27) || !(b <= 8.8e+27)) tmp = Float64(sin(b) * r); else tmp = Float64(Float64(b * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.6e+27) || ~((b <= 8.8e+27))) tmp = sin(b) * r; else tmp = (b * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.6e+27], N[Not[LessEqual[b, 8.8e+27]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+27} \lor \neg \left(b \leq 8.8 \cdot 10^{+27}\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\end{array}
\end{array}
if b < -1.60000000000000008e27 or 8.7999999999999995e27 < b Initial program 59.2%
associate-/l*59.3%
remove-double-neg59.3%
sin-neg59.3%
neg-mul-159.3%
associate-/r*59.3%
associate-/l*59.2%
*-commutative59.2%
associate-*l/59.3%
associate-/l*59.3%
sin-neg59.3%
distribute-lft-neg-in59.3%
distribute-rgt-neg-in59.3%
associate-/l*59.3%
metadata-eval59.3%
/-rgt-identity59.3%
+-commutative59.3%
Simplified59.3%
associate-*l/59.2%
associate-/l*59.3%
Applied egg-rr59.3%
Taylor expanded in b around 0 11.9%
Taylor expanded in a around 0 11.7%
if -1.60000000000000008e27 < b < 8.7999999999999995e27Initial program 97.7%
associate-/l*97.5%
remove-double-neg97.5%
sin-neg97.5%
neg-mul-197.5%
associate-/r*97.5%
associate-/l*97.7%
*-commutative97.7%
associate-*l/97.6%
associate-/l*97.6%
sin-neg97.6%
distribute-lft-neg-in97.6%
distribute-rgt-neg-in97.6%
associate-/l*97.6%
metadata-eval97.6%
/-rgt-identity97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in b around 0 92.6%
Final simplification52.5%
(FPCore (r a b) :precision binary64 (* (sin b) r))
double code(double r, double a, double b) {
return sin(b) * r;
}
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
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * r;
}
def code(r, a, b): return math.sin(b) * r
function code(r, a, b) return Float64(sin(b) * r) end
function tmp = code(r, a, b) tmp = sin(b) * r; end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot r
\end{array}
Initial program 78.6%
associate-/l*78.6%
remove-double-neg78.6%
sin-neg78.6%
neg-mul-178.6%
associate-/r*78.6%
associate-/l*78.6%
*-commutative78.6%
associate-*l/78.6%
associate-/l*78.6%
sin-neg78.6%
distribute-lft-neg-in78.6%
distribute-rgt-neg-in78.6%
associate-/l*78.6%
metadata-eval78.6%
/-rgt-identity78.6%
+-commutative78.6%
Simplified78.6%
associate-*l/78.6%
associate-/l*78.6%
Applied egg-rr78.6%
Taylor expanded in b around 0 52.5%
Taylor expanded in a around 0 39.2%
Final simplification39.2%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return b * r;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = b * r
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 78.6%
associate-/l*78.6%
remove-double-neg78.6%
sin-neg78.6%
neg-mul-178.6%
associate-/r*78.6%
associate-/l*78.6%
*-commutative78.6%
associate-*l/78.6%
associate-/l*78.6%
sin-neg78.6%
distribute-lft-neg-in78.6%
distribute-rgt-neg-in78.6%
associate-/l*78.6%
metadata-eval78.6%
/-rgt-identity78.6%
+-commutative78.6%
Simplified78.6%
Taylor expanded in b around 0 48.5%
associate-/l*48.4%
Simplified48.4%
Taylor expanded in a around 0 35.3%
Final simplification35.3%
herbie shell --seed 2023339
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))