
(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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ a b)))))
double code(double r, double a, double b) {
return r * (sin(b) / cos((a + b)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos((a + b)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos((a + b)));
}
def code(r, a, b): return r * (math.sin(b) / math.cos((a + b)))
function code(r, a, b) return Float64(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\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.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.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(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.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(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.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
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.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (/ (* -2.0 (cos (+ b a))) -2.0) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / (((-2.0 * cos((b + a))) / -2.0) - (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) / ((((-2.0d0) * cos((b + a))) / (-2.0d0)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (((-2.0 * Math.cos((b + a))) / -2.0) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / (((-2.0 * math.cos((b + a))) / -2.0) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(Float64(-2.0 * cos(Float64(b + a))) / -2.0) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (((-2.0 * cos((b + a))) / -2.0) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[(-2.0 * N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\frac{-2 \cdot \cos \left(b + a\right)}{-2} - \sin b \cdot \sin a}
\end{array}
Initial program 76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
Applied egg-rr99.5%
cos-mult78.1%
frac-2neg78.1%
cos-diff78.1%
add-sqr-sqrt37.6%
sqrt-unprod77.9%
sqr-neg77.9%
sqrt-unprod40.4%
add-sqr-sqrt78.0%
cancel-sign-sub-inv78.0%
cos-sum77.5%
metadata-eval77.5%
Applied egg-rr77.5%
count-277.5%
distribute-lft-neg-in77.5%
metadata-eval77.5%
Simplified77.5%
Final simplification77.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) 0.0)))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), 0.0);
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), 0.0)) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, 0\right)}
\end{array}
Initial program 76.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
add-sqr-sqrt51.3%
sqrt-unprod87.8%
sqr-neg87.8%
sqrt-unprod36.5%
add-sqr-sqrt75.8%
sin-mult77.2%
div-sub77.2%
Applied egg-rr77.2%
+-inverses77.2%
Simplified77.2%
Final simplification77.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -2500.0) (not (<= b 240.0))) (* r (/ (sin b) (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 = 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 <= (-2500.0d0)) .or. (.not. (b <= 240.0d0))) 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 <= -2500.0) || !(b <= 240.0)) {
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 <= -2500.0) or not (b <= 240.0): 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 <= -2500.0) || !(b <= 240.0)) 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 <= -2500.0) || ~((b <= 240.0))) 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, -2500.0], N[Not[LessEqual[b, 240.0]], $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 -2500 \lor \neg \left(b \leq 240\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 < -2500 or 240 < b Initial program 53.8%
remove-double-neg53.8%
remove-double-neg53.8%
+-commutative53.8%
Simplified53.8%
Taylor expanded in a around 0 52.9%
if -2500 < b < 240Initial program 96.9%
associate-*r/96.9%
+-commutative96.9%
Simplified96.9%
Taylor expanded in b around 0 96.8%
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%
remove-double-neg53.8%
remove-double-neg53.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%
associate-*r/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.1%
remove-double-neg52.1%
remove-double-neg52.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%
associate-*r/96.9%
+-commutative96.9%
Simplified96.9%
Taylor expanded in b around 0 96.8%
if 240 < b Initial program 55.2%
remove-double-neg55.2%
remove-double-neg55.2%
+-commutative55.2%
Simplified55.2%
associate-*r/55.2%
*-commutative55.2%
associate-/l*55.2%
Applied egg-rr55.2%
Taylor expanded in a around 0 55.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.1%
remove-double-neg52.1%
remove-double-neg52.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%
associate-*r/96.9%
+-commutative96.9%
Simplified96.9%
Taylor expanded in b around 0 96.8%
if 240 < b Initial program 55.2%
remove-double-neg55.2%
remove-double-neg55.2%
+-commutative55.2%
Simplified55.2%
Taylor expanded in a around 0 55.2%
*-commutative55.2%
Simplified55.2%
Final simplification76.3%
(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%
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%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
Final simplification76.7%
(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 76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 56.3%
Final simplification56.3%
(FPCore (r a b) :precision binary64 (* r (/ b (cos (+ b a)))))
double code(double r, double a, double b) {
return r * (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 * (b / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos((b + a)));
}
def code(r, a, b): return r * (b / math.cos((b + a)))
function code(r, a, b) return Float64(r * Float64(b / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = r * (b / cos((b + a))); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos \left(b + a\right)}
\end{array}
Initial program 76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 53.4%
Final simplification53.4%
(FPCore (r a b) :precision binary64 (/ (* r b) (cos (+ b a))))
double code(double r, double a, double b) {
return (r * 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 * b) / cos((b + a))
end function
public static double code(double r, double a, double b) {
return (r * b) / Math.cos((b + a));
}
def code(r, a, b): return (r * b) / math.cos((b + a))
function code(r, a, b) return Float64(Float64(r * b) / cos(Float64(b + a))) end
function tmp = code(r, a, b) tmp = (r * b) / cos((b + a)); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos \left(b + a\right)}
\end{array}
Initial program 76.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 53.4%
Final simplification53.4%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (b / cos(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 53.1%
Final simplification53.1%
(FPCore (r a b) :precision binary64 (/ (* r b) (cos a)))
double code(double r, double a, double b) {
return (r * b) / cos(a);
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * b) / cos(a)
end function
public static double code(double r, double a, double b) {
return (r * b) / Math.cos(a);
}
def code(r, a, b): return (r * b) / math.cos(a)
function code(r, a, b) return Float64(Float64(r * b) / cos(a)) end
function tmp = code(r, a, b) tmp = (r * b) / cos(a); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos a}
\end{array}
Initial program 76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 53.1%
Final simplification53.1%
(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%
remove-double-neg76.7%
remove-double-neg76.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 B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))