
(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 18 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 (sin a) (- (sin b)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(a), -sin(b), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)}
\end{array}
Initial program 79.6%
+-commutative79.6%
Simplified79.6%
cos-sum99.5%
sub-neg99.5%
Applied egg-rr99.5%
+-commutative99.5%
distribute-lft-neg-in99.5%
*-commutative99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (/ (fma (sin a) (- (sin b)) (* (cos a) (cos b))) (sin b))))
double code(double r, double a, double b) {
return r / (fma(sin(a), -sin(b), (cos(a) * cos(b))) / sin(b));
}
function code(r, a, b) return Float64(r / Float64(fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b))) / sin(b))) end
code[r_, a_, b_] := N[(r / N[(N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)}{\sin b}}
\end{array}
Initial program 79.6%
associate-/l*79.5%
+-commutative79.5%
Simplified79.5%
cos-sum99.5%
sub-neg99.5%
Applied egg-rr99.5%
+-commutative99.5%
distribute-lft-neg-in99.5%
*-commutative99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(a) * cos(b)) - (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(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 79.6%
associate-/l*79.5%
remove-double-neg79.5%
sin-neg79.5%
neg-mul-179.5%
associate-/r*79.5%
associate-/l*79.6%
*-commutative79.6%
associate-*l/79.5%
associate-/l*79.5%
sin-neg79.5%
distribute-lft-neg-in79.5%
distribute-rgt-neg-in79.5%
associate-/l*79.5%
metadata-eval79.5%
/-rgt-identity79.5%
+-commutative79.5%
Simplified79.5%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ r (/ (- (* (cos a) (cos b)) (* (sin b) (sin a))) (sin b))))
double code(double r, double a, double b) {
return r / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / 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 / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / sin(b))
end function
public static double code(double r, double a, double b) {
return r / (((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))) / Math.sin(b));
}
def code(r, a, b): return r / (((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))) / math.sin(b))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))) / sin(b))) end
function tmp = code(r, a, b) tmp = r / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / sin(b)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a \cdot \cos b - \sin b \cdot \sin a}{\sin b}}
\end{array}
Initial program 79.6%
associate-/l*79.5%
+-commutative79.5%
Simplified79.5%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos a) (cos b)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(a) * cos(b)) - (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(a) * cos(b)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(a) * cos(b)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 79.6%
+-commutative79.6%
Simplified79.6%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (cos (+ b a)) (* (* (sin b) (sin a)) 2.0))))
double code(double r, double a, double b) {
return (r * sin(b)) / (cos((b + a)) - ((sin(b) * sin(a)) * 2.0));
}
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)) - ((sin(b) * sin(a)) * 2.0d0))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / (Math.cos((b + a)) - ((Math.sin(b) * Math.sin(a)) * 2.0));
}
def code(r, a, b): return (r * math.sin(b)) / (math.cos((b + a)) - ((math.sin(b) * math.sin(a)) * 2.0))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(cos(Float64(b + a)) - Float64(Float64(sin(b) * sin(a)) * 2.0))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / (cos((b + a)) - ((sin(b) * sin(a)) * 2.0)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] - N[(N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right) - \left(\sin b \cdot \sin a\right) \cdot 2}
\end{array}
Initial program 79.6%
+-commutative79.6%
Simplified79.6%
cos-sum99.5%
sub-neg99.5%
Applied egg-rr99.5%
+-commutative99.5%
distribute-lft-neg-in99.5%
*-commutative99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
fma-udef99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
*-commutative99.5%
+-commutative99.5%
sub-neg99.5%
prod-diff99.5%
*-commutative99.5%
fma-neg99.5%
cos-sum79.6%
*-commutative79.6%
fma-udef79.6%
Applied egg-rr77.8%
count-277.8%
Simplified77.8%
add-sqr-sqrt38.1%
sqrt-unprod79.1%
sqr-neg79.1%
sqrt-unprod41.0%
add-sqr-sqrt80.0%
distribute-lft-neg-in80.0%
neg-sub080.0%
Applied egg-rr80.0%
neg-sub080.0%
distribute-rgt-neg-in80.0%
Simplified80.0%
Final simplification80.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -9e-6) (not (<= b 16500.0))) (* (sin b) (/ r (cos b))) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -9e-6) || !(b <= 16500.0)) {
tmp = sin(b) * (r / cos(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 <= (-9d-6)) .or. (.not. (b <= 16500.0d0))) then
tmp = sin(b) * (r / cos(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 <= -9e-6) || !(b <= 16500.0)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -9e-6) or not (b <= 16500.0): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -9e-6) || !(b <= 16500.0)) tmp = Float64(sin(b) * Float64(r / cos(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 <= -9e-6) || ~((b <= 16500.0))) tmp = sin(b) * (r / cos(b)); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -9e-6], N[Not[LessEqual[b, 16500.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-6} \lor \neg \left(b \leq 16500\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -9.00000000000000023e-6 or 16500 < b Initial program 59.8%
associate-/l*59.8%
remove-double-neg59.8%
sin-neg59.8%
neg-mul-159.8%
associate-/r*59.8%
associate-/l*59.8%
*-commutative59.8%
associate-*l/59.8%
associate-/l*59.8%
sin-neg59.8%
distribute-lft-neg-in59.8%
distribute-rgt-neg-in59.8%
associate-/l*59.8%
metadata-eval59.8%
/-rgt-identity59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in a around 0 59.0%
associate-/l*59.0%
associate-/r/59.0%
Simplified59.0%
if -9.00000000000000023e-6 < b < 16500Initial program 98.7%
associate-/l*98.6%
remove-double-neg98.6%
sin-neg98.6%
neg-mul-198.6%
associate-/r*98.6%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.6%
associate-/l*98.6%
sin-neg98.6%
distribute-lft-neg-in98.6%
distribute-rgt-neg-in98.6%
associate-/l*98.6%
metadata-eval98.6%
/-rgt-identity98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.8%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (<= b -6.4e-6) (/ r (/ (cos b) (sin b))) (if (<= b 16500.0) (/ (* r b) (cos a)) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -6.4e-6) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 16500.0) {
tmp = (r * b) / cos(a);
} else {
tmp = sin(b) * (r / 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 <= (-6.4d-6)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 16500.0d0) then
tmp = (r * b) / cos(a)
else
tmp = sin(b) * (r / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -6.4e-6) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 16500.0) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -6.4e-6: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 16500.0: tmp = (r * b) / math.cos(a) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -6.4e-6) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 16500.0) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -6.4e-6) tmp = r / (cos(b) / sin(b)); elseif (b <= 16500.0) tmp = (r * b) / cos(a); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -6.4e-6], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 16500.0], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 16500:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -6.3999999999999997e-6Initial program 60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in a around 0 57.9%
if -6.3999999999999997e-6 < b < 16500Initial program 98.7%
associate-/l*98.6%
remove-double-neg98.6%
sin-neg98.6%
neg-mul-198.6%
associate-/r*98.6%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.6%
associate-/l*98.6%
sin-neg98.6%
distribute-lft-neg-in98.6%
distribute-rgt-neg-in98.6%
associate-/l*98.6%
metadata-eval98.6%
/-rgt-identity98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.8%
if 16500 < b Initial program 59.6%
associate-/l*59.5%
remove-double-neg59.5%
sin-neg59.5%
neg-mul-159.5%
associate-/r*59.5%
associate-/l*59.6%
*-commutative59.6%
associate-*l/59.5%
associate-/l*59.5%
sin-neg59.5%
distribute-lft-neg-in59.5%
distribute-rgt-neg-in59.5%
associate-/l*59.5%
metadata-eval59.5%
/-rgt-identity59.5%
+-commutative59.5%
Simplified59.5%
Taylor expanded in a around 0 60.2%
associate-/l*60.0%
associate-/r/60.1%
Simplified60.1%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (<= b -3e-6) (/ r (/ (cos b) (sin b))) (if (<= b 16500.0) (/ (* r b) (cos a)) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -3e-6) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 16500.0) {
tmp = (r * b) / 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 <= (-3d-6)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 16500.0d0) then
tmp = (r * b) / 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 <= -3e-6) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 16500.0) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = (r * Math.sin(b)) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -3e-6: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 16500.0: tmp = (r * b) / math.cos(a) else: tmp = (r * math.sin(b)) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -3e-6) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 16500.0) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(Float64(r * sin(b)) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -3e-6) tmp = r / (cos(b) / sin(b)); elseif (b <= 16500.0) tmp = (r * b) / cos(a); else tmp = (r * sin(b)) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -3e-6], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 16500.0], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-6}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 16500:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -3.0000000000000001e-6Initial program 60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in a around 0 57.9%
if -3.0000000000000001e-6 < b < 16500Initial program 98.7%
associate-/l*98.6%
remove-double-neg98.6%
sin-neg98.6%
neg-mul-198.6%
associate-/r*98.6%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.6%
associate-/l*98.6%
sin-neg98.6%
distribute-lft-neg-in98.6%
distribute-rgt-neg-in98.6%
associate-/l*98.6%
metadata-eval98.6%
/-rgt-identity98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.8%
if 16500 < b Initial program 59.6%
+-commutative59.6%
Simplified59.6%
Taylor expanded in a around 0 60.2%
Final simplification79.2%
(FPCore (r a b) :precision binary64 (if (<= b -9.2e-5) (* r (/ 1.0 (/ (cos b) (sin b)))) (if (<= b 16500.0) (/ (* r b) (cos a)) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -9.2e-5) {
tmp = r * (1.0 / (cos(b) / sin(b)));
} else if (b <= 16500.0) {
tmp = (r * b) / 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 <= (-9.2d-5)) then
tmp = r * (1.0d0 / (cos(b) / sin(b)))
else if (b <= 16500.0d0) then
tmp = (r * b) / 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 <= -9.2e-5) {
tmp = r * (1.0 / (Math.cos(b) / Math.sin(b)));
} else if (b <= 16500.0) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = (r * Math.sin(b)) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -9.2e-5: tmp = r * (1.0 / (math.cos(b) / math.sin(b))) elif b <= 16500.0: tmp = (r * b) / math.cos(a) else: tmp = (r * math.sin(b)) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -9.2e-5) tmp = Float64(r * Float64(1.0 / Float64(cos(b) / sin(b)))); elseif (b <= 16500.0) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(Float64(r * sin(b)) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -9.2e-5) tmp = r * (1.0 / (cos(b) / sin(b))); elseif (b <= 16500.0) tmp = (r * b) / cos(a); else tmp = (r * sin(b)) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -9.2e-5], N[(r * N[(1.0 / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 16500.0], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.2 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{1}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 16500:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -9.20000000000000001e-5Initial program 60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in a around 0 57.8%
associate-/l*57.9%
div-inv57.9%
Applied egg-rr57.9%
if -9.20000000000000001e-5 < b < 16500Initial program 98.7%
associate-/l*98.6%
remove-double-neg98.6%
sin-neg98.6%
neg-mul-198.6%
associate-/r*98.6%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.6%
associate-/l*98.6%
sin-neg98.6%
distribute-lft-neg-in98.6%
distribute-rgt-neg-in98.6%
associate-/l*98.6%
metadata-eval98.6%
/-rgt-identity98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.8%
if 16500 < b Initial program 59.6%
+-commutative59.6%
Simplified59.6%
Taylor expanded in a around 0 60.2%
Final simplification79.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 79.6%
associate-/l*79.5%
remove-double-neg79.5%
sin-neg79.5%
neg-mul-179.5%
associate-/r*79.5%
associate-/l*79.6%
*-commutative79.6%
associate-*l/79.5%
associate-/l*79.5%
sin-neg79.5%
distribute-lft-neg-in79.5%
distribute-rgt-neg-in79.5%
associate-/l*79.5%
metadata-eval79.5%
/-rgt-identity79.5%
+-commutative79.5%
Simplified79.5%
Final simplification79.5%
(FPCore (r a b) :precision binary64 (/ r (/ (cos (+ b a)) (sin b))))
double code(double r, double a, double b) {
return r / (cos((b + a)) / 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 / (cos((b + a)) / sin(b))
end function
public static double code(double r, double a, double b) {
return r / (Math.cos((b + a)) / Math.sin(b));
}
def code(r, a, b): return r / (math.cos((b + a)) / math.sin(b))
function code(r, a, b) return Float64(r / Float64(cos(Float64(b + a)) / sin(b))) end
function tmp = code(r, a, b) tmp = r / (cos((b + a)) / sin(b)); end
code[r_, a_, b_] := N[(r / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos \left(b + a\right)}{\sin b}}
\end{array}
Initial program 79.6%
associate-/l*79.5%
+-commutative79.5%
Simplified79.5%
Final simplification79.5%
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 79.6%
Final simplification79.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.000205) (not (<= b 16500.0))) (/ r (- (/ 1.0 (tan b)) a)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000205) || !(b <= 16500.0)) {
tmp = r / ((1.0 / tan(b)) - a);
} 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.000205d0)) .or. (.not. (b <= 16500.0d0))) then
tmp = r / ((1.0d0 / tan(b)) - a)
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.000205) || !(b <= 16500.0)) {
tmp = r / ((1.0 / Math.tan(b)) - a);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.000205) or not (b <= 16500.0): tmp = r / ((1.0 / math.tan(b)) - a) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.000205) || !(b <= 16500.0)) tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); 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.000205) || ~((b <= 16500.0))) tmp = r / ((1.0 / tan(b)) - a); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.000205], N[Not[LessEqual[b, 16500.0]], $MachinePrecision]], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.000205 \lor \neg \left(b \leq 16500\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -2.05e-4 or 16500 < b Initial program 59.8%
associate-/l*59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in a around 0 55.4%
+-commutative55.4%
mul-1-neg55.4%
unsub-neg55.4%
Simplified55.4%
expm1-log1p-u49.0%
expm1-udef48.9%
clear-num48.8%
quot-tan48.9%
Applied egg-rr48.9%
expm1-def49.0%
expm1-log1p55.4%
Simplified55.4%
if -2.05e-4 < b < 16500Initial program 98.7%
associate-/l*98.6%
remove-double-neg98.6%
sin-neg98.6%
neg-mul-198.6%
associate-/r*98.6%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.6%
associate-/l*98.6%
sin-neg98.6%
distribute-lft-neg-in98.6%
distribute-rgt-neg-in98.6%
associate-/l*98.6%
metadata-eval98.6%
/-rgt-identity98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.8%
Final simplification77.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (- (/ 1.0 (tan b)) a)))
(if (<= b -3.7e-5)
(* r (/ 1.0 t_0))
(if (<= b 16500.0) (/ (* r b) (cos a)) (/ r t_0)))))
double code(double r, double a, double b) {
double t_0 = (1.0 / tan(b)) - a;
double tmp;
if (b <= -3.7e-5) {
tmp = r * (1.0 / t_0);
} else if (b <= 16500.0) {
tmp = (r * b) / cos(a);
} else {
tmp = r / 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 <= (-3.7d-5)) then
tmp = r * (1.0d0 / t_0)
else if (b <= 16500.0d0) then
tmp = (r * b) / cos(a)
else
tmp = r / 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 <= -3.7e-5) {
tmp = r * (1.0 / t_0);
} else if (b <= 16500.0) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = r / t_0;
}
return tmp;
}
def code(r, a, b): t_0 = (1.0 / math.tan(b)) - a tmp = 0 if b <= -3.7e-5: tmp = r * (1.0 / t_0) elif b <= 16500.0: tmp = (r * b) / math.cos(a) else: tmp = r / t_0 return tmp
function code(r, a, b) t_0 = Float64(Float64(1.0 / tan(b)) - a) tmp = 0.0 if (b <= -3.7e-5) tmp = Float64(r * Float64(1.0 / t_0)); elseif (b <= 16500.0) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(r / 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 <= -3.7e-5) tmp = r * (1.0 / t_0); elseif (b <= 16500.0) tmp = (r * b) / cos(a); else tmp = r / 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, -3.7e-5], N[(r * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 16500.0], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -3.7 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{1}{t_0}\\
\mathbf{elif}\;b \leq 16500:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{t_0}\\
\end{array}
\end{array}
if b < -3.69999999999999981e-5Initial program 60.0%
associate-/l*60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in a around 0 55.5%
+-commutative55.5%
mul-1-neg55.5%
unsub-neg55.5%
Simplified55.5%
div-inv55.5%
clear-num55.4%
quot-tan55.4%
Applied egg-rr55.4%
if -3.69999999999999981e-5 < b < 16500Initial program 98.7%
associate-/l*98.6%
remove-double-neg98.6%
sin-neg98.6%
neg-mul-198.6%
associate-/r*98.6%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.6%
associate-/l*98.6%
sin-neg98.6%
distribute-lft-neg-in98.6%
distribute-rgt-neg-in98.6%
associate-/l*98.6%
metadata-eval98.6%
/-rgt-identity98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in b around 0 98.8%
if 16500 < b Initial program 59.6%
associate-/l*59.5%
+-commutative59.5%
Simplified59.5%
Taylor expanded in a around 0 55.3%
+-commutative55.3%
mul-1-neg55.3%
unsub-neg55.3%
Simplified55.3%
expm1-log1p-u53.3%
expm1-udef53.2%
clear-num53.3%
quot-tan53.3%
Applied egg-rr53.3%
expm1-def53.4%
expm1-log1p55.4%
Simplified55.4%
Final simplification77.5%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (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 * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 79.6%
associate-/l*79.5%
remove-double-neg79.5%
sin-neg79.5%
neg-mul-179.5%
associate-/r*79.5%
associate-/l*79.6%
*-commutative79.6%
associate-*l/79.5%
associate-/l*79.5%
sin-neg79.5%
distribute-lft-neg-in79.5%
distribute-rgt-neg-in79.5%
associate-/l*79.5%
metadata-eval79.5%
/-rgt-identity79.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in b around 0 52.2%
Final simplification52.2%
(FPCore (r a b) :precision binary64 (/ (* r b) (cos a)))
double code(double r, double a, double b) {
return (r * 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 * b) / cos(a)
end function
public static double code(double r, double a, double b) {
return (r * b) / Math.cos(a);
}
def code(r, a, b): return (r * b) / math.cos(a)
function code(r, a, b) return Float64(Float64(r * b) / cos(a)) end
function tmp = code(r, a, b) tmp = (r * b) / cos(a); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos a}
\end{array}
Initial program 79.6%
associate-/l*79.5%
remove-double-neg79.5%
sin-neg79.5%
neg-mul-179.5%
associate-/r*79.5%
associate-/l*79.6%
*-commutative79.6%
associate-*l/79.5%
associate-/l*79.5%
sin-neg79.5%
distribute-lft-neg-in79.5%
distribute-rgt-neg-in79.5%
associate-/l*79.5%
metadata-eval79.5%
/-rgt-identity79.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in b around 0 52.2%
Final simplification52.2%
(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 79.6%
associate-/l*79.5%
remove-double-neg79.5%
sin-neg79.5%
neg-mul-179.5%
associate-/r*79.5%
associate-/l*79.6%
*-commutative79.6%
associate-*l/79.5%
associate-/l*79.5%
sin-neg79.5%
distribute-lft-neg-in79.5%
distribute-rgt-neg-in79.5%
associate-/l*79.5%
metadata-eval79.5%
/-rgt-identity79.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in b around 0 52.2%
Taylor expanded in a around 0 36.4%
*-commutative36.4%
Simplified36.4%
Final simplification36.4%
herbie shell --seed 2023318
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))