
(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
(let* ((t_0 (* (sin b) (sin a))))
(/
(* r (sin b))
(+ (fma (cos a) (cos b) (- t_0)) (fma (- (sin b)) (sin a) t_0)))))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return (r * sin(b)) / (fma(cos(a), cos(b), -t_0) + fma(-sin(b), sin(a), t_0));
}
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(Float64(r * sin(b)) / Float64(fma(cos(a), cos(b), Float64(-t_0)) + fma(Float64(-sin(b)), sin(a), t_0))) end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision] + (-t$95$0)), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos a, \cos b, -t_0\right) + \mathsf{fma}\left(-\sin b, \sin a, t_0\right)}
\end{array}
\end{array}
Initial program 76.7%
+-commutative76.7%
Simplified76.7%
+-commutative76.7%
cos-sum99.5%
prod-diff99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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, -\sin b \cdot \sin a\right)}
\end{array}
Initial program 76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
fma-neg99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((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 = sin(b) * (r / ((cos(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / 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}
\\
\sin b \cdot \frac{r}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 76.7%
associate-/l*76.6%
+-commutative76.6%
Simplified76.6%
associate-/r/76.7%
Applied egg-rr76.7%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(if (<= b -2500.0)
(* (sin b) (/ r (cos b)))
(if (<= b 240.0)
(/ (* r b) (cos (+ b a)))
(* r (/ 1.0 (/ (cos b) (sin b)))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2500.0) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 240.0) {
tmp = (r * b) / cos((b + a));
} else {
tmp = r * (1.0 / (cos(b) / 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 <= (-2500.0d0)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 240.0d0) then
tmp = (r * b) / cos((b + a))
else
tmp = r * (1.0d0 / (cos(b) / sin(b)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2500.0) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 240.0) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = r * (1.0 / (Math.cos(b) / Math.sin(b)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2500.0: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 240.0: tmp = (r * b) / math.cos((b + a)) else: tmp = r * (1.0 / (math.cos(b) / math.sin(b))) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2500.0) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 240.0) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(r * Float64(1.0 / Float64(cos(b) / sin(b)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2500.0) tmp = sin(b) * (r / cos(b)); elseif (b <= 240.0) tmp = (r * b) / cos((b + a)); else tmp = r * (1.0 / (cos(b) / sin(b))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2500.0], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 240.0], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2500:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 240:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{\cos b}{\sin b}}\\
\end{array}
\end{array}
if b < -2500Initial program 52.2%
associate-/l*52.2%
remove-double-neg52.2%
sin-neg52.2%
neg-mul-152.2%
associate-/r*52.2%
associate-/l*52.2%
*-commutative52.2%
associate-*l/52.1%
associate-/l*52.1%
sin-neg52.1%
distribute-lft-neg-in52.1%
distribute-rgt-neg-in52.1%
associate-/l*52.1%
metadata-eval52.1%
/-rgt-identity52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in a around 0 50.4%
associate-/l*50.4%
associate-/r/50.4%
Simplified50.4%
if -2500 < b < 240Initial program 96.9%
+-commutative96.9%
Simplified96.9%
Taylor expanded in b around 0 96.8%
if 240 < b Initial program 55.2%
associate-/l*55.1%
remove-double-neg55.1%
sin-neg55.1%
neg-mul-155.1%
associate-/r*55.1%
associate-/l*55.2%
*-commutative55.2%
associate-*l/55.2%
associate-/l*55.2%
sin-neg55.2%
distribute-lft-neg-in55.2%
distribute-rgt-neg-in55.2%
associate-/l*55.2%
metadata-eval55.2%
/-rgt-identity55.2%
+-commutative55.2%
Simplified55.2%
associate-*l/55.2%
*-commutative55.2%
associate-/l*55.1%
add-exp-log27.7%
associate-/r/27.7%
*-commutative27.7%
Applied egg-rr27.7%
Taylor expanded in a around 0 28.1%
rem-exp-log55.2%
associate-/l*55.1%
div-inv55.2%
Applied egg-rr55.2%
Final simplification76.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -2500.0) (not (<= b 240.0))) (* (sin b) (/ r (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2500.0) || !(b <= 240.0)) {
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 <= (-2500.0d0)) .or. (.not. (b <= 240.0d0))) 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 <= -2500.0) || !(b <= 240.0)) {
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 <= -2500.0) or not (b <= 240.0): 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 <= -2500.0) || !(b <= 240.0)) 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 <= -2500.0) || ~((b <= 240.0))) 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, -2500.0], N[Not[LessEqual[b, 240.0]], $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 -2500 \lor \neg \left(b \leq 240\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 < -2500 or 240 < b Initial program 53.8%
associate-/l*53.8%
remove-double-neg53.8%
sin-neg53.8%
neg-mul-153.8%
associate-/r*53.8%
associate-/l*53.8%
*-commutative53.8%
associate-*l/53.8%
associate-/l*53.8%
sin-neg53.8%
distribute-lft-neg-in53.8%
distribute-rgt-neg-in53.8%
associate-/l*53.8%
metadata-eval53.8%
/-rgt-identity53.8%
+-commutative53.8%
Simplified53.8%
Taylor expanded in a around 0 53.0%
associate-/l*52.9%
associate-/r/53.0%
Simplified53.0%
if -2500 < b < 240Initial program 96.9%
+-commutative96.9%
Simplified96.9%
Taylor expanded in b around 0 96.8%
Final simplification76.3%
(FPCore (r a b) :precision binary64 (if (<= b -2500.0) (* (sin b) (/ r (cos b))) (if (<= b 240.0) (/ (* r b) (cos (+ b a))) (/ (sin b) (/ (cos b) r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2500.0) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 240.0) {
tmp = (r * b) / cos((b + a));
} else {
tmp = sin(b) / (cos(b) / 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 <= (-2500.0d0)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 240.0d0) then
tmp = (r * b) / cos((b + a))
else
tmp = sin(b) / (cos(b) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2500.0) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 240.0) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = Math.sin(b) / (Math.cos(b) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2500.0: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 240.0: tmp = (r * b) / math.cos((b + a)) else: tmp = math.sin(b) / (math.cos(b) / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2500.0) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 240.0) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(sin(b) / Float64(cos(b) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2500.0) tmp = sin(b) * (r / cos(b)); elseif (b <= 240.0) tmp = (r * b) / cos((b + a)); else tmp = sin(b) / (cos(b) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2500.0], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 240.0], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2500:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 240:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\end{array}
\end{array}
if b < -2500Initial program 52.2%
associate-/l*52.2%
remove-double-neg52.2%
sin-neg52.2%
neg-mul-152.2%
associate-/r*52.2%
associate-/l*52.2%
*-commutative52.2%
associate-*l/52.1%
associate-/l*52.1%
sin-neg52.1%
distribute-lft-neg-in52.1%
distribute-rgt-neg-in52.1%
associate-/l*52.1%
metadata-eval52.1%
/-rgt-identity52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in a around 0 50.4%
associate-/l*50.4%
associate-/r/50.4%
Simplified50.4%
if -2500 < b < 240Initial program 96.9%
+-commutative96.9%
Simplified96.9%
Taylor expanded in b around 0 96.8%
if 240 < b Initial program 55.2%
associate-/l*55.1%
remove-double-neg55.1%
sin-neg55.1%
neg-mul-155.1%
associate-/r*55.1%
associate-/l*55.2%
*-commutative55.2%
associate-*l/55.2%
associate-/l*55.2%
sin-neg55.2%
distribute-lft-neg-in55.2%
distribute-rgt-neg-in55.2%
associate-/l*55.2%
metadata-eval55.2%
/-rgt-identity55.2%
+-commutative55.2%
Simplified55.2%
associate-*l/55.2%
*-commutative55.2%
associate-/l*55.1%
add-exp-log27.7%
associate-/r/27.7%
*-commutative27.7%
Applied egg-rr27.7%
Taylor expanded in a around 0 28.1%
rem-exp-log55.2%
*-commutative55.2%
associate-/l*55.2%
Applied egg-rr55.2%
Final simplification76.3%
(FPCore (r a b) :precision binary64 (if (<= b -2500.0) (* (sin b) (/ r (cos b))) (if (<= b 240.0) (/ (* r b) (cos (+ b a))) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2500.0) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 240.0) {
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 <= (-2500.0d0)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 240.0d0) 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 <= -2500.0) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 240.0) {
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 <= -2500.0: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 240.0: 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 <= -2500.0) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 240.0) 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 <= -2500.0) tmp = sin(b) * (r / cos(b)); elseif (b <= 240.0) 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, -2500.0], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 240.0], 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 -2500:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 240:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -2500Initial program 52.2%
associate-/l*52.2%
remove-double-neg52.2%
sin-neg52.2%
neg-mul-152.2%
associate-/r*52.2%
associate-/l*52.2%
*-commutative52.2%
associate-*l/52.1%
associate-/l*52.1%
sin-neg52.1%
distribute-lft-neg-in52.1%
distribute-rgt-neg-in52.1%
associate-/l*52.1%
metadata-eval52.1%
/-rgt-identity52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in a around 0 50.4%
associate-/l*50.4%
associate-/r/50.4%
Simplified50.4%
if -2500 < b < 240Initial program 96.9%
+-commutative96.9%
Simplified96.9%
Taylor expanded in b around 0 96.8%
if 240 < b Initial program 55.2%
+-commutative55.2%
Simplified55.2%
Taylor expanded in a around 0 55.2%
Final simplification76.3%
(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.7%
associate-/l*76.6%
+-commutative76.6%
Simplified76.6%
associate-/r/76.7%
Applied egg-rr76.7%
Final simplification76.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 76.7%
associate-/l*76.6%
remove-double-neg76.6%
sin-neg76.6%
neg-mul-176.6%
associate-/r*76.6%
associate-/l*76.7%
*-commutative76.7%
associate-*l/76.7%
associate-/l*76.7%
sin-neg76.7%
distribute-lft-neg-in76.7%
distribute-rgt-neg-in76.7%
associate-/l*76.7%
metadata-eval76.7%
/-rgt-identity76.7%
+-commutative76.7%
Simplified76.7%
Final simplification76.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(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 76.7%
Final simplification76.7%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(b) * (r / 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(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 76.7%
associate-/l*76.6%
+-commutative76.6%
Simplified76.6%
associate-/r/76.7%
Applied egg-rr76.7%
Taylor expanded in b around 0 56.3%
Final simplification56.3%
(FPCore (r a b) :precision binary64 (if (<= b 2e+19) (* r (/ b (cos (+ b a)))) (/ (- r) (sin a))))
double code(double r, double a, double b) {
double tmp;
if (b <= 2e+19) {
tmp = r * (b / cos((b + a)));
} else {
tmp = -r / sin(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 <= 2d+19) then
tmp = r * (b / cos((b + a)))
else
tmp = -r / sin(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 2e+19) {
tmp = r * (b / Math.cos((b + a)));
} else {
tmp = -r / Math.sin(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 2e+19: tmp = r * (b / math.cos((b + a))) else: tmp = -r / math.sin(a) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 2e+19) tmp = Float64(r * Float64(b / cos(Float64(b + a)))); else tmp = Float64(Float64(-r) / sin(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 2e+19) tmp = r * (b / cos((b + a))); else tmp = -r / sin(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 2e+19], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{+19}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-r}{\sin a}\\
\end{array}
\end{array}
if b < 2e19Initial program 83.7%
associate-/l*83.7%
remove-double-neg83.7%
sin-neg83.7%
neg-mul-183.7%
associate-/r*83.7%
associate-/l*83.7%
*-commutative83.7%
associate-*l/83.7%
associate-/l*83.7%
sin-neg83.7%
distribute-lft-neg-in83.7%
distribute-rgt-neg-in83.7%
associate-/l*83.7%
metadata-eval83.7%
/-rgt-identity83.7%
+-commutative83.7%
Simplified83.7%
Taylor expanded in b around 0 68.0%
if 2e19 < b Initial program 52.6%
associate-/l*52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in b around 0 11.1%
+-commutative11.1%
neg-mul-111.1%
unsub-neg11.1%
Simplified11.1%
Taylor expanded in b around inf 11.4%
associate-*r/11.4%
neg-mul-111.4%
Simplified11.4%
Final simplification55.1%
(FPCore (r a b) :precision binary64 (if (<= b 1.02e+18) (/ (* r b) (cos (+ b a))) (/ (- r) (sin a))))
double code(double r, double a, double b) {
double tmp;
if (b <= 1.02e+18) {
tmp = (r * b) / cos((b + a));
} else {
tmp = -r / sin(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.02d+18) then
tmp = (r * b) / cos((b + a))
else
tmp = -r / sin(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 1.02e+18) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = -r / Math.sin(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 1.02e+18: tmp = (r * b) / math.cos((b + a)) else: tmp = -r / math.sin(a) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 1.02e+18) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(Float64(-r) / sin(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 1.02e+18) tmp = (r * b) / cos((b + a)); else tmp = -r / sin(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 1.02e+18], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.02 \cdot 10^{+18}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-r}{\sin a}\\
\end{array}
\end{array}
if b < 1.02e18Initial program 83.7%
+-commutative83.7%
Simplified83.7%
Taylor expanded in b around 0 68.0%
if 1.02e18 < b Initial program 52.6%
associate-/l*52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in b around 0 11.1%
+-commutative11.1%
neg-mul-111.1%
unsub-neg11.1%
Simplified11.1%
Taylor expanded in b around inf 11.4%
associate-*r/11.4%
neg-mul-111.4%
Simplified11.4%
Final simplification55.1%
(FPCore (r a b) :precision binary64 (if (<= b 1.4) (* r (/ b (cos a))) (/ (- r) (sin a))))
double code(double r, double a, double b) {
double tmp;
if (b <= 1.4) {
tmp = r * (b / cos(a));
} else {
tmp = -r / sin(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.4d0) then
tmp = r * (b / cos(a))
else
tmp = -r / sin(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 1.4) {
tmp = r * (b / Math.cos(a));
} else {
tmp = -r / Math.sin(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 1.4: tmp = r * (b / math.cos(a)) else: tmp = -r / math.sin(a) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 1.4) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(Float64(-r) / sin(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 1.4) tmp = r * (b / cos(a)); else tmp = -r / sin(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 1.4], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.4:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-r}{\sin a}\\
\end{array}
\end{array}
if b < 1.3999999999999999Initial program 84.3%
associate-/l*84.2%
remove-double-neg84.2%
sin-neg84.2%
neg-mul-184.2%
associate-/r*84.2%
associate-/l*84.3%
*-commutative84.3%
associate-*l/84.3%
associate-/l*84.3%
sin-neg84.3%
distribute-lft-neg-in84.3%
distribute-rgt-neg-in84.3%
associate-/l*84.3%
metadata-eval84.3%
/-rgt-identity84.3%
+-commutative84.3%
Simplified84.3%
Taylor expanded in b around 0 70.2%
if 1.3999999999999999 < b Initial program 54.8%
associate-/l*54.7%
+-commutative54.7%
Simplified54.7%
Taylor expanded in b around 0 10.7%
+-commutative10.7%
neg-mul-110.7%
unsub-neg10.7%
Simplified10.7%
Taylor expanded in b around inf 11.0%
associate-*r/11.0%
neg-mul-111.0%
Simplified11.0%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (if (<= b 1.45) (/ (* r b) (cos a)) (/ (- r) (sin a))))
double code(double r, double a, double b) {
double tmp;
if (b <= 1.45) {
tmp = (r * b) / cos(a);
} else {
tmp = -r / sin(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.45d0) then
tmp = (r * b) / cos(a)
else
tmp = -r / sin(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 1.45) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = -r / Math.sin(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 1.45: tmp = (r * b) / math.cos(a) else: tmp = -r / math.sin(a) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 1.45) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(Float64(-r) / sin(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 1.45) tmp = (r * b) / cos(a); else tmp = -r / sin(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 1.45], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.45:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-r}{\sin a}\\
\end{array}
\end{array}
if b < 1.44999999999999996Initial program 84.3%
associate-/l*84.2%
remove-double-neg84.2%
sin-neg84.2%
neg-mul-184.2%
associate-/r*84.2%
associate-/l*84.3%
*-commutative84.3%
associate-*l/84.3%
associate-/l*84.3%
sin-neg84.3%
distribute-lft-neg-in84.3%
distribute-rgt-neg-in84.3%
associate-/l*84.3%
metadata-eval84.3%
/-rgt-identity84.3%
+-commutative84.3%
Simplified84.3%
Taylor expanded in b around 0 70.2%
if 1.44999999999999996 < b Initial program 54.8%
associate-/l*54.7%
+-commutative54.7%
Simplified54.7%
Taylor expanded in b around 0 10.7%
+-commutative10.7%
neg-mul-110.7%
unsub-neg10.7%
Simplified10.7%
Taylor expanded in b around inf 11.0%
associate-*r/11.0%
neg-mul-111.0%
Simplified11.0%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (if (<= b 0.017) (* r b) (/ (- r) (sin a))))
double code(double r, double a, double b) {
double tmp;
if (b <= 0.017) {
tmp = r * b;
} else {
tmp = -r / sin(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.017d0) then
tmp = r * b
else
tmp = -r / sin(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 0.017) {
tmp = r * b;
} else {
tmp = -r / Math.sin(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 0.017: tmp = r * b else: tmp = -r / math.sin(a) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 0.017) tmp = Float64(r * b); else tmp = Float64(Float64(-r) / sin(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 0.017) tmp = r * b; else tmp = -r / sin(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 0.017], N[(r * b), $MachinePrecision], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.017:\\
\;\;\;\;r \cdot b\\
\mathbf{else}:\\
\;\;\;\;\frac{-r}{\sin a}\\
\end{array}
\end{array}
if b < 0.017000000000000001Initial program 84.6%
associate-/l*84.6%
remove-double-neg84.6%
sin-neg84.6%
neg-mul-184.6%
associate-/r*84.6%
associate-/l*84.6%
*-commutative84.6%
associate-*l/84.6%
associate-/l*84.6%
sin-neg84.6%
distribute-lft-neg-in84.6%
distribute-rgt-neg-in84.6%
associate-/l*84.6%
metadata-eval84.6%
/-rgt-identity84.6%
+-commutative84.6%
Simplified84.6%
Taylor expanded in b around 0 70.4%
Taylor expanded in a around 0 44.4%
if 0.017000000000000001 < b Initial program 54.3%
associate-/l*54.3%
+-commutative54.3%
Simplified54.3%
Taylor expanded in b around 0 11.2%
+-commutative11.2%
neg-mul-111.2%
unsub-neg11.2%
Simplified11.2%
Taylor expanded in b around inf 11.0%
associate-*r/11.0%
neg-mul-111.0%
Simplified11.0%
Final simplification35.7%
(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.7%
associate-/l*76.6%
remove-double-neg76.6%
sin-neg76.6%
neg-mul-176.6%
associate-/r*76.6%
associate-/l*76.7%
*-commutative76.7%
associate-*l/76.7%
associate-/l*76.7%
sin-neg76.7%
distribute-lft-neg-in76.7%
distribute-rgt-neg-in76.7%
associate-/l*76.7%
metadata-eval76.7%
/-rgt-identity76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 53.1%
Taylor expanded in a around 0 33.6%
Final simplification33.6%
herbie shell --seed 2024018
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))