
(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 16 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 b) (- (sin a)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(b), -sin(a), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(b), Float64(-sin(a)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $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 b, -\sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.6%
sub-neg99.6%
Applied egg-rr99.6%
+-commutative99.6%
distribute-rgt-neg-in99.6%
fma-define99.6%
*-commutative99.6%
Simplified99.6%
(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 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.6%
cancel-sign-sub-inv99.6%
fma-define99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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 77.4%
associate-/l*77.4%
remove-double-neg77.4%
remove-double-neg77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.6%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* 0.5 (* 2.0 (cos (- b a)))) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((0.5 * (2.0 * cos((b - 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) / ((0.5d0 * (2.0d0 * cos((b - a)))) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((0.5 * (2.0 * Math.cos((b - a)))) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((0.5 * (2.0 * math.cos((b - a)))) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(0.5 * Float64(2.0 * cos(Float64(b - a)))) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((0.5 * (2.0 * cos((b - a)))) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(0.5 * N[(2.0 * N[Cos[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{0.5 \cdot \left(2 \cdot \cos \left(b - a\right)\right) - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
associate-/l*77.4%
remove-double-neg77.4%
remove-double-neg77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.6%
Applied egg-rr99.5%
*-commutative99.5%
cos-mult78.9%
clear-num78.8%
+-commutative78.8%
cos-sum79.1%
sub-neg79.1%
distribute-rgt-neg-in79.1%
add-sqr-sqrt40.1%
sqrt-unprod78.6%
sqr-neg78.6%
sqrt-unprod38.4%
add-sqr-sqrt78.4%
cos-diff78.7%
cos-diff78.4%
*-commutative78.4%
*-commutative78.4%
cos-diff78.7%
Applied egg-rr78.7%
associate-/r/78.8%
metadata-eval78.8%
count-278.8%
Simplified78.8%
(FPCore (r a b) :precision binary64 (* (/ r (cos a)) (/ (sin b) (cos b))))
double code(double r, double a, double b) {
return (r / cos(a)) * (sin(b) / cos(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)) * (sin(b) / cos(b))
end function
public static double code(double r, double a, double b) {
return (r / Math.cos(a)) * (Math.sin(b) / Math.cos(b));
}
def code(r, a, b): return (r / math.cos(a)) * (math.sin(b) / math.cos(b))
function code(r, a, b) return Float64(Float64(r / cos(a)) * Float64(sin(b) / cos(b))) end
function tmp = code(r, a, b) tmp = (r / cos(a)) * (sin(b) / cos(b)); end
code[r_, a_, b_] := N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos a} \cdot \frac{\sin b}{\cos b}
\end{array}
Initial program 77.4%
associate-/l*77.4%
remove-double-neg77.4%
remove-double-neg77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.6%
Applied egg-rr99.5%
sin-mult78.4%
div-sub78.4%
cos-sum79.2%
sub-neg79.2%
distribute-rgt-neg-in79.2%
add-sqr-sqrt40.2%
sqrt-unprod78.5%
sqr-neg78.5%
sqrt-unprod38.3%
add-sqr-sqrt77.6%
cos-diff78.3%
Applied egg-rr78.3%
+-inverses78.3%
Simplified78.3%
Taylor expanded in r around 0 78.3%
times-frac78.3%
Simplified78.3%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos(a) * cos(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) * cos(b)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos(a) * Math.cos(b)));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos(a) * math.cos(b)))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(a) * cos(b)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos(a) * cos(b))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b}
\end{array}
Initial program 77.4%
associate-/l*77.4%
remove-double-neg77.4%
remove-double-neg77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.6%
Applied egg-rr99.5%
sin-mult78.4%
div-sub78.4%
cos-sum79.2%
sub-neg79.2%
distribute-rgt-neg-in79.2%
add-sqr-sqrt40.2%
sqrt-unprod78.5%
sqr-neg78.5%
sqrt-unprod38.3%
add-sqr-sqrt77.6%
cos-diff78.3%
Applied egg-rr78.3%
+-inverses78.3%
Simplified78.3%
--rgt-identity78.3%
Applied egg-rr78.3%
Final simplification78.3%
(FPCore (r a b) :precision binary64 (if (or (<= a -1.85e-7) (not (<= a 620000000.0))) (/ (sin b) (/ (cos a) r)) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -1.85e-7) || !(a <= 620000000.0)) {
tmp = sin(b) / (cos(a) / r);
} 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 <= (-1.85d-7)) .or. (.not. (a <= 620000000.0d0))) then
tmp = sin(b) / (cos(a) / r)
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 <= -1.85e-7) || !(a <= 620000000.0)) {
tmp = Math.sin(b) / (Math.cos(a) / r);
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -1.85e-7) or not (a <= 620000000.0): tmp = math.sin(b) / (math.cos(a) / r) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -1.85e-7) || !(a <= 620000000.0)) tmp = Float64(sin(b) / Float64(cos(a) / r)); 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 <= -1.85e-7) || ~((a <= 620000000.0))) tmp = sin(b) / (cos(a) / r); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -1.85e-7], N[Not[LessEqual[a, 620000000.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $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 -1.85 \cdot 10^{-7} \lor \neg \left(a \leq 620000000\right):\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -1.85000000000000002e-7 or 6.2e8 < a Initial program 59.5%
associate-/l*59.4%
remove-double-neg59.4%
remove-double-neg59.4%
+-commutative59.4%
Simplified59.4%
associate-*r/59.5%
clear-num59.4%
Applied egg-rr59.4%
Taylor expanded in b around 0 58.9%
frac-2neg58.9%
metadata-eval58.9%
div-inv58.9%
distribute-neg-frac258.9%
distribute-rgt-neg-in58.9%
add-sqr-sqrt27.3%
sqrt-unprod27.8%
sqr-neg27.8%
sqrt-unprod9.8%
add-sqr-sqrt19.3%
clear-num19.3%
Applied egg-rr19.3%
neg-mul-119.3%
*-commutative19.3%
associate-*r/19.3%
distribute-rgt-neg-in19.3%
Simplified19.3%
add-sqr-sqrt8.3%
sqrt-unprod28.9%
sqr-neg28.9%
sqrt-unprod29.2%
add-sqr-sqrt59.0%
clear-num58.9%
un-div-inv59.0%
Applied egg-rr59.0%
if -1.85000000000000002e-7 < a < 6.2e8Initial program 97.5%
associate-/l*97.6%
remove-double-neg97.6%
remove-double-neg97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in a around 0 97.5%
associate-/l*97.6%
Simplified97.6%
Final simplification77.2%
(FPCore (r a b) :precision binary64 (if (or (<= a -1.85e-7) (not (<= a 620000000.0))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -1.85e-7) || !(a <= 620000000.0)) {
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 <= (-1.85d-7)) .or. (.not. (a <= 620000000.0d0))) 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 <= -1.85e-7) || !(a <= 620000000.0)) {
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 <= -1.85e-7) or not (a <= 620000000.0): 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 <= -1.85e-7) || !(a <= 620000000.0)) 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 <= -1.85e-7) || ~((a <= 620000000.0))) 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, -1.85e-7], N[Not[LessEqual[a, 620000000.0]], $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 -1.85 \cdot 10^{-7} \lor \neg \left(a \leq 620000000\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -1.85000000000000002e-7 or 6.2e8 < a Initial program 59.5%
associate-/l*59.4%
remove-double-neg59.4%
remove-double-neg59.4%
+-commutative59.4%
Simplified59.4%
Taylor expanded in b around 0 58.9%
if -1.85000000000000002e-7 < a < 6.2e8Initial program 97.5%
associate-/l*97.6%
remove-double-neg97.6%
remove-double-neg97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in a around 0 97.5%
associate-/l*97.6%
Simplified97.6%
Final simplification77.2%
(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 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.6%
sub-neg99.6%
Applied egg-rr99.6%
+-commutative99.6%
distribute-rgt-neg-in99.6%
fma-define99.6%
*-commutative99.6%
Simplified99.6%
associate-/l*99.5%
fma-undefine99.5%
add-sqr-sqrt48.6%
sqrt-unprod86.8%
sqr-neg86.8%
sqrt-unprod38.2%
add-sqr-sqrt77.4%
*-commutative77.4%
+-commutative77.4%
cos-diff77.6%
Applied egg-rr77.6%
*-commutative77.6%
associate-*l/77.6%
associate-*r/77.6%
Simplified77.6%
(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 77.4%
associate-/l*77.4%
remove-double-neg77.4%
remove-double-neg77.4%
+-commutative77.4%
Simplified77.4%
(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 77.4%
associate-/l*77.4%
remove-double-neg77.4%
remove-double-neg77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in b around 0 56.1%
(FPCore (r a b) :precision binary64 (if (<= b -21000.0) (/ 1.0 (/ 1.0 (* r (sin b)))) (if (<= b 115.0) (* b (/ r (cos a))) (* r (- (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -21000.0) {
tmp = 1.0 / (1.0 / (r * sin(b)));
} else if (b <= 115.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 <= (-21000.0d0)) then
tmp = 1.0d0 / (1.0d0 / (r * sin(b)))
else if (b <= 115.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 <= -21000.0) {
tmp = 1.0 / (1.0 / (r * Math.sin(b)));
} else if (b <= 115.0) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r * -Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -21000.0: tmp = 1.0 / (1.0 / (r * math.sin(b))) elif b <= 115.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 <= -21000.0) tmp = Float64(1.0 / Float64(1.0 / Float64(r * sin(b)))); elseif (b <= 115.0) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(r * Float64(-sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -21000.0) tmp = 1.0 / (1.0 / (r * sin(b))); elseif (b <= 115.0) tmp = b * (r / cos(a)); else tmp = r * -sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -21000.0], N[(1.0 / N[(1.0 / N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 115.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 -21000:\\
\;\;\;\;\frac{1}{\frac{1}{r \cdot \sin b}}\\
\mathbf{elif}\;b \leq 115:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \left(-\sin b\right)\\
\end{array}
\end{array}
if b < -21000Initial program 53.4%
associate-/l*53.4%
remove-double-neg53.4%
remove-double-neg53.4%
+-commutative53.4%
Simplified53.4%
associate-*r/53.4%
clear-num53.4%
Applied egg-rr53.4%
Taylor expanded in b around 0 12.2%
Taylor expanded in a around 0 13.0%
if -21000 < b < 115Initial program 99.2%
associate-/l*99.2%
remove-double-neg99.2%
remove-double-neg99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 98.2%
associate-/l*98.2%
Simplified98.2%
if 115 < b Initial program 54.3%
associate-/l*54.4%
remove-double-neg54.4%
remove-double-neg54.4%
+-commutative54.4%
Simplified54.4%
associate-*r/54.3%
clear-num54.1%
Applied egg-rr54.1%
Taylor expanded in b around 0 9.4%
frac-2neg9.4%
metadata-eval9.4%
div-inv9.4%
distribute-neg-frac29.4%
distribute-rgt-neg-in9.4%
add-sqr-sqrt4.6%
sqrt-unprod12.4%
sqr-neg12.4%
sqrt-unprod7.8%
add-sqr-sqrt13.9%
clear-num13.9%
Applied egg-rr13.9%
neg-mul-113.9%
*-commutative13.9%
associate-*r/13.9%
distribute-rgt-neg-in13.9%
Simplified13.9%
Taylor expanded in a around 0 15.0%
Final simplification57.8%
(FPCore (r a b) :precision binary64 (if (<= b -22000.0) (* r (sin b)) (if (<= b 390.0) (* b (/ r (cos a))) (* r (- (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -22000.0) {
tmp = r * sin(b);
} else if (b <= 390.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 <= (-22000.0d0)) then
tmp = r * sin(b)
else if (b <= 390.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 <= -22000.0) {
tmp = r * Math.sin(b);
} else if (b <= 390.0) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r * -Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -22000.0: tmp = r * math.sin(b) elif b <= 390.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 <= -22000.0) tmp = Float64(r * sin(b)); elseif (b <= 390.0) tmp = Float64(b * Float64(r / cos(a))); else tmp = Float64(r * Float64(-sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -22000.0) tmp = r * sin(b); elseif (b <= 390.0) tmp = b * (r / cos(a)); else tmp = r * -sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -22000.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 390.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 -22000:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 390:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \left(-\sin b\right)\\
\end{array}
\end{array}
if b < -22000Initial program 53.4%
associate-/l*53.4%
remove-double-neg53.4%
remove-double-neg53.4%
+-commutative53.4%
Simplified53.4%
associate-*r/53.4%
clear-num53.4%
Applied egg-rr53.4%
Taylor expanded in b around 0 12.2%
Taylor expanded in a around 0 13.0%
if -22000 < b < 390Initial program 99.2%
associate-/l*99.2%
remove-double-neg99.2%
remove-double-neg99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 98.2%
associate-/l*98.2%
Simplified98.2%
if 390 < b Initial program 54.3%
associate-/l*54.4%
remove-double-neg54.4%
remove-double-neg54.4%
+-commutative54.4%
Simplified54.4%
associate-*r/54.3%
clear-num54.1%
Applied egg-rr54.1%
Taylor expanded in b around 0 9.4%
frac-2neg9.4%
metadata-eval9.4%
div-inv9.4%
distribute-neg-frac29.4%
distribute-rgt-neg-in9.4%
add-sqr-sqrt4.6%
sqrt-unprod12.4%
sqr-neg12.4%
sqrt-unprod7.8%
add-sqr-sqrt13.9%
clear-num13.9%
Applied egg-rr13.9%
neg-mul-113.9%
*-commutative13.9%
associate-*r/13.9%
distribute-rgt-neg-in13.9%
Simplified13.9%
Taylor expanded in a around 0 15.0%
Final simplification57.8%
(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 77.4%
associate-/l*77.4%
remove-double-neg77.4%
remove-double-neg77.4%
+-commutative77.4%
Simplified77.4%
associate-*r/77.4%
clear-num77.2%
Applied egg-rr77.2%
Taylor expanded in b around 0 55.9%
Taylor expanded in a around 0 37.6%
(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 77.4%
associate-/l*77.4%
remove-double-neg77.4%
remove-double-neg77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in b around 0 52.8%
associate-/l*52.8%
Simplified52.8%
Taylor expanded in a around 0 34.2%
*-commutative34.2%
Simplified34.2%
herbie shell --seed 2024156
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))