
(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)
(fma (sin a) (- (sin b)) (fma (- (sin a)) (sin b) (* (sin b) (sin a))))))
r))
double code(double r, double a, double b) {
return (sin(b) / fma(cos(b), cos(a), fma(sin(a), -sin(b), fma(-sin(a), sin(b), (sin(b) * sin(a)))))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(cos(b), cos(a), fma(sin(a), Float64(-sin(b)), fma(Float64(-sin(a)), sin(b), Float64(sin(b) * 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[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[((-N[Sin[a], $MachinePrecision]) * N[Sin[b], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \mathsf{fma}\left(\sin a, -\sin b, \mathsf{fma}\left(-\sin a, \sin b, \sin b \cdot \sin a\right)\right)\right)} \cdot r
\end{array}
Initial program 79.8%
associate-/l*79.7%
remove-double-neg79.7%
sin-neg79.7%
neg-mul-179.7%
associate-/r*79.7%
associate-/l*79.8%
*-commutative79.8%
associate-*l/79.8%
associate-/l*79.8%
sin-neg79.8%
distribute-lft-neg-in79.8%
distribute-rgt-neg-in79.8%
associate-/l*79.8%
metadata-eval79.8%
/-rgt-identity79.8%
+-commutative79.8%
Simplified79.8%
cos-sum99.5%
Applied egg-rr99.5%
prod-diff99.5%
*-commutative99.5%
fma-def99.5%
associate-+l+99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
*-commutative99.5%
Applied egg-rr99.5%
fma-def99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.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 79.8%
associate-/l*79.7%
remove-double-neg79.7%
sin-neg79.7%
neg-mul-179.7%
associate-/r*79.7%
associate-/l*79.8%
*-commutative79.8%
associate-*l/79.8%
associate-/l*79.8%
sin-neg79.8%
distribute-lft-neg-in79.8%
distribute-rgt-neg-in79.8%
associate-/l*79.8%
metadata-eval79.8%
/-rgt-identity79.8%
+-commutative79.8%
Simplified79.8%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (fma (cos b) (cos a) 0.0))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), 0.0));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), 0.0))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, 0\right)}
\end{array}
Initial program 79.8%
associate-/l*79.7%
remove-double-neg79.7%
sin-neg79.7%
neg-mul-179.7%
associate-/r*79.7%
associate-/l*79.8%
*-commutative79.8%
associate-*l/79.8%
associate-/l*79.8%
sin-neg79.8%
distribute-lft-neg-in79.8%
distribute-rgt-neg-in79.8%
associate-/l*79.8%
metadata-eval79.8%
/-rgt-identity79.8%
+-commutative79.8%
Simplified79.8%
cos-sum99.5%
Applied egg-rr99.5%
fma-neg99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
Applied egg-rr99.5%
*-commutative99.5%
add-sqr-sqrt51.6%
sqrt-unprod92.4%
sqr-neg92.4%
sqrt-unprod40.8%
add-sqr-sqrt79.5%
sin-mult80.3%
cos-diff79.7%
add-sqr-sqrt40.9%
sqrt-unprod80.3%
sqr-neg80.3%
sqrt-unprod39.4%
add-sqr-sqrt80.7%
cancel-sign-sub-inv80.7%
cos-sum80.3%
Applied egg-rr80.3%
+-inverses80.3%
metadata-eval80.3%
Simplified80.3%
Final simplification80.3%
(FPCore (r a b) :precision binary64 (if (or (<= a -8e-5) (not (<= a 0.00075))) (* r (/ (sin b) (cos a))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -8e-5) || !(a <= 0.00075)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * (1.0 / ((1.0 / tan(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 ((a <= (-8d-5)) .or. (.not. (a <= 0.00075d0))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -8e-5) || !(a <= 0.00075)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -8e-5) or not (a <= 0.00075): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -8e-5) || !(a <= 0.00075)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -8e-5) || ~((a <= 0.00075))) tmp = r * (sin(b) / cos(a)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -8e-5], N[Not[LessEqual[a, 0.00075]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8 \cdot 10^{-5} \lor \neg \left(a \leq 0.00075\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -8.00000000000000065e-5 or 7.5000000000000002e-4 < a Initial program 63.3%
associate-/l*63.3%
remove-double-neg63.3%
sin-neg63.3%
neg-mul-163.3%
associate-/r*63.3%
associate-/l*63.3%
*-commutative63.3%
associate-*l/63.3%
associate-/l*63.3%
sin-neg63.3%
distribute-lft-neg-in63.3%
distribute-rgt-neg-in63.3%
associate-/l*63.3%
metadata-eval63.3%
/-rgt-identity63.3%
+-commutative63.3%
Simplified63.3%
Taylor expanded in b around 0 62.6%
if -8.00000000000000065e-5 < a < 7.5000000000000002e-4Initial program 98.9%
associate-/l*98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in a around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.3%
clear-num99.3%
quot-tan99.4%
Applied egg-rr99.4%
Final simplification79.7%
(FPCore (r a b)
:precision binary64
(if (<= a -0.000185)
(/ r (/ (cos a) (sin b)))
(if (<= a 0.0006)
(* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
(* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.000185) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 0.0006) {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
} else {
tmp = r * (sin(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 (a <= (-0.000185d0)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 0.0006d0) then
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.000185) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 0.0006) {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.000185: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 0.0006: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.000185) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 0.0006) tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.000185) tmp = r / (cos(a) / sin(b)); elseif (a <= 0.0006) tmp = r * (1.0 / ((1.0 / tan(b)) - a)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.000185], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.0006], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000185:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 0.0006:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -1.85e-4Initial program 68.3%
associate-/l*68.3%
+-commutative68.3%
Simplified68.3%
Taylor expanded in b around 0 67.4%
if -1.85e-4 < a < 5.99999999999999947e-4Initial program 98.9%
associate-/l*98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in a around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.3%
clear-num99.3%
quot-tan99.4%
Applied egg-rr99.4%
if 5.99999999999999947e-4 < a Initial program 59.2%
associate-/l*59.2%
remove-double-neg59.2%
sin-neg59.2%
neg-mul-159.2%
associate-/r*59.2%
associate-/l*59.2%
*-commutative59.2%
associate-*l/59.2%
associate-/l*59.2%
sin-neg59.2%
distribute-lft-neg-in59.2%
distribute-rgt-neg-in59.2%
associate-/l*59.2%
metadata-eval59.2%
/-rgt-identity59.2%
+-commutative59.2%
Simplified59.2%
Taylor expanded in b around 0 58.8%
Final simplification79.7%
(FPCore (r a b) :precision binary64 (if (<= b -7.6e+15) (/ r (/ (cos b) (sin b))) (if (<= b 2.3e-7) (* b (/ r (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -7.6e+15) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 2.3e-7) {
tmp = b * (r / cos(a));
} else {
tmp = r * (sin(b) / cos(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 <= (-7.6d+15)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 2.3d-7) then
tmp = b * (r / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -7.6e+15) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 2.3e-7) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -7.6e+15: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 2.3e-7: tmp = b * (r / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -7.6e+15) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 2.3e-7) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -7.6e+15) tmp = r / (cos(b) / sin(b)); elseif (b <= 2.3e-7) tmp = b * (r / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -7.6e+15], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-7], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{+15}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-7}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -7.6e15Initial program 49.0%
associate-/l*49.0%
+-commutative49.0%
Simplified49.0%
Taylor expanded in a around 0 48.5%
if -7.6e15 < b < 2.29999999999999995e-7Initial program 97.9%
associate-/l*97.8%
remove-double-neg97.8%
sin-neg97.8%
neg-mul-197.8%
associate-/r*97.8%
associate-/l*97.9%
*-commutative97.9%
associate-*l/97.9%
associate-/l*97.9%
sin-neg97.9%
distribute-lft-neg-in97.9%
distribute-rgt-neg-in97.9%
associate-/l*97.9%
metadata-eval97.9%
/-rgt-identity97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 97.9%
*-commutative97.9%
clear-num97.8%
un-div-inv97.7%
Applied egg-rr97.7%
associate-/r/97.9%
Simplified97.9%
if 2.29999999999999995e-7 < b Initial program 59.9%
associate-/l*60.0%
remove-double-neg60.0%
sin-neg60.0%
neg-mul-160.0%
associate-/r*60.0%
associate-/l*59.9%
*-commutative59.9%
associate-*l/60.0%
associate-/l*60.0%
sin-neg60.0%
distribute-lft-neg-in60.0%
distribute-rgt-neg-in60.0%
associate-/l*60.0%
metadata-eval60.0%
/-rgt-identity60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in a around 0 59.9%
Final simplification79.7%
(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 79.8%
associate-/l*79.7%
+-commutative79.7%
Simplified79.7%
associate-/r/79.9%
Applied egg-rr79.9%
Final simplification79.9%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (- (/ 1.0 (tan b)) a)))
(if (<= b -1.6e+20)
(/ r t_0)
(if (<= b 2.3e-7) (* b (/ r (cos a))) (* r (/ 1.0 t_0))))))
double code(double r, double a, double b) {
double t_0 = (1.0 / tan(b)) - a;
double tmp;
if (b <= -1.6e+20) {
tmp = r / t_0;
} else if (b <= 2.3e-7) {
tmp = b * (r / cos(a));
} else {
tmp = r * (1.0 / t_0);
}
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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / tan(b)) - a
if (b <= (-1.6d+20)) then
tmp = r / t_0
else if (b <= 2.3d-7) then
tmp = b * (r / cos(a))
else
tmp = r * (1.0d0 / t_0)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (1.0 / Math.tan(b)) - a;
double tmp;
if (b <= -1.6e+20) {
tmp = r / t_0;
} else if (b <= 2.3e-7) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r * (1.0 / t_0);
}
return tmp;
}
def code(r, a, b): t_0 = (1.0 / math.tan(b)) - a tmp = 0 if b <= -1.6e+20: tmp = r / t_0 elif b <= 2.3e-7: tmp = b * (r / math.cos(a)) else: tmp = r * (1.0 / t_0) return tmp
function code(r, a, b) t_0 = Float64(Float64(1.0 / tan(b)) - a) tmp = 0.0 if (b <= -1.6e+20) tmp = Float64(r / t_0); elseif (b <= 2.3e-7) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(r * Float64(1.0 / t_0)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = (1.0 / tan(b)) - a; tmp = 0.0; if (b <= -1.6e+20) tmp = r / t_0; elseif (b <= 2.3e-7) tmp = b * (r / cos(a)); else tmp = r * (1.0 / t_0); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]}, If[LessEqual[b, -1.6e+20], N[(r / t$95$0), $MachinePrecision], If[LessEqual[b, 2.3e-7], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20}:\\
\;\;\;\;\frac{r}{t_0}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-7}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{t_0}\\
\end{array}
\end{array}
if b < -1.6e20Initial program 50.7%
associate-/l*50.7%
+-commutative50.7%
Simplified50.7%
Taylor expanded in a around 0 48.8%
+-commutative48.8%
mul-1-neg48.8%
unsub-neg48.8%
Simplified48.8%
expm1-log1p-u28.6%
expm1-udef15.1%
clear-num15.1%
quot-tan15.1%
Applied egg-rr15.1%
expm1-def28.6%
expm1-log1p48.8%
Simplified48.8%
if -1.6e20 < b < 2.29999999999999995e-7Initial program 96.7%
associate-/l*96.6%
remove-double-neg96.6%
sin-neg96.6%
neg-mul-196.6%
associate-/r*96.6%
associate-/l*96.7%
*-commutative96.7%
associate-*l/96.8%
associate-/l*96.8%
sin-neg96.8%
distribute-lft-neg-in96.8%
distribute-rgt-neg-in96.8%
associate-/l*96.8%
metadata-eval96.8%
/-rgt-identity96.8%
+-commutative96.8%
Simplified96.8%
Taylor expanded in b around 0 96.7%
*-commutative96.7%
clear-num96.6%
un-div-inv96.6%
Applied egg-rr96.6%
associate-/r/96.8%
Simplified96.8%
if 2.29999999999999995e-7 < b Initial program 59.9%
associate-/l*60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in a around 0 55.8%
+-commutative55.8%
mul-1-neg55.8%
unsub-neg55.8%
Simplified55.8%
div-inv55.7%
clear-num55.8%
quot-tan55.9%
Applied egg-rr55.9%
Final simplification78.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (- (/ 1.0 (tan b)) a)))
(if (<= b -1.6e+20)
(/ 1.0 (/ t_0 r))
(if (<= b 2.3e-7) (* b (/ r (cos a))) (* r (/ 1.0 t_0))))))
double code(double r, double a, double b) {
double t_0 = (1.0 / tan(b)) - a;
double tmp;
if (b <= -1.6e+20) {
tmp = 1.0 / (t_0 / r);
} else if (b <= 2.3e-7) {
tmp = b * (r / cos(a));
} else {
tmp = r * (1.0 / t_0);
}
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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / tan(b)) - a
if (b <= (-1.6d+20)) then
tmp = 1.0d0 / (t_0 / r)
else if (b <= 2.3d-7) then
tmp = b * (r / cos(a))
else
tmp = r * (1.0d0 / t_0)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (1.0 / Math.tan(b)) - a;
double tmp;
if (b <= -1.6e+20) {
tmp = 1.0 / (t_0 / r);
} else if (b <= 2.3e-7) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r * (1.0 / t_0);
}
return tmp;
}
def code(r, a, b): t_0 = (1.0 / math.tan(b)) - a tmp = 0 if b <= -1.6e+20: tmp = 1.0 / (t_0 / r) elif b <= 2.3e-7: tmp = b * (r / math.cos(a)) else: tmp = r * (1.0 / t_0) return tmp
function code(r, a, b) t_0 = Float64(Float64(1.0 / tan(b)) - a) tmp = 0.0 if (b <= -1.6e+20) tmp = Float64(1.0 / Float64(t_0 / r)); elseif (b <= 2.3e-7) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(r * Float64(1.0 / t_0)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = (1.0 / tan(b)) - a; tmp = 0.0; if (b <= -1.6e+20) tmp = 1.0 / (t_0 / r); elseif (b <= 2.3e-7) tmp = b * (r / cos(a)); else tmp = r * (1.0 / t_0); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]}, If[LessEqual[b, -1.6e+20], N[(1.0 / N[(t$95$0 / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-7], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20}:\\
\;\;\;\;\frac{1}{\frac{t_0}{r}}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-7}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{t_0}\\
\end{array}
\end{array}
if b < -1.6e20Initial program 50.7%
associate-/l*50.7%
+-commutative50.7%
Simplified50.7%
Taylor expanded in a around 0 48.8%
+-commutative48.8%
mul-1-neg48.8%
unsub-neg48.8%
Simplified48.8%
clear-num48.8%
inv-pow48.8%
clear-num48.7%
quot-tan48.9%
Applied egg-rr48.9%
unpow-148.9%
Simplified48.9%
if -1.6e20 < b < 2.29999999999999995e-7Initial program 96.7%
associate-/l*96.6%
remove-double-neg96.6%
sin-neg96.6%
neg-mul-196.6%
associate-/r*96.6%
associate-/l*96.7%
*-commutative96.7%
associate-*l/96.8%
associate-/l*96.8%
sin-neg96.8%
distribute-lft-neg-in96.8%
distribute-rgt-neg-in96.8%
associate-/l*96.8%
metadata-eval96.8%
/-rgt-identity96.8%
+-commutative96.8%
Simplified96.8%
Taylor expanded in b around 0 96.7%
*-commutative96.7%
clear-num96.6%
un-div-inv96.6%
Applied egg-rr96.6%
associate-/r/96.8%
Simplified96.8%
if 2.29999999999999995e-7 < b Initial program 59.9%
associate-/l*60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in a around 0 55.8%
+-commutative55.8%
mul-1-neg55.8%
unsub-neg55.8%
Simplified55.8%
div-inv55.7%
clear-num55.8%
quot-tan55.9%
Applied egg-rr55.9%
Final simplification78.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.6e+20) (not (<= b 2.3e-7))) (/ r (- (/ 1.0 (tan b)) a)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.6e+20) || !(b <= 2.3e-7)) {
tmp = r / ((1.0 / tan(b)) - a);
} 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+20)) .or. (.not. (b <= 2.3d-7))) then
tmp = r / ((1.0d0 / tan(b)) - a)
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+20) || !(b <= 2.3e-7)) {
tmp = r / ((1.0 / Math.tan(b)) - a);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.6e+20) or not (b <= 2.3e-7): tmp = r / ((1.0 / math.tan(b)) - a) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.6e+20) || !(b <= 2.3e-7)) tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.6e+20) || ~((b <= 2.3e-7))) tmp = r / ((1.0 / tan(b)) - a); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.6e+20], N[Not[LessEqual[b, 2.3e-7]], $MachinePrecision]], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20} \lor \neg \left(b \leq 2.3 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.6e20 or 2.29999999999999995e-7 < b Initial program 55.8%
associate-/l*55.9%
+-commutative55.9%
Simplified55.9%
Taylor expanded in a around 0 52.7%
+-commutative52.7%
mul-1-neg52.7%
unsub-neg52.7%
Simplified52.7%
expm1-log1p-u31.0%
expm1-udef12.9%
clear-num12.9%
quot-tan12.9%
Applied egg-rr12.9%
expm1-def31.1%
expm1-log1p52.7%
Simplified52.7%
if -1.6e20 < b < 2.29999999999999995e-7Initial program 96.7%
associate-/l*96.6%
remove-double-neg96.6%
sin-neg96.6%
neg-mul-196.6%
associate-/r*96.6%
associate-/l*96.7%
*-commutative96.7%
associate-*l/96.8%
associate-/l*96.8%
sin-neg96.8%
distribute-lft-neg-in96.8%
distribute-rgt-neg-in96.8%
associate-/l*96.8%
metadata-eval96.8%
/-rgt-identity96.8%
+-commutative96.8%
Simplified96.8%
Taylor expanded in b around 0 96.7%
*-commutative96.7%
clear-num96.6%
un-div-inv96.6%
Applied egg-rr96.6%
associate-/r/96.8%
Simplified96.8%
Final simplification78.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.6e+20) (not (<= b 9000.0))) (* (sin b) r) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.6e+20) || !(b <= 9000.0)) {
tmp = sin(b) * r;
} 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 <= (-1.6d+20)) .or. (.not. (b <= 9000.0d0))) then
tmp = sin(b) * r
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 <= -1.6e+20) || !(b <= 9000.0)) {
tmp = Math.sin(b) * r;
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.6e+20) or not (b <= 9000.0): tmp = math.sin(b) * r else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.6e+20) || !(b <= 9000.0)) tmp = Float64(sin(b) * r); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.6e+20) || ~((b <= 9000.0))) tmp = sin(b) * r; else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.6e+20], N[Not[LessEqual[b, 9000.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20} \lor \neg \left(b \leq 9000\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.6e20 or 9e3 < b Initial program 54.6%
associate-/l*54.6%
remove-double-neg54.6%
sin-neg54.6%
neg-mul-154.6%
associate-/r*54.6%
associate-/l*54.6%
*-commutative54.6%
associate-*l/54.5%
associate-/l*54.5%
sin-neg54.5%
distribute-lft-neg-in54.5%
distribute-rgt-neg-in54.5%
associate-/l*54.5%
metadata-eval54.5%
/-rgt-identity54.5%
+-commutative54.5%
Simplified54.5%
Taylor expanded in b around 0 7.0%
mul-1-neg7.0%
unsub-neg7.0%
Simplified7.0%
Taylor expanded in a around 0 12.9%
*-commutative12.9%
Simplified12.9%
if -1.6e20 < b < 9e3Initial program 96.8%
associate-/l*96.7%
remove-double-neg96.7%
sin-neg96.7%
neg-mul-196.7%
associate-/r*96.7%
associate-/l*96.8%
*-commutative96.8%
associate-*l/96.8%
associate-/l*96.8%
sin-neg96.8%
distribute-lft-neg-in96.8%
distribute-rgt-neg-in96.8%
associate-/l*96.8%
metadata-eval96.8%
/-rgt-identity96.8%
+-commutative96.8%
Simplified96.8%
Taylor expanded in b around 0 96.4%
Final simplification62.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.6e+20) (not (<= b 360000000.0))) (* (sin b) r) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.6e+20) || !(b <= 360000000.0)) {
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+20)) .or. (.not. (b <= 360000000.0d0))) 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+20) || !(b <= 360000000.0)) {
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+20) or not (b <= 360000000.0): 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+20) || !(b <= 360000000.0)) tmp = Float64(sin(b) * r); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.6e+20) || ~((b <= 360000000.0))) 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+20], N[Not[LessEqual[b, 360000000.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+20} \lor \neg \left(b \leq 360000000\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.6e20 or 3.6e8 < b Initial program 54.6%
associate-/l*54.6%
remove-double-neg54.6%
sin-neg54.6%
neg-mul-154.6%
associate-/r*54.6%
associate-/l*54.6%
*-commutative54.6%
associate-*l/54.5%
associate-/l*54.5%
sin-neg54.5%
distribute-lft-neg-in54.5%
distribute-rgt-neg-in54.5%
associate-/l*54.5%
metadata-eval54.5%
/-rgt-identity54.5%
+-commutative54.5%
Simplified54.5%
Taylor expanded in b around 0 7.0%
mul-1-neg7.0%
unsub-neg7.0%
Simplified7.0%
Taylor expanded in a around 0 12.9%
*-commutative12.9%
Simplified12.9%
if -1.6e20 < b < 3.6e8Initial program 96.8%
associate-/l*96.7%
remove-double-neg96.7%
sin-neg96.7%
neg-mul-196.7%
associate-/r*96.7%
associate-/l*96.8%
*-commutative96.8%
associate-*l/96.8%
associate-/l*96.8%
sin-neg96.8%
distribute-lft-neg-in96.8%
distribute-rgt-neg-in96.8%
associate-/l*96.8%
metadata-eval96.8%
/-rgt-identity96.8%
+-commutative96.8%
Simplified96.8%
Taylor expanded in b around 0 96.4%
*-commutative96.4%
clear-num96.3%
un-div-inv96.2%
Applied egg-rr96.2%
associate-/r/96.4%
Simplified96.4%
Final simplification62.8%
(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 79.8%
associate-/l*79.7%
remove-double-neg79.7%
sin-neg79.7%
neg-mul-179.7%
associate-/r*79.7%
associate-/l*79.8%
*-commutative79.8%
associate-*l/79.8%
associate-/l*79.8%
sin-neg79.8%
distribute-lft-neg-in79.8%
distribute-rgt-neg-in79.8%
associate-/l*79.8%
metadata-eval79.8%
/-rgt-identity79.8%
+-commutative79.8%
Simplified79.8%
Taylor expanded in b around 0 60.7%
mul-1-neg60.7%
unsub-neg60.7%
Simplified60.7%
Taylor expanded in a around 0 42.9%
*-commutative42.9%
Simplified42.9%
Final simplification42.9%
(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 79.8%
associate-/l*79.7%
remove-double-neg79.7%
sin-neg79.7%
neg-mul-179.7%
associate-/r*79.7%
associate-/l*79.8%
*-commutative79.8%
associate-*l/79.8%
associate-/l*79.8%
sin-neg79.8%
distribute-lft-neg-in79.8%
distribute-rgt-neg-in79.8%
associate-/l*79.8%
metadata-eval79.8%
/-rgt-identity79.8%
+-commutative79.8%
Simplified79.8%
Taylor expanded in b around 0 59.2%
Taylor expanded in a around 0 39.3%
Final simplification39.3%
herbie shell --seed 2024010
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))