
(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(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 76.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.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%
+-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)) (+ (* (sin a) (* (sin b) -2.0)) (cos (- b a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((sin(a) * (sin(b) * -2.0)) + 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)) / ((sin(a) * (sin(b) * (-2.0d0))) + cos((b - a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.sin(a) * (Math.sin(b) * -2.0)) + Math.cos((b - a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.sin(a) * (math.sin(b) * -2.0)) + math.cos((b - a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(sin(a) * Float64(sin(b) * -2.0)) + cos(Float64(b - a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((sin(a) * (sin(b) * -2.0)) + cos((b - a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[a], $MachinePrecision] * N[(N[Sin[b], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] + N[Cos[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\sin a \cdot \left(\sin b \cdot -2\right) + \cos \left(b - a\right)}
\end{array}
Initial program 76.7%
associate-*r/76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
distribute-lft-neg-out99.5%
fmm-def99.5%
add-sqr-sqrt49.4%
sqrt-unprod87.1%
sqr-neg87.1%
sqrt-unprod37.7%
add-sqr-sqrt76.6%
neg-mul-176.6%
associate-*l*76.6%
add-sqr-sqrt38.9%
sqrt-unprod89.0%
sqr-neg89.0%
sqrt-unprod50.1%
add-sqr-sqrt99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-undefine99.5%
*-commutative99.5%
neg-mul-199.5%
*-commutative99.5%
neg-mul-199.5%
distribute-neg-out99.5%
fma-undefine99.5%
fmm-undef99.5%
*-commutative99.5%
neg-mul-199.5%
distribute-lft-neg-in99.5%
cancel-sign-sub99.5%
*-commutative99.5%
Simplified99.5%
Applied egg-rr77.7%
associate-*r/77.8%
*-rgt-identity77.8%
distribute-rgt-neg-out77.8%
distribute-neg-frac77.8%
distribute-neg-frac277.8%
neg-sub077.8%
associate--r-77.8%
neg-sub077.8%
distribute-lft-neg-in77.8%
distribute-lft-neg-in77.8%
*-commutative77.8%
associate-*l*77.8%
distribute-lft-neg-in77.8%
distribute-rgt-neg-in77.8%
metadata-eval77.8%
Simplified77.8%
Final simplification77.8%
(FPCore (r a b) :precision binary64 (if (or (<= a -200000.0) (not (<= a 9.8e-6))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -200000.0) || !(a <= 9.8e-6)) {
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 <= (-200000.0d0)) .or. (.not. (a <= 9.8d-6))) 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 <= -200000.0) || !(a <= 9.8e-6)) {
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 <= -200000.0) or not (a <= 9.8e-6): 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 <= -200000.0) || !(a <= 9.8e-6)) 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 <= -200000.0) || ~((a <= 9.8e-6))) 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, -200000.0], N[Not[LessEqual[a, 9.8e-6]], $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 -200000 \lor \neg \left(a \leq 9.8 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2e5 or 9.79999999999999934e-6 < a Initial program 57.6%
+-commutative57.6%
Simplified57.6%
Taylor expanded in b around 0 58.4%
if -2e5 < a < 9.79999999999999934e-6Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.9%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (if (or (<= a -200000.0) (not (<= a 4.9e-5))) (* (sin b) (/ r (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -200000.0) || !(a <= 4.9e-5)) {
tmp = sin(b) * (r / 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 <= (-200000.0d0)) .or. (.not. (a <= 4.9d-5))) then
tmp = sin(b) * (r / 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 <= -200000.0) || !(a <= 4.9e-5)) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -200000.0) or not (a <= 4.9e-5): tmp = math.sin(b) * (r / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -200000.0) || !(a <= 4.9e-5)) tmp = Float64(sin(b) * Float64(r / 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 <= -200000.0) || ~((a <= 4.9e-5))) tmp = sin(b) * (r / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -200000.0], N[Not[LessEqual[a, 4.9e-5]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / 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 -200000 \lor \neg \left(a \leq 4.9 \cdot 10^{-5}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2e5 or 4.9e-5 < a Initial program 57.6%
+-commutative57.6%
Simplified57.6%
add-cbrt-cube34.9%
pow1/326.4%
pow326.4%
associate-*r/26.4%
*-commutative26.4%
associate-/l*26.4%
Applied egg-rr26.4%
Taylor expanded in b around 0 26.3%
unpow1/335.0%
rem-cbrt-cube58.4%
*-commutative58.4%
Applied egg-rr58.4%
if -2e5 < a < 4.9e-5Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.9%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (if (or (<= a -200000.0) (not (<= a 4.9e-5))) (/ (sin b) (/ (cos a) r)) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -200000.0) || !(a <= 4.9e-5)) {
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 <= (-200000.0d0)) .or. (.not. (a <= 4.9d-5))) 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 <= -200000.0) || !(a <= 4.9e-5)) {
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 <= -200000.0) or not (a <= 4.9e-5): 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 <= -200000.0) || !(a <= 4.9e-5)) 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 <= -200000.0) || ~((a <= 4.9e-5))) 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, -200000.0], N[Not[LessEqual[a, 4.9e-5]], $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 -200000 \lor \neg \left(a \leq 4.9 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2e5 or 4.9e-5 < a Initial program 57.6%
+-commutative57.6%
Simplified57.6%
add-cbrt-cube34.9%
pow1/326.4%
pow326.4%
associate-*r/26.4%
*-commutative26.4%
associate-/l*26.4%
Applied egg-rr26.4%
Taylor expanded in b around 0 26.3%
unpow1/335.0%
rem-cbrt-cube58.4%
clear-num58.4%
un-div-inv58.4%
Applied egg-rr58.4%
if -2e5 < a < 4.9e-5Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.9%
Final simplification77.1%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (sin b))))
(if (<= b -550000000000.0)
(fabs t_0)
(if (<= b 7800.0) (/ (* r b) (cos (+ b a))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (b <= -550000000000.0) {
tmp = fabs(t_0);
} else if (b <= 7800.0) {
tmp = (r * b) / cos((b + a));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = r * sin(b)
if (b <= (-550000000000.0d0)) then
tmp = abs(t_0)
else if (b <= 7800.0d0) then
tmp = (r * b) / cos((b + a))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = r * Math.sin(b);
double tmp;
if (b <= -550000000000.0) {
tmp = Math.abs(t_0);
} else if (b <= 7800.0) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * math.sin(b) tmp = 0 if b <= -550000000000.0: tmp = math.fabs(t_0) elif b <= 7800.0: tmp = (r * b) / math.cos((b + a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (b <= -550000000000.0) tmp = abs(t_0); elseif (b <= 7800.0) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * sin(b); tmp = 0.0; if (b <= -550000000000.0) tmp = abs(t_0); elseif (b <= 7800.0) tmp = (r * b) / cos((b + a)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -550000000000.0], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[b, 7800.0], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -550000000000:\\
\;\;\;\;\left|t\_0\right|\\
\mathbf{elif}\;b \leq 7800:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -5.5e11Initial program 52.4%
+-commutative52.4%
Simplified52.4%
add-cbrt-cube18.3%
pow1/311.0%
pow311.0%
associate-*r/11.0%
*-commutative11.0%
associate-/l*11.0%
Applied egg-rr11.0%
Taylor expanded in b around 0 3.8%
Taylor expanded in a around 0 10.9%
add-sqr-sqrt5.3%
sqrt-unprod7.7%
pow27.7%
*-commutative7.7%
Applied egg-rr7.7%
unpow27.7%
rem-sqrt-square11.1%
Simplified11.1%
if -5.5e11 < b < 7800Initial program 98.3%
associate-*r/98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in b around 0 97.4%
if 7800 < b Initial program 56.3%
+-commutative56.3%
Simplified56.3%
add-cbrt-cube24.2%
pow1/317.6%
pow317.6%
associate-*r/17.6%
*-commutative17.6%
associate-/l*17.6%
Applied egg-rr17.6%
Taylor expanded in b around 0 5.8%
Taylor expanded in a around 0 11.0%
Final simplification54.9%
(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 (* (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-*r/76.7%
+-commutative76.7%
Simplified76.7%
*-commutative76.7%
associate-/l*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(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%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 55.2%
Final simplification55.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -8500000.0) (not (<= b 7800.0))) (* r (sin b)) (* b (/ r (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -8500000.0) || !(b <= 7800.0)) {
tmp = r * sin(b);
} else {
tmp = b * (r / 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 <= (-8500000.0d0)) .or. (.not. (b <= 7800.0d0))) then
tmp = r * sin(b)
else
tmp = b * (r / cos((b + a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -8500000.0) || !(b <= 7800.0)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -8500000.0) or not (b <= 7800.0): tmp = r * math.sin(b) else: tmp = b * (r / math.cos((b + a))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -8500000.0) || !(b <= 7800.0)) tmp = Float64(r * sin(b)); else tmp = Float64(b * Float64(r / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -8500000.0) || ~((b <= 7800.0))) tmp = r * sin(b); else tmp = b * (r / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -8500000.0], N[Not[LessEqual[b, 7800.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8500000 \lor \neg \left(b \leq 7800\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -8.5e6 or 7800 < b Initial program 54.1%
+-commutative54.1%
Simplified54.1%
add-cbrt-cube21.2%
pow1/314.2%
pow314.2%
associate-*r/14.2%
*-commutative14.2%
associate-/l*14.2%
Applied egg-rr14.2%
Taylor expanded in b around 0 4.8%
Taylor expanded in a around 0 11.1%
if -8.5e6 < b < 7800Initial program 98.9%
associate-*r/98.9%
+-commutative98.9%
Simplified98.9%
add-exp-log59.1%
*-commutative59.1%
Applied egg-rr59.1%
add-sqr-sqrt42.1%
sqrt-unprod50.9%
pow250.9%
Applied egg-rr50.9%
unpow250.9%
rem-sqrt-square50.9%
+-commutative50.9%
Simplified50.9%
Taylor expanded in b around 0 79.3%
+-commutative79.3%
rem-square-sqrt70.2%
fabs-sqr70.2%
rem-square-sqrt98.1%
associate-*r/98.1%
Simplified98.1%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -23000.0) (not (<= b 4.5))) (* r (sin b)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -23000.0) || !(b <= 4.5)) {
tmp = r * sin(b);
} else {
tmp = (r * b) / cos((b + a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-23000.0d0)) .or. (.not. (b <= 4.5d0))) then
tmp = r * sin(b)
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -23000.0) || !(b <= 4.5)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -23000.0) or not (b <= 4.5): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -23000.0) || !(b <= 4.5)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -23000.0) || ~((b <= 4.5))) tmp = r * sin(b); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -23000.0], N[Not[LessEqual[b, 4.5]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -23000 \lor \neg \left(b \leq 4.5\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -23000 or 4.5 < b Initial program 54.1%
+-commutative54.1%
Simplified54.1%
add-cbrt-cube21.2%
pow1/314.2%
pow314.2%
associate-*r/14.2%
*-commutative14.2%
associate-/l*14.2%
Applied egg-rr14.2%
Taylor expanded in b around 0 4.8%
Taylor expanded in a around 0 11.1%
if -23000 < b < 4.5Initial program 98.9%
associate-*r/98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.1%
Final simplification54.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.8) (not (<= b 1.0))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8) || !(b <= 1.0)) {
tmp = r * sin(b);
} else {
tmp = b * (r / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-4.8d0)) .or. (.not. (b <= 1.0d0))) then
tmp = r * sin(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8) || !(b <= 1.0)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.8) or not (b <= 1.0): tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.8) || !(b <= 1.0)) tmp = Float64(r * sin(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.8) || ~((b <= 1.0))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.8], N[Not[LessEqual[b, 1.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \lor \neg \left(b \leq 1\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -4.79999999999999982 or 1 < b Initial program 54.4%
+-commutative54.4%
Simplified54.4%
add-cbrt-cube21.1%
pow1/314.2%
pow314.2%
associate-*r/14.2%
*-commutative14.2%
associate-/l*14.2%
Applied egg-rr14.2%
Taylor expanded in b around 0 4.9%
Taylor expanded in a around 0 11.0%
if -4.79999999999999982 < b < 1Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.7%
associate-/l*98.7%
Simplified98.7%
Final simplification54.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.8) (not (<= b 1.55))) (* r (sin b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8) || !(b <= 1.55)) {
tmp = r * sin(b);
} else {
tmp = (r * b) / cos(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-4.8d0)) .or. (.not. (b <= 1.55d0))) then
tmp = r * sin(b)
else
tmp = (r * b) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8) || !(b <= 1.55)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.8) or not (b <= 1.55): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.8) || !(b <= 1.55)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.8) || ~((b <= 1.55))) tmp = r * sin(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.8], N[Not[LessEqual[b, 1.55]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \lor \neg \left(b \leq 1.55\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -4.79999999999999982 or 1.55000000000000004 < b Initial program 54.4%
+-commutative54.4%
Simplified54.4%
add-cbrt-cube21.1%
pow1/314.2%
pow314.2%
associate-*r/14.2%
*-commutative14.2%
associate-/l*14.2%
Applied egg-rr14.2%
Taylor expanded in b around 0 4.9%
Taylor expanded in a around 0 11.0%
if -4.79999999999999982 < b < 1.55000000000000004Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.7%
Final simplification54.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 76.7%
+-commutative76.7%
Simplified76.7%
add-cbrt-cube40.2%
pow1/329.7%
pow329.7%
associate-*r/29.7%
*-commutative29.7%
associate-/l*29.7%
Applied egg-rr29.7%
Taylor expanded in b around 0 25.0%
Taylor expanded in a around 0 36.7%
Final simplification36.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%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 51.0%
associate-/l*51.0%
Simplified51.0%
Taylor expanded in a around 0 32.9%
*-commutative32.9%
Simplified32.9%
Final simplification32.9%
herbie shell --seed 2024112
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))