
(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 17 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(Float64(-sin(b)) * 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, \left(-\sin b\right) \cdot \sin a\right)}
\end{array}
Initial program 71.7%
+-commutative71.7%
Simplified71.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.6%
Applied egg-rr99.6%
(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 71.7%
+-commutative71.7%
Simplified71.7%
cos-sum99.5%
Applied egg-rr99.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 71.7%
associate-/l*71.6%
remove-double-neg71.6%
remove-double-neg71.6%
+-commutative71.6%
Simplified71.6%
cos-sum99.5%
Applied egg-rr99.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 71.7%
+-commutative71.7%
Simplified71.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.6%
Applied egg-rr99.6%
add-sqr-sqrt44.7%
sqrt-unprod84.6%
sqr-neg84.6%
sqrt-unprod39.9%
add-sqr-sqrt71.4%
sin-mult73.0%
div-sub73.0%
cos-diff72.0%
add-sqr-sqrt40.2%
sqrt-unprod72.7%
sqr-neg72.7%
sqrt-unprod32.5%
add-sqr-sqrt73.6%
cancel-sign-sub-inv73.6%
cos-sum72.9%
Applied egg-rr72.9%
+-inverses72.9%
Simplified72.9%
fma-undefine72.9%
+-rgt-identity72.9%
Applied egg-rr72.9%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return sin(b) * (r / (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 = sin(b) * (r / (cos(b) * cos(a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / (Math.cos(b) * Math.cos(a)));
}
def code(r, a, b): return math.sin(b) * (r / (math.cos(b) * math.cos(a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(cos(b) * cos(a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / (cos(b) * cos(a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a}
\end{array}
Initial program 71.7%
+-commutative71.7%
Simplified71.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.6%
Applied egg-rr99.6%
add-sqr-sqrt44.7%
sqrt-unprod84.6%
sqr-neg84.6%
sqrt-unprod39.9%
add-sqr-sqrt71.4%
sin-mult73.0%
div-sub73.0%
cos-diff72.0%
add-sqr-sqrt40.2%
sqrt-unprod72.7%
sqr-neg72.7%
sqrt-unprod32.5%
add-sqr-sqrt73.6%
cancel-sign-sub-inv73.6%
cos-sum72.9%
Applied egg-rr72.9%
+-inverses72.9%
Simplified72.9%
Taylor expanded in r around 0 72.9%
*-commutative72.9%
*-commutative72.9%
associate-*r/72.8%
*-commutative72.8%
Simplified72.8%
Final simplification72.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00055) (not (<= b 0.52))) (/ r (/ (cos b) (sin b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00055) || !(b <= 0.52)) {
tmp = r / (cos(b) / 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 <= (-0.00055d0)) .or. (.not. (b <= 0.52d0))) then
tmp = r / (cos(b) / 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 <= -0.00055) || !(b <= 0.52)) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00055) or not (b <= 0.52): tmp = r / (math.cos(b) / math.sin(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.00055) || !(b <= 0.52)) tmp = Float64(r / Float64(cos(b) / 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 <= -0.00055) || ~((b <= 0.52))) tmp = r / (cos(b) / sin(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00055], N[Not[LessEqual[b, 0.52]], $MachinePrecision]], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[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.00055 \lor \neg \left(b \leq 0.52\right):\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -5.50000000000000033e-4 or 0.52000000000000002 < b Initial program 46.8%
+-commutative46.8%
Simplified46.8%
cos-sum99.2%
cancel-sign-sub-inv99.2%
fma-define99.3%
Applied egg-rr99.3%
frac-2neg99.3%
fma-undefine99.2%
cancel-sign-sub-inv99.2%
cos-sum46.8%
div-inv46.8%
distribute-rgt-neg-in46.8%
add-sqr-sqrt18.3%
sqrt-unprod22.8%
sqr-neg22.8%
sqrt-unprod4.4%
add-sqr-sqrt8.0%
Applied egg-rr8.0%
associate-*r/8.0%
*-rgt-identity8.0%
associate-/l*8.0%
distribute-neg-frac28.0%
distribute-neg-frac8.0%
Simplified8.0%
clear-num8.0%
un-div-inv8.0%
cos-sum2.3%
fma-neg2.3%
fma-define2.3%
distribute-lft-neg-in2.3%
add-sqr-sqrt0.8%
sqrt-unprod5.7%
sqr-neg5.7%
sqrt-unprod4.9%
add-sqr-sqrt8.4%
cos-diff7.7%
add-sqr-sqrt3.4%
sqrt-unprod31.9%
sqr-neg31.9%
sqrt-unprod28.4%
add-sqr-sqrt47.1%
Applied egg-rr47.1%
Taylor expanded in a around 0 48.1%
if -5.50000000000000033e-4 < b < 0.52000000000000002Initial program 97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in b around 0 97.4%
Final simplification72.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.0006) (not (<= b 0.52))) (* (sin b) (/ r (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0006) || !(b <= 0.52)) {
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.0006d0)) .or. (.not. (b <= 0.52d0))) 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.0006) || !(b <= 0.52)) {
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.0006) or not (b <= 0.52): 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.0006) || !(b <= 0.52)) 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.0006) || ~((b <= 0.52))) 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.0006], N[Not[LessEqual[b, 0.52]], $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.0006 \lor \neg \left(b \leq 0.52\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 < -5.99999999999999947e-4 or 0.52000000000000002 < b Initial program 46.8%
+-commutative46.8%
Simplified46.8%
cos-sum99.2%
cancel-sign-sub-inv99.2%
fma-define99.3%
Applied egg-rr99.3%
expm1-log1p-u99.3%
expm1-undefine99.2%
Applied egg-rr99.2%
expm1-define99.3%
Simplified99.3%
Taylor expanded in a around 0 48.1%
*-commutative48.1%
*-lft-identity48.1%
times-frac48.1%
/-rgt-identity48.1%
Simplified48.1%
if -5.99999999999999947e-4 < b < 0.52000000000000002Initial program 97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in b around 0 97.4%
Final simplification72.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00055) (not (<= b 0.52))) (* r (/ (sin b) (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00055) || !(b <= 0.52)) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = (r * b) / cos((b + a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-0.00055d0)) .or. (.not. (b <= 0.52d0))) then
tmp = r * (sin(b) / cos(b))
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00055) || !(b <= 0.52)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00055) or not (b <= 0.52): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.00055) || !(b <= 0.52)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.00055) || ~((b <= 0.52))) tmp = r * (sin(b) / cos(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00055], N[Not[LessEqual[b, 0.52]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00055 \lor \neg \left(b \leq 0.52\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -5.50000000000000033e-4 or 0.52000000000000002 < b Initial program 46.8%
associate-/l*46.8%
remove-double-neg46.8%
remove-double-neg46.8%
+-commutative46.8%
Simplified46.8%
Taylor expanded in a around 0 48.1%
if -5.50000000000000033e-4 < b < 0.52000000000000002Initial program 97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in b around 0 97.4%
Final simplification72.2%
(FPCore (r a b) :precision binary64 (if (<= b -0.00065) (/ r (/ (cos b) (sin b))) (if (<= b 0.52) (/ (* r b) (cos (+ b a))) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.00065) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 0.52) {
tmp = (r * b) / cos((b + 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 <= (-0.00065d0)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 0.52d0) then
tmp = (r * b) / cos((b + 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 <= -0.00065) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 0.52) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = (r * Math.sin(b)) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.00065: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 0.52: tmp = (r * b) / math.cos((b + a)) else: tmp = (r * math.sin(b)) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.00065) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 0.52) tmp = Float64(Float64(r * b) / cos(Float64(b + 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 <= -0.00065) tmp = r / (cos(b) / sin(b)); elseif (b <= 0.52) tmp = (r * b) / cos((b + a)); else tmp = (r * sin(b)) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.00065], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.52], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $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 -0.00065:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 0.52:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -6.4999999999999997e-4Initial program 49.7%
+-commutative49.7%
Simplified49.7%
cos-sum99.2%
cancel-sign-sub-inv99.2%
fma-define99.4%
Applied egg-rr99.4%
frac-2neg99.4%
fma-undefine99.2%
cancel-sign-sub-inv99.2%
cos-sum49.7%
div-inv49.6%
distribute-rgt-neg-in49.6%
add-sqr-sqrt21.9%
sqrt-unprod24.9%
sqr-neg24.9%
sqrt-unprod2.9%
add-sqr-sqrt6.6%
Applied egg-rr6.6%
associate-*r/6.6%
*-rgt-identity6.6%
associate-/l*6.6%
distribute-neg-frac26.6%
distribute-neg-frac6.6%
Simplified6.6%
clear-num6.6%
un-div-inv6.6%
cos-sum2.4%
fma-neg2.4%
fma-define2.4%
distribute-lft-neg-in2.4%
add-sqr-sqrt1.0%
sqrt-unprod5.7%
sqr-neg5.7%
sqrt-unprod4.7%
add-sqr-sqrt8.7%
cos-diff6.6%
add-sqr-sqrt3.6%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod27.7%
add-sqr-sqrt49.7%
Applied egg-rr49.7%
Taylor expanded in a around 0 50.7%
if -6.4999999999999997e-4 < b < 0.52000000000000002Initial program 97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in b around 0 97.4%
if 0.52000000000000002 < b Initial program 44.6%
associate-/l*44.5%
remove-double-neg44.5%
remove-double-neg44.5%
+-commutative44.5%
Simplified44.5%
Taylor expanded in a around 0 46.1%
*-commutative46.1%
Simplified46.1%
Final simplification72.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(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 71.7%
Final simplification71.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 71.7%
+-commutative71.7%
Simplified71.7%
*-commutative71.7%
associate-/l*71.7%
Applied egg-rr71.7%
(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 71.7%
associate-/l*71.6%
remove-double-neg71.6%
remove-double-neg71.6%
+-commutative71.6%
Simplified71.6%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos a))))
double code(double r, double a, double b) {
return r * (sin(b) / cos(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos(a));
}
def code(r, a, b): return r * (math.sin(b) / math.cos(a))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(a))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos(a)); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a}
\end{array}
Initial program 71.7%
associate-/l*71.6%
remove-double-neg71.6%
remove-double-neg71.6%
+-commutative71.6%
Simplified71.6%
Taylor expanded in b around 0 52.6%
(FPCore (r a b) :precision binary64 (if (<= b 3450.0) (/ (* r b) (cos a)) (* r (sin b))))
double code(double r, double a, double b) {
double tmp;
if (b <= 3450.0) {
tmp = (r * b) / cos(a);
} else {
tmp = r * sin(b);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3450.0d0) then
tmp = (r * b) / cos(a)
else
tmp = r * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 3450.0) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = r * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 3450.0: tmp = (r * b) / math.cos(a) else: tmp = r * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 3450.0) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(r * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 3450.0) tmp = (r * b) / cos(a); else tmp = r * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 3450.0], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3450:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \sin b\\
\end{array}
\end{array}
if b < 3450Initial program 82.8%
associate-/l*82.7%
remove-double-neg82.7%
remove-double-neg82.7%
+-commutative82.7%
Simplified82.7%
Taylor expanded in b around 0 67.8%
if 3450 < b Initial program 43.9%
+-commutative43.9%
Simplified43.9%
associate-*r/43.8%
add-cube-cbrt43.1%
associate-*l*43.1%
pow243.1%
Applied egg-rr43.1%
Taylor expanded in b around 0 10.3%
Taylor expanded in a around 0 11.0%
Final simplification51.6%
(FPCore (r a b) :precision binary64 (if (<= b 3450.0) (* b (/ r (cos a))) (* r (sin b))))
double code(double r, double a, double b) {
double tmp;
if (b <= 3450.0) {
tmp = b * (r / cos(a));
} else {
tmp = r * sin(b);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3450.0d0) then
tmp = b * (r / cos(a))
else
tmp = r * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 3450.0) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 3450.0: tmp = b * (r / math.cos(a)) else: tmp = r * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 3450.0) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(r * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 3450.0) tmp = b * (r / cos(a)); else tmp = r * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 3450.0], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3450:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \sin b\\
\end{array}
\end{array}
if b < 3450Initial program 82.8%
associate-/l*82.7%
remove-double-neg82.7%
remove-double-neg82.7%
+-commutative82.7%
Simplified82.7%
Taylor expanded in b around 0 67.8%
associate-/l*67.8%
Simplified67.8%
if 3450 < b Initial program 43.9%
+-commutative43.9%
Simplified43.9%
associate-*r/43.8%
add-cube-cbrt43.1%
associate-*l*43.1%
pow243.1%
Applied egg-rr43.1%
Taylor expanded in b around 0 10.3%
Taylor expanded in a around 0 11.0%
(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 71.7%
+-commutative71.7%
Simplified71.7%
associate-*r/71.6%
add-cube-cbrt70.5%
associate-*l*70.5%
pow270.5%
Applied egg-rr70.5%
Taylor expanded in b around 0 51.9%
Taylor expanded in a around 0 37.0%
(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 71.7%
associate-/l*71.6%
remove-double-neg71.6%
remove-double-neg71.6%
+-commutative71.6%
Simplified71.6%
Taylor expanded in b around 0 49.5%
associate-/l*49.5%
Simplified49.5%
Taylor expanded in a around 0 33.6%
*-commutative33.6%
Simplified33.6%
herbie shell --seed 2024107
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))