
(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 14 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 74.7%
associate-*r/74.7%
+-commutative74.7%
Simplified74.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(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 74.7%
associate-*r/74.7%
+-commutative74.7%
Simplified74.7%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 74.7%
+-commutative74.7%
Simplified74.7%
cos-sum99.5%
Applied egg-rr99.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.1e-6) (not (<= b 175.0))) (* r (/ (sin b) (cos b))) (* (sin b) (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.1e-6) || !(b <= 175.0)) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = sin(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 <= (-1.1d-6)) .or. (.not. (b <= 175.0d0))) then
tmp = r * (sin(b) / cos(b))
else
tmp = sin(b) * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -1.1e-6) || !(b <= 175.0)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.1e-6) or not (b <= 175.0): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.1e-6) || !(b <= 175.0)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(sin(b) * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.1e-6) || ~((b <= 175.0))) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.1e-6], N[Not[LessEqual[b, 175.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.1 \cdot 10^{-6} \lor \neg \left(b \leq 175\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.1000000000000001e-6 or 175 < b Initial program 53.2%
+-commutative53.2%
Simplified53.2%
Taylor expanded in a around 0 53.6%
associate-/l*53.6%
Simplified53.6%
if -1.1000000000000001e-6 < b < 175Initial program 97.7%
associate-*r/97.7%
+-commutative97.7%
Simplified97.7%
expm1-log1p-u97.7%
expm1-undefine32.3%
Applied egg-rr32.3%
expm1-define97.7%
Simplified97.7%
add-sqr-sqrt53.9%
sqrt-unprod55.2%
pow255.2%
Applied egg-rr55.2%
unpow255.2%
rem-sqrt-square69.0%
Simplified69.0%
Taylor expanded in b around 0 69.0%
*-commutative69.0%
associate-/l*69.0%
add-sqr-sqrt53.9%
fabs-sqr53.9%
add-sqr-sqrt97.7%
expm1-log1p-u97.7%
Applied egg-rr97.7%
Final simplification74.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.1e-6) (not (<= b 1.45))) (* r (/ (sin b) (cos b))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.1e-6) || !(b <= 1.45)) {
tmp = r * (sin(b) / cos(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 <= (-1.1d-6)) .or. (.not. (b <= 1.45d0))) then
tmp = r * (sin(b) / cos(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 <= -1.1e-6) || !(b <= 1.45)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.1e-6) or not (b <= 1.45): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.1e-6) || !(b <= 1.45)) tmp = Float64(r * Float64(sin(b) / cos(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 <= -1.1e-6) || ~((b <= 1.45))) tmp = r * (sin(b) / cos(b)); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.1e-6], N[Not[LessEqual[b, 1.45]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.1 \cdot 10^{-6} \lor \neg \left(b \leq 1.45\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.1000000000000001e-6 or 1.44999999999999996 < b Initial program 52.8%
+-commutative52.8%
Simplified52.8%
Taylor expanded in a around 0 53.2%
associate-/l*53.2%
Simplified53.2%
if -1.1000000000000001e-6 < b < 1.44999999999999996Initial program 98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in b around 0 98.4%
associate-/l*98.5%
Simplified98.5%
Final simplification74.9%
(FPCore (r a b) :precision binary64 (if (<= b -1.1e-6) (* (sin b) (/ r (cos b))) (if (<= b 175.0) (* (sin b) (/ r (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.1e-6) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 175.0) {
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 (b <= (-1.1d-6)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 175.0d0) 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 (b <= -1.1e-6) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 175.0) {
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 b <= -1.1e-6: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 175.0: 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 (b <= -1.1e-6) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 175.0) 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 (b <= -1.1e-6) tmp = sin(b) * (r / cos(b)); elseif (b <= 175.0) tmp = sin(b) * (r / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.1e-6], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 175.0], 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}\;b \leq -1.1 \cdot 10^{-6}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 175:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -1.1000000000000001e-6Initial program 54.8%
+-commutative54.8%
Simplified54.8%
associate-*r/54.9%
clear-num54.8%
Applied egg-rr54.8%
Taylor expanded in a around 0 54.3%
clear-num54.4%
*-commutative54.4%
associate-/l*54.4%
Applied egg-rr54.4%
if -1.1000000000000001e-6 < b < 175Initial program 97.7%
associate-*r/97.7%
+-commutative97.7%
Simplified97.7%
expm1-log1p-u97.7%
expm1-undefine32.3%
Applied egg-rr32.3%
expm1-define97.7%
Simplified97.7%
add-sqr-sqrt53.9%
sqrt-unprod55.2%
pow255.2%
Applied egg-rr55.2%
unpow255.2%
rem-sqrt-square69.0%
Simplified69.0%
Taylor expanded in b around 0 69.0%
*-commutative69.0%
associate-/l*69.0%
add-sqr-sqrt53.9%
fabs-sqr53.9%
add-sqr-sqrt97.7%
expm1-log1p-u97.7%
Applied egg-rr97.7%
if 175 < b Initial program 51.2%
+-commutative51.2%
Simplified51.2%
Taylor expanded in a around 0 52.6%
associate-/l*52.6%
Simplified52.6%
(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}
Initial program 74.7%
associate-*r/74.7%
+-commutative74.7%
Simplified74.7%
cos-sum99.5%
sub-neg99.5%
Applied egg-rr99.5%
+-commutative99.5%
distribute-rgt-neg-in99.5%
fma-define99.5%
*-commutative99.5%
Simplified99.5%
associate-/l*99.5%
*-commutative99.5%
fma-undefine99.4%
+-commutative99.4%
*-commutative99.4%
add-sqr-sqrt48.5%
sqrt-unprod86.9%
sqr-neg86.9%
sqrt-unprod38.4%
add-sqr-sqrt75.0%
cos-diff74.8%
Applied egg-rr74.8%
Final simplification74.8%
(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 74.7%
associate-*r/74.7%
+-commutative74.7%
Simplified74.7%
*-commutative74.7%
associate-/l*74.7%
Applied egg-rr74.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 74.7%
Final simplification74.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 74.7%
+-commutative74.7%
Simplified74.7%
Taylor expanded in b around 0 53.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.75) (not (<= b 1.1))) (/ 1.0 (/ 1.0 (* r (sin b)))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.75) || !(b <= 1.1)) {
tmp = 1.0 / (1.0 / (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 <= (-0.75d0)) .or. (.not. (b <= 1.1d0))) then
tmp = 1.0d0 / (1.0d0 / (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 <= -0.75) || !(b <= 1.1)) {
tmp = 1.0 / (1.0 / (r * Math.sin(b)));
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.75) or not (b <= 1.1): tmp = 1.0 / (1.0 / (r * math.sin(b))) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.75) || !(b <= 1.1)) tmp = Float64(1.0 / Float64(1.0 / 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 <= -0.75) || ~((b <= 1.1))) tmp = 1.0 / (1.0 / (r * sin(b))); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.75], N[Not[LessEqual[b, 1.1]], $MachinePrecision]], N[(1.0 / N[(1.0 / N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.75 \lor \neg \left(b \leq 1.1\right):\\
\;\;\;\;\frac{1}{\frac{1}{r \cdot \sin b}}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -0.75 or 1.1000000000000001 < b Initial program 52.1%
+-commutative52.1%
Simplified52.1%
associate-*r/52.1%
clear-num52.1%
Applied egg-rr52.1%
Taylor expanded in a around 0 52.4%
Taylor expanded in b around 0 12.4%
if -0.75 < b < 1.1000000000000001Initial program 99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in b around 0 99.1%
associate-/l*99.1%
Simplified99.1%
Final simplification54.1%
(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 74.7%
+-commutative74.7%
Simplified74.7%
Taylor expanded in b around 0 49.8%
(FPCore (r a b) :precision binary64 (* b (/ r (cos a))))
double code(double r, double a, double b) {
return 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 = b * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return b * (r / Math.cos(a));
}
def code(r, a, b): return b * (r / math.cos(a))
function code(r, a, b) return Float64(b * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = b * (r / cos(a)); end
code[r_, a_, b_] := N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{r}{\cos a}
\end{array}
Initial program 74.7%
+-commutative74.7%
Simplified74.7%
Taylor expanded in b around 0 49.6%
associate-/l*49.6%
Simplified49.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 74.7%
+-commutative74.7%
Simplified74.7%
Taylor expanded in b around 0 49.6%
associate-/l*49.6%
Simplified49.6%
Taylor expanded in a around 0 35.5%
*-commutative35.5%
Simplified35.5%
herbie shell --seed 2024165
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))