
(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 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) (* (sin b) (- (sin a))))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (sin(b) * -sin(a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (/ r (/ (fma (cos a) (cos b) (* (sin b) (- (sin a)))) (sin b))))
double code(double r, double a, double b) {
return r / (fma(cos(a), cos(b), (sin(b) * -sin(a))) / sin(b));
}
function code(r, a, b) return Float64(r / Float64(fma(cos(a), cos(b), Float64(sin(b) * Float64(-sin(a)))) / sin(b))) end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\mathsf{fma}\left(\cos a, \cos b, \sin b \cdot \left(-\sin a\right)\right)}{\sin b}}
\end{array}
Initial program 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in r around 0 99.5%
*-commutative99.5%
mul-1-neg99.5%
distribute-lft-neg-out99.5%
*-commutative99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in b around inf 99.5%
associate-/l*99.5%
neg-mul-199.5%
+-commutative99.5%
fma-udef99.5%
distribute-rgt-neg-in99.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 76.0%
*-commutative76.0%
associate-/l*75.9%
+-commutative75.9%
Simplified75.9%
associate-/r/76.0%
Applied egg-rr76.0%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (* (cos b) (cos a))))
double code(double r, double a, double b) {
return (r * sin(b)) / (cos(b) * cos(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / (cos(b) * cos(a))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / (Math.cos(b) * Math.cos(a));
}
def code(r, a, b): return (r * math.sin(b)) / (math.cos(b) * math.cos(a))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(cos(b) * cos(a))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / (cos(b) * cos(a)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a}
\end{array}
Initial program 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
Applied egg-rr77.9%
Final simplification77.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.000105) (not (<= b 0.00175))) (* (sin b) (/ r (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000105) || !(b <= 0.00175)) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = (r * b) / cos((b + a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-0.000105d0)) .or. (.not. (b <= 0.00175d0))) then
tmp = sin(b) * (r / cos(b))
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000105) || !(b <= 0.00175)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.000105) or not (b <= 0.00175): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.000105) || !(b <= 0.00175)) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.000105) || ~((b <= 0.00175))) tmp = sin(b) * (r / cos(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.000105], N[Not[LessEqual[b, 0.00175]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.000105 \lor \neg \left(b \leq 0.00175\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -1.05e-4 or 0.00175000000000000004 < b Initial program 55.9%
*-commutative55.9%
associate-/l*55.9%
+-commutative55.9%
Simplified55.9%
Taylor expanded in a around 0 56.3%
associate-/l*56.3%
associate-/r/56.2%
Simplified56.2%
if -1.05e-4 < b < 0.00175000000000000004Initial program 98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in b around 0 98.8%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (if (or (<= a -5.7e-6) (not (<= a 0.00136))) (* r (/ (sin b) (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -5.7e-6) || !(a <= 0.00136)) {
tmp = r * (sin(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 ((a <= (-5.7d-6)) .or. (.not. (a <= 0.00136d0))) then
tmp = r * (sin(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 ((a <= -5.7e-6) || !(a <= 0.00136)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -5.7e-6) or not (a <= 0.00136): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -5.7e-6) || !(a <= 0.00136)) tmp = Float64(r * Float64(sin(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 ((a <= -5.7e-6) || ~((a <= 0.00136))) tmp = r * (sin(b) / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -5.7e-6], N[Not[LessEqual[a, 0.00136]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.7 \cdot 10^{-6} \lor \neg \left(a \leq 0.00136\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -5.6999999999999996e-6 or 0.00136 < a Initial program 54.6%
*-commutative54.6%
associate-/l*54.6%
+-commutative54.6%
Simplified54.6%
associate-/r/54.6%
Applied egg-rr54.6%
Taylor expanded in b around 0 55.9%
if -5.6999999999999996e-6 < a < 0.00136Initial program 98.8%
*-commutative98.8%
associate-/l*98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in a around 0 98.8%
associate-/l*98.7%
associate-/r/98.7%
Simplified98.7%
Final simplification76.6%
(FPCore (r a b) :precision binary64 (if (or (<= a -6.2e-6) (not (<= a 0.000112))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -6.2e-6) || !(a <= 0.000112)) {
tmp = r * (sin(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 ((a <= (-6.2d-6)) .or. (.not. (a <= 0.000112d0))) then
tmp = r * (sin(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 ((a <= -6.2e-6) || !(a <= 0.000112)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -6.2e-6) or not (a <= 0.000112): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -6.2e-6) || !(a <= 0.000112)) tmp = Float64(r * Float64(sin(b) / 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 ((a <= -6.2e-6) || ~((a <= 0.000112))) tmp = r * (sin(b) / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -6.2e-6], N[Not[LessEqual[a, 0.000112]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 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}\;a \leq -6.2 \cdot 10^{-6} \lor \neg \left(a \leq 0.000112\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -6.1999999999999999e-6 or 1.11999999999999998e-4 < a Initial program 54.6%
*-commutative54.6%
associate-/l*54.6%
+-commutative54.6%
Simplified54.6%
associate-/r/54.6%
Applied egg-rr54.6%
Taylor expanded in b around 0 55.9%
if -6.1999999999999999e-6 < a < 1.11999999999999998e-4Initial program 98.8%
*-commutative98.8%
associate-/l*98.7%
+-commutative98.7%
Simplified98.7%
associate-/r/98.9%
Applied egg-rr98.9%
Taylor expanded in a around 0 98.9%
Final simplification76.7%
(FPCore (r a b) :precision binary64 (if (or (<= a -5.7e-6) (not (<= a 0.00012))) (/ (* r (sin b)) (cos a)) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -5.7e-6) || !(a <= 0.00012)) {
tmp = (r * sin(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 ((a <= (-5.7d-6)) .or. (.not. (a <= 0.00012d0))) then
tmp = (r * sin(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 ((a <= -5.7e-6) || !(a <= 0.00012)) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -5.7e-6) or not (a <= 0.00012): tmp = (r * math.sin(b)) / math.cos(a) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -5.7e-6) || !(a <= 0.00012)) tmp = Float64(Float64(r * sin(b)) / 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 ((a <= -5.7e-6) || ~((a <= 0.00012))) tmp = (r * sin(b)) / cos(a); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -5.7e-6], N[Not[LessEqual[a, 0.00012]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.7 \cdot 10^{-6} \lor \neg \left(a \leq 0.00012\right):\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -5.6999999999999996e-6 or 1.20000000000000003e-4 < a Initial program 54.6%
+-commutative54.6%
Simplified54.6%
Taylor expanded in b around 0 56.0%
if -5.6999999999999996e-6 < a < 1.20000000000000003e-4Initial program 98.8%
*-commutative98.8%
associate-/l*98.7%
+-commutative98.7%
Simplified98.7%
associate-/r/98.9%
Applied egg-rr98.9%
Taylor expanded in a around 0 98.9%
Final simplification76.8%
(FPCore (r a b) :precision binary64 (if (<= a -6.2e-6) (* r (/ (sin b) (cos a))) (if (<= a 9.2e-5) (* r (/ (sin b) (cos b))) (/ (sin b) (/ (cos a) r)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -6.2e-6) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 9.2e-5) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = sin(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 (a <= (-6.2d-6)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 9.2d-5) then
tmp = r * (sin(b) / cos(b))
else
tmp = sin(b) / (cos(a) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -6.2e-6) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 9.2e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = Math.sin(b) / (Math.cos(a) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -6.2e-6: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 9.2e-5: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = math.sin(b) / (math.cos(a) / r) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -6.2e-6) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 9.2e-5) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(sin(b) / Float64(cos(a) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -6.2e-6) tmp = r * (sin(b) / cos(a)); elseif (a <= 9.2e-5) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) / (cos(a) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -6.2e-6], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 9.2e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.2 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 9.2 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if a < -6.1999999999999999e-6Initial program 61.2%
*-commutative61.2%
associate-/l*61.1%
+-commutative61.1%
Simplified61.1%
associate-/r/61.1%
Applied egg-rr61.1%
Taylor expanded in b around 0 62.6%
if -6.1999999999999999e-6 < a < 9.20000000000000001e-5Initial program 98.8%
*-commutative98.8%
associate-/l*98.7%
+-commutative98.7%
Simplified98.7%
associate-/r/98.9%
Applied egg-rr98.9%
Taylor expanded in a around 0 98.9%
if 9.20000000000000001e-5 < a Initial program 47.5%
*-commutative47.5%
associate-/l*47.5%
+-commutative47.5%
Simplified47.5%
Taylor expanded in b around 0 48.6%
Final simplification76.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 76.0%
*-commutative76.0%
associate-/l*75.9%
+-commutative75.9%
Simplified75.9%
clear-num75.3%
associate-/r/75.9%
clear-num76.0%
Applied egg-rr76.0%
Final simplification76.0%
(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 76.0%
*-commutative76.0%
associate-/l*75.9%
+-commutative75.9%
Simplified75.9%
associate-/r/76.0%
Applied egg-rr76.0%
Final simplification76.0%
(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 76.0%
*-commutative76.0%
associate-/l*75.9%
+-commutative75.9%
Simplified75.9%
frac-2neg75.9%
div-inv75.9%
distribute-neg-frac75.9%
Applied egg-rr75.9%
associate-*r/75.9%
*-un-lft-identity75.9%
times-frac75.9%
add-sqr-sqrt40.8%
sqrt-unprod41.2%
sqr-neg41.2%
sqrt-unprod6.7%
add-sqr-sqrt16.9%
clear-num16.9%
add-sqr-sqrt5.2%
sqrt-unprod53.1%
sqr-neg53.1%
sqrt-unprod47.9%
add-sqr-sqrt76.0%
times-frac76.0%
Applied egg-rr76.1%
Final simplification76.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -200000000.0) (not (<= b 1.85e+33))) (* r (sin b)) (/ b (/ (cos (+ b a)) r))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -200000000.0) || !(b <= 1.85e+33)) {
tmp = r * sin(b);
} else {
tmp = b / (cos((b + 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 <= (-200000000.0d0)) .or. (.not. (b <= 1.85d+33))) then
tmp = r * sin(b)
else
tmp = b / (cos((b + a)) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -200000000.0) || !(b <= 1.85e+33)) {
tmp = r * Math.sin(b);
} else {
tmp = b / (Math.cos((b + a)) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -200000000.0) or not (b <= 1.85e+33): tmp = r * math.sin(b) else: tmp = b / (math.cos((b + a)) / r) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -200000000.0) || !(b <= 1.85e+33)) tmp = Float64(r * sin(b)); else tmp = Float64(b / Float64(cos(Float64(b + a)) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -200000000.0) || ~((b <= 1.85e+33))) tmp = r * sin(b); else tmp = b / (cos((b + a)) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -200000000.0], N[Not[LessEqual[b, 1.85e+33]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -200000000 \lor \neg \left(b \leq 1.85 \cdot 10^{+33}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{\cos \left(b + a\right)}{r}}\\
\end{array}
\end{array}
if b < -2e8 or 1.8499999999999999e33 < b Initial program 55.6%
*-commutative55.6%
associate-/l*55.5%
+-commutative55.5%
Simplified55.5%
Taylor expanded in b around 0 12.5%
Taylor expanded in a around 0 11.3%
if -2e8 < b < 1.8499999999999999e33Initial program 94.4%
*-commutative94.4%
associate-/l*94.2%
+-commutative94.2%
Simplified94.2%
add-exp-log48.0%
Applied egg-rr48.0%
add-sqr-sqrt33.6%
sqrt-unprod37.7%
pow237.7%
Applied egg-rr37.7%
unpow237.7%
rem-sqrt-square37.7%
+-commutative37.7%
Simplified37.7%
Taylor expanded in b around 0 70.4%
associate-/l*70.2%
+-commutative70.2%
rem-square-sqrt62.6%
fabs-sqr62.6%
rem-square-sqrt89.6%
Simplified89.6%
Final simplification52.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -200000000.0) (not (<= b 1.85e+33))) (* r (sin b)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -200000000.0) || !(b <= 1.85e+33)) {
tmp = r * sin(b);
} else {
tmp = (r * b) / cos((b + a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-200000000.0d0)) .or. (.not. (b <= 1.85d+33))) then
tmp = r * sin(b)
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -200000000.0) || !(b <= 1.85e+33)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -200000000.0) or not (b <= 1.85e+33): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -200000000.0) || !(b <= 1.85e+33)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -200000000.0) || ~((b <= 1.85e+33))) tmp = r * sin(b); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -200000000.0], N[Not[LessEqual[b, 1.85e+33]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -200000000 \lor \neg \left(b \leq 1.85 \cdot 10^{+33}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -2e8 or 1.8499999999999999e33 < b Initial program 55.6%
*-commutative55.6%
associate-/l*55.5%
+-commutative55.5%
Simplified55.5%
Taylor expanded in b around 0 12.5%
Taylor expanded in a around 0 11.3%
if -2e8 < b < 1.8499999999999999e33Initial program 94.4%
+-commutative94.4%
Simplified94.4%
Taylor expanded in b around 0 89.8%
Final simplification52.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -2400000000.0) (not (<= b 2.4e+33))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2400000000.0) || !(b <= 2.4e+33)) {
tmp = r * sin(b);
} else {
tmp = r * (b / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-2400000000.0d0)) .or. (.not. (b <= 2.4d+33))) then
tmp = r * sin(b)
else
tmp = r * (b / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2400000000.0) || !(b <= 2.4e+33)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2400000000.0) or not (b <= 2.4e+33): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2400000000.0) || !(b <= 2.4e+33)) tmp = Float64(r * sin(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2400000000.0) || ~((b <= 2.4e+33))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2400000000.0], N[Not[LessEqual[b, 2.4e+33]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2400000000 \lor \neg \left(b \leq 2.4 \cdot 10^{+33}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -2.4e9 or 2.4e33 < b Initial program 55.6%
*-commutative55.6%
associate-/l*55.5%
+-commutative55.5%
Simplified55.5%
Taylor expanded in b around 0 12.5%
Taylor expanded in a around 0 11.3%
if -2.4e9 < b < 2.4e33Initial program 94.4%
*-commutative94.4%
associate-/l*94.2%
+-commutative94.2%
Simplified94.2%
Taylor expanded in b around 0 89.6%
associate-/l*89.4%
associate-/r/89.5%
Simplified89.5%
Final simplification52.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -2400000000.0) (not (<= b 2.2e+33))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2400000000.0) || !(b <= 2.2e+33)) {
tmp = r * sin(b);
} else {
tmp = b * (r / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-2400000000.0d0)) .or. (.not. (b <= 2.2d+33))) then
tmp = r * sin(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2400000000.0) || !(b <= 2.2e+33)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2400000000.0) or not (b <= 2.2e+33): tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2400000000.0) || !(b <= 2.2e+33)) tmp = Float64(r * sin(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2400000000.0) || ~((b <= 2.2e+33))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2400000000.0], N[Not[LessEqual[b, 2.2e+33]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2400000000 \lor \neg \left(b \leq 2.2 \cdot 10^{+33}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -2.4e9 or 2.19999999999999994e33 < b Initial program 55.6%
*-commutative55.6%
associate-/l*55.5%
+-commutative55.5%
Simplified55.5%
Taylor expanded in b around 0 12.5%
Taylor expanded in a around 0 11.3%
if -2.4e9 < b < 2.19999999999999994e33Initial program 94.4%
*-commutative94.4%
associate-/l*94.2%
+-commutative94.2%
Simplified94.2%
Taylor expanded in b around 0 89.6%
associate-/l*89.4%
associate-/r/89.5%
Simplified89.5%
expm1-log1p-u80.2%
expm1-udef35.6%
*-commutative35.6%
clear-num35.6%
un-div-inv35.6%
Applied egg-rr35.6%
expm1-def80.1%
expm1-log1p89.5%
associate-/r/89.6%
Simplified89.6%
Final simplification52.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -2400000000.0) (not (<= b 1.85e+33))) (* r (sin b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2400000000.0) || !(b <= 1.85e+33)) {
tmp = r * sin(b);
} else {
tmp = (r * b) / cos(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-2400000000.0d0)) .or. (.not. (b <= 1.85d+33))) then
tmp = r * sin(b)
else
tmp = (r * b) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2400000000.0) || !(b <= 1.85e+33)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2400000000.0) or not (b <= 1.85e+33): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2400000000.0) || !(b <= 1.85e+33)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2400000000.0) || ~((b <= 1.85e+33))) tmp = r * sin(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2400000000.0], N[Not[LessEqual[b, 1.85e+33]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2400000000 \lor \neg \left(b \leq 1.85 \cdot 10^{+33}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -2.4e9 or 1.8499999999999999e33 < b Initial program 55.6%
*-commutative55.6%
associate-/l*55.5%
+-commutative55.5%
Simplified55.5%
Taylor expanded in b around 0 12.5%
Taylor expanded in a around 0 11.3%
if -2.4e9 < b < 1.8499999999999999e33Initial program 94.4%
*-commutative94.4%
associate-/l*94.2%
+-commutative94.2%
Simplified94.2%
Taylor expanded in b around 0 89.6%
Final simplification52.6%
(FPCore (r a b) :precision binary64 (* r (sin b)))
double code(double r, double a, double b) {
return r * sin(b);
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * sin(b)
end function
public static double code(double r, double a, double b) {
return r * Math.sin(b);
}
def code(r, a, b): return r * math.sin(b)
function code(r, a, b) return Float64(r * sin(b)) end
function tmp = code(r, a, b) tmp = r * sin(b); end
code[r_, a_, b_] := N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \sin b
\end{array}
Initial program 76.0%
*-commutative76.0%
associate-/l*75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in b around 0 53.1%
Taylor expanded in a around 0 36.5%
Final simplification36.5%
(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 76.0%
*-commutative76.0%
associate-/l*75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in b around 0 48.9%
associate-/l*48.8%
associate-/r/48.8%
Simplified48.8%
Taylor expanded in a around 0 32.9%
Final simplification32.9%
herbie shell --seed 2023285
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))