
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (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 75.5%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (if (<= b -850000.0) (* r (/ (sin b) (- (cos b) (* (sin b) (sin a))))) (/ (* r (sin b)) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -850000.0) {
tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a))));
} else {
tmp = (r * sin(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 <= (-850000.0d0)) then
tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a))))
else
tmp = (r * sin(b)) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -850000.0) {
tmp = r * (Math.sin(b) / (Math.cos(b) - (Math.sin(b) * Math.sin(a))));
} else {
tmp = (r * Math.sin(b)) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -850000.0: tmp = r * (math.sin(b) / (math.cos(b) - (math.sin(b) * math.sin(a)))) else: tmp = (r * math.sin(b)) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -850000.0) tmp = Float64(r * Float64(sin(b) / Float64(cos(b) - Float64(sin(b) * sin(a))))); else tmp = Float64(Float64(r * sin(b)) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -850000.0) tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a)))); else tmp = (r * sin(b)) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -850000.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -850000:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b - \sin b \cdot \sin a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -8.5e5Initial program 46.4%
associate-/l*46.4%
remove-double-neg46.4%
remove-double-neg46.4%
+-commutative46.4%
Simplified46.4%
cos-sum99.3%
Applied egg-rr99.3%
expm1-log1p-u99.2%
Applied egg-rr99.2%
Taylor expanded in a around 0 52.7%
if -8.5e5 < b Initial program 85.7%
Final simplification77.2%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00047) (not (<= a 0.00043))) (* r (/ (sin b) (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00047) || !(a <= 0.00043)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = sin(b) * (r / 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 <= (-0.00047d0)) .or. (.not. (a <= 0.00043d0))) then
tmp = r * (sin(b) / cos(a))
else
tmp = sin(b) * (r / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00047) || !(a <= 0.00043)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.00047) or not (a <= 0.00043): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.00047) || !(a <= 0.00043)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.00047) || ~((a <= 0.00043))) tmp = r * (sin(b) / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.00047], N[Not[LessEqual[a, 0.00043]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00047 \lor \neg \left(a \leq 0.00043\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -4.69999999999999986e-4 or 4.29999999999999989e-4 < a Initial program 52.8%
associate-/l*52.8%
remove-double-neg52.8%
remove-double-neg52.8%
+-commutative52.8%
Simplified52.8%
Taylor expanded in b around 0 53.6%
if -4.69999999999999986e-4 < a < 4.29999999999999989e-4Initial program 98.6%
associate-/l*98.6%
remove-double-neg98.6%
remove-double-neg98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in a around 0 98.6%
*-commutative98.6%
associate-/l*98.6%
Simplified98.6%
Final simplification75.9%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00028) (not (<= a 4.7e-5))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00028) || !(a <= 4.7e-5)) {
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 <= (-0.00028d0)) .or. (.not. (a <= 4.7d-5))) 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 <= -0.00028) || !(a <= 4.7e-5)) {
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 <= -0.00028) or not (a <= 4.7e-5): 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 <= -0.00028) || !(a <= 4.7e-5)) 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 <= -0.00028) || ~((a <= 4.7e-5))) 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, -0.00028], N[Not[LessEqual[a, 4.7e-5]], $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 -0.00028 \lor \neg \left(a \leq 4.7 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2.7999999999999998e-4 or 4.69999999999999972e-5 < a Initial program 52.8%
associate-/l*52.8%
remove-double-neg52.8%
remove-double-neg52.8%
+-commutative52.8%
Simplified52.8%
Taylor expanded in b around 0 53.6%
if -2.7999999999999998e-4 < a < 4.69999999999999972e-5Initial program 98.6%
associate-/l*98.6%
remove-double-neg98.6%
remove-double-neg98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in a around 0 98.6%
Final simplification75.9%
(FPCore (r a b) :precision binary64 (if (<= a -0.00029) (/ (* r (sin b)) (cos a)) (if (<= a 7e-5) (* (sin b) (/ r (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00029) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 7e-5) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = r * (sin(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 (a <= (-0.00029d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 7d-5) then
tmp = sin(b) * (r / cos(b))
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.00029) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 7e-5) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.00029: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 7e-5: tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.00029) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 7e-5) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.00029) tmp = (r * sin(b)) / cos(a); elseif (a <= 7e-5) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.00029], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7e-5], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00029:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 7 \cdot 10^{-5}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -2.9e-4Initial program 53.2%
+-commutative53.2%
Simplified53.2%
Taylor expanded in b around 0 54.2%
if -2.9e-4 < a < 6.9999999999999994e-5Initial program 98.6%
associate-/l*98.6%
remove-double-neg98.6%
remove-double-neg98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in a around 0 98.6%
*-commutative98.6%
associate-/l*98.6%
Simplified98.6%
if 6.9999999999999994e-5 < a Initial program 52.5%
associate-/l*52.6%
remove-double-neg52.6%
remove-double-neg52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in b around 0 53.2%
(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 75.5%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
(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 75.5%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in b around 0 53.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.8) (not (<= b 17.0))) (* r (sin b)) (* r (/ b (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8) || !(b <= 17.0)) {
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 <= (-4.8d0)) .or. (.not. (b <= 17.0d0))) 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 <= -4.8) || !(b <= 17.0)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.8) or not (b <= 17.0): 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 <= -4.8) || !(b <= 17.0)) tmp = Float64(r * sin(b)); else tmp = Float64(r * Float64(b / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.8) || ~((b <= 17.0))) tmp = r * sin(b); else tmp = r * (b / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.8], N[Not[LessEqual[b, 17.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \lor \neg \left(b \leq 17\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -4.79999999999999982 or 17 < b Initial program 53.5%
associate-/l*53.5%
remove-double-neg53.5%
remove-double-neg53.5%
+-commutative53.5%
Simplified53.5%
Taylor expanded in a around 0 54.1%
*-commutative54.1%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in b around 0 11.6%
if -4.79999999999999982 < b < 17Initial program 99.0%
associate-/l*99.0%
remove-double-neg99.0%
remove-double-neg99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 98.1%
Final simplification53.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -55.0) (not (<= b 11.0))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -55.0) || !(b <= 11.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 <= (-55.0d0)) .or. (.not. (b <= 11.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 <= -55.0) || !(b <= 11.0)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -55.0) or not (b <= 11.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 <= -55.0) || !(b <= 11.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 <= -55.0) || ~((b <= 11.0))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -55.0], N[Not[LessEqual[b, 11.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 -55 \lor \neg \left(b \leq 11\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -55 or 11 < b Initial program 53.5%
associate-/l*53.5%
remove-double-neg53.5%
remove-double-neg53.5%
+-commutative53.5%
Simplified53.5%
Taylor expanded in a around 0 54.1%
*-commutative54.1%
associate-/l*54.1%
Simplified54.1%
Taylor expanded in b around 0 11.6%
if -55 < b < 11Initial program 99.0%
associate-/l*99.0%
remove-double-neg99.0%
remove-double-neg99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 98.0%
associate-/l*98.0%
Simplified98.0%
Final simplification53.4%
(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 75.5%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in a around 0 58.7%
*-commutative58.7%
associate-/l*58.7%
Simplified58.7%
Taylor expanded in b around 0 36.3%
Final simplification36.3%
(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 75.5%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in b around 0 49.6%
associate-/l*49.6%
Simplified49.6%
Taylor expanded in a around 0 32.5%
Final simplification32.5%
herbie shell --seed 2024132
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))