
(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 12 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)) (fma (sin b) (- (sin a)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(b), -sin(a), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(b), Float64(-sin(a)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 76.3%
+-commutative76.3%
Simplified76.3%
cos-sum99.5%
sub-neg99.5%
Applied egg-rr99.5%
+-commutative99.5%
distribute-rgt-neg-in99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (sin b) (/ (- (* (cos a) (cos b)) (* (sin b) (sin a))) r)))
double code(double r, double a, double b) {
return sin(b) / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / r);
}
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) / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / r)
end function
public static double code(double r, double a, double b) {
return Math.sin(b) / (((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))) / r);
}
def code(r, a, b): return math.sin(b) / (((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))) / r)
function code(r, a, b) return Float64(sin(b) / Float64(Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))) / r)) end
function tmp = code(r, a, b) tmp = sin(b) / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / r); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\frac{\cos a \cdot \cos b - \sin b \cdot \sin a}{r}}
\end{array}
Initial program 76.3%
*-commutative76.3%
associate-/l*76.2%
+-commutative76.2%
Simplified76.2%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos a) (cos b)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(a) * cos(b)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(a) * cos(b)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 76.3%
+-commutative76.3%
Simplified76.3%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00013) (not (<= a 5.6e+19))) (* (sin b) (/ r (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00013) || !(a <= 5.6e+19)) {
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 <= (-0.00013d0)) .or. (.not. (a <= 5.6d+19))) 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 <= -0.00013) || !(a <= 5.6e+19)) {
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 <= -0.00013) or not (a <= 5.6e+19): 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 <= -0.00013) || !(a <= 5.6e+19)) 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 <= -0.00013) || ~((a <= 5.6e+19))) 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, -0.00013], N[Not[LessEqual[a, 5.6e+19]], $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 -0.00013 \lor \neg \left(a \leq 5.6 \cdot 10^{+19}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -1.29999999999999989e-4 or 5.6e19 < a Initial program 53.9%
*-commutative53.9%
associate-/l*53.9%
+-commutative53.9%
Simplified53.9%
add-cube-cbrt53.4%
pow353.4%
Applied egg-rr53.4%
Taylor expanded in b around 0 23.2%
Taylor expanded in b around inf 53.4%
associate-*r/53.4%
*-commutative53.4%
Simplified53.4%
if -1.29999999999999989e-4 < a < 5.6e19Initial program 96.0%
*-commutative96.0%
associate-/l*95.9%
+-commutative95.9%
Simplified95.9%
Taylor expanded in a around 0 96.0%
associate-/l*95.9%
associate-/r/96.1%
Simplified96.1%
Final simplification76.1%
(FPCore (r a b) :precision binary64 (if (<= a -2.05e-5) (/ (sin b) (/ (cos a) r)) (if (<= a 5.6e+19) (* r (/ (sin b) (cos b))) (* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -2.05e-5) {
tmp = sin(b) / (cos(a) / r);
} else if (a <= 5.6e+19) {
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 (a <= (-2.05d-5)) then
tmp = sin(b) / (cos(a) / r)
else if (a <= 5.6d+19) 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 (a <= -2.05e-5) {
tmp = Math.sin(b) / (Math.cos(a) / r);
} else if (a <= 5.6e+19) {
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 a <= -2.05e-5: tmp = math.sin(b) / (math.cos(a) / r) elif a <= 5.6e+19: 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 (a <= -2.05e-5) tmp = Float64(sin(b) / Float64(cos(a) / r)); elseif (a <= 5.6e+19) 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 (a <= -2.05e-5) tmp = sin(b) / (cos(a) / r); elseif (a <= 5.6e+19) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -2.05e-5], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.6e+19], 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}\;a \leq -2.05 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\mathbf{elif}\;a \leq 5.6 \cdot 10^{+19}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -2.05000000000000002e-5Initial program 56.4%
*-commutative56.4%
associate-/l*56.4%
+-commutative56.4%
Simplified56.4%
Taylor expanded in b around 0 55.8%
if -2.05000000000000002e-5 < a < 5.6e19Initial program 96.0%
*-commutative96.0%
associate-/l*95.9%
+-commutative95.9%
Simplified95.9%
Taylor expanded in a around 0 96.0%
associate-/l*95.9%
associate-/r/96.1%
Simplified96.1%
if 5.6e19 < a Initial program 51.4%
*-commutative51.4%
associate-/l*51.4%
+-commutative51.4%
Simplified51.4%
add-cube-cbrt50.8%
pow350.7%
Applied egg-rr50.7%
Taylor expanded in b around 0 24.0%
Taylor expanded in b around inf 51.1%
associate-*r/51.1%
*-commutative51.1%
Simplified51.1%
Final simplification76.1%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (sin b)))) (if (<= b -11.0) t_0 (if (<= b 1.55) (* r (/ b (cos a))) (fabs t_0)))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (b <= -11.0) {
tmp = t_0;
} else if (b <= 1.55) {
tmp = r * (b / cos(a));
} else {
tmp = fabs(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 <= (-11.0d0)) then
tmp = t_0
else if (b <= 1.55d0) then
tmp = r * (b / cos(a))
else
tmp = abs(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 <= -11.0) {
tmp = t_0;
} else if (b <= 1.55) {
tmp = r * (b / Math.cos(a));
} else {
tmp = Math.abs(t_0);
}
return tmp;
}
def code(r, a, b): t_0 = r * math.sin(b) tmp = 0 if b <= -11.0: tmp = t_0 elif b <= 1.55: tmp = r * (b / math.cos(a)) else: tmp = math.fabs(t_0) return tmp
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (b <= -11.0) tmp = t_0; elseif (b <= 1.55) tmp = Float64(r * Float64(b / cos(a))); else tmp = abs(t_0); end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * sin(b); tmp = 0.0; if (b <= -11.0) tmp = t_0; elseif (b <= 1.55) tmp = r * (b / cos(a)); else tmp = abs(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, -11.0], t$95$0, If[LessEqual[b, 1.55], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[t$95$0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -11:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 1.55:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\left|t_0\right|\\
\end{array}
\end{array}
if b < -11Initial program 56.7%
*-commutative56.7%
associate-/l*56.7%
+-commutative56.7%
Simplified56.7%
add-cube-cbrt55.8%
pow355.9%
Applied egg-rr55.9%
Taylor expanded in b around 0 7.1%
Taylor expanded in a around 0 13.0%
if -11 < b < 1.55000000000000004Initial program 99.1%
*-commutative99.1%
associate-/l*99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 97.7%
associate-/l*97.5%
Simplified97.5%
associate-/r/97.7%
Applied egg-rr97.7%
if 1.55000000000000004 < b Initial program 56.8%
*-commutative56.8%
associate-/l*57.0%
+-commutative57.0%
Simplified57.0%
associate-/l*56.8%
*-commutative56.8%
add-sqr-sqrt29.6%
sqrt-unprod19.9%
pow219.9%
associate-/l*19.9%
associate-/r/19.9%
*-commutative19.9%
Applied egg-rr19.9%
unpow219.9%
rem-sqrt-square32.4%
+-commutative32.4%
Simplified32.4%
Taylor expanded in b around 0 11.7%
Taylor expanded in a around 0 12.6%
Final simplification52.0%
(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.3%
*-commutative76.3%
associate-/l*76.2%
+-commutative76.2%
Simplified76.2%
clear-num75.8%
associate-/r/76.2%
clear-num76.3%
Applied egg-rr76.3%
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.3%
*-commutative76.3%
associate-/l*76.2%
+-commutative76.2%
Simplified76.2%
associate-/r/76.4%
Applied egg-rr76.4%
Final simplification76.4%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(b) * (r / cos(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 76.3%
*-commutative76.3%
associate-/l*76.2%
+-commutative76.2%
Simplified76.2%
add-cube-cbrt75.2%
pow375.2%
Applied egg-rr75.2%
Taylor expanded in b around 0 22.4%
Taylor expanded in b around inf 51.4%
associate-*r/51.4%
*-commutative51.4%
Simplified51.4%
Final simplification51.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.8) (not (<= b 1.5))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8) || !(b <= 1.5)) {
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.5d0))) 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.5)) {
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.5): 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.5)) tmp = Float64(r * sin(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.8) || ~((b <= 1.5))) 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.5]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \lor \neg \left(b \leq 1.5\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.79999999999999982 or 1.5 < b Initial program 56.8%
*-commutative56.8%
associate-/l*56.8%
+-commutative56.8%
Simplified56.8%
add-cube-cbrt56.0%
pow356.0%
Applied egg-rr56.0%
Taylor expanded in b around 0 6.7%
Taylor expanded in a around 0 12.4%
if -4.79999999999999982 < b < 1.5Initial program 99.1%
*-commutative99.1%
associate-/l*99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 97.7%
associate-/l*97.5%
Simplified97.5%
associate-/r/97.7%
Applied egg-rr97.7%
Final simplification51.7%
(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.3%
*-commutative76.3%
associate-/l*76.2%
+-commutative76.2%
Simplified76.2%
add-cube-cbrt75.2%
pow375.2%
Applied egg-rr75.2%
Taylor expanded in b around 0 22.4%
Taylor expanded in a around 0 37.3%
Final simplification37.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 76.3%
*-commutative76.3%
associate-/l*76.2%
+-commutative76.2%
Simplified76.2%
Taylor expanded in b around 0 46.8%
*-commutative46.8%
associate-/l*46.7%
associate-/r/46.8%
Simplified46.8%
Taylor expanded in a around 0 32.6%
Final simplification32.6%
herbie shell --seed 2023274
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))