
(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
(let* ((t_0 (* (sin a) (sin b))))
(*
(sin b)
(/ r (+ (fma (- (sin b)) (sin a) t_0) (- (* (cos a) (cos b)) t_0))))))
double code(double r, double a, double b) {
double t_0 = sin(a) * sin(b);
return sin(b) * (r / (fma(-sin(b), sin(a), t_0) + ((cos(a) * cos(b)) - t_0)));
}
function code(r, a, b) t_0 = Float64(sin(a) * sin(b)) return Float64(sin(b) * Float64(r / Float64(fma(Float64(-sin(b)), sin(a), t_0) + Float64(Float64(cos(a) * cos(b)) - t_0)))) end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin a \cdot \sin b\\
\sin b \cdot \frac{r}{\mathsf{fma}\left(-\sin b, \sin a, t_0\right) + \left(\cos a \cdot \cos b - t_0\right)}
\end{array}
\end{array}
Initial program 79.8%
associate-*r/79.8%
/-rgt-identity79.8%
metadata-eval79.8%
associate-/l/79.8%
associate-*l/79.9%
associate-/l/79.9%
metadata-eval79.9%
metadata-eval79.9%
metadata-eval79.9%
/-rgt-identity79.9%
+-commutative79.9%
Simplified79.9%
cos-sum99.5%
*-un-lft-identity99.5%
prod-diff99.5%
Applied egg-rr99.5%
*-rgt-identity99.5%
fma-neg99.5%
*-commutative99.5%
*-commutative99.5%
fma-udef99.5%
*-rgt-identity99.5%
distribute-lft-neg-in99.5%
*-rgt-identity99.5%
fma-udef99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin a) (sin b))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(a) * cos(b)) - (sin(a) * 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) / ((cos(a) * cos(b)) - (sin(a) * sin(b))))
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(a) * Math.sin(b))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(a) * math.sin(b))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(a) * sin(b))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(a) * sin(b)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin a \cdot \sin b}
\end{array}
Initial program 79.8%
+-commutative79.8%
Simplified79.8%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos a) (cos b)) (* (sin a) (sin b))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((cos(a) * cos(b)) - (sin(a) * 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 = sin(b) * (r / ((cos(a) * cos(b)) - (sin(a) * sin(b))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(a) * Math.cos(b)) - (Math.sin(a) * Math.sin(b))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(a) * math.cos(b)) - (math.sin(a) * math.sin(b))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(a) * cos(b)) - Float64(sin(a) * sin(b))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(a) * cos(b)) - (sin(a) * sin(b)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a \cdot \cos b - \sin a \cdot \sin b}
\end{array}
Initial program 79.8%
associate-*r/79.8%
/-rgt-identity79.8%
metadata-eval79.8%
associate-/l/79.8%
associate-*l/79.9%
associate-/l/79.9%
metadata-eval79.9%
metadata-eval79.9%
metadata-eval79.9%
/-rgt-identity79.9%
+-commutative79.9%
Simplified79.9%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (cos (+ a b)) (* (sin a) (sin b))))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos((a + b)) - (sin(a) * 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) / (cos((a + b)) - (sin(a) * sin(b))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos((a + b)) - (Math.sin(a) * Math.sin(b))));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos((a + b)) - (math.sin(a) * math.sin(b))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(Float64(a + b)) - Float64(sin(a) * sin(b))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos((a + b)) - (sin(a) * sin(b)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(a + b\right) - \sin a \cdot \sin b}
\end{array}
Initial program 79.8%
+-commutative79.8%
Simplified79.8%
add-log-exp79.5%
Applied egg-rr79.5%
rem-log-exp79.8%
cos-sum99.5%
Applied egg-rr80.9%
Final simplification80.9%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos(a) * cos(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) * cos(b)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos(a) * Math.cos(b)));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos(a) * math.cos(b)))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(a) * cos(b)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos(a) * cos(b))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b}
\end{array}
Initial program 79.8%
+-commutative79.8%
Simplified79.8%
add-log-exp79.5%
Applied egg-rr79.5%
add-sqr-sqrt79.3%
sqrt-unprod79.5%
prod-exp79.5%
cos-sum80.5%
cancel-sign-sub-inv80.5%
add-sqr-sqrt39.5%
sqrt-unprod79.9%
sqr-neg79.9%
sqrt-unprod40.4%
add-sqr-sqrt78.7%
cos-diff79.2%
exp-sqrt79.2%
Applied egg-rr80.3%
Final simplification80.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -7.6e+15) (not (<= b 2.2e-7))) (* r (/ (sin b) (cos b))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -7.6e+15) || !(b <= 2.2e-7)) {
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 <= (-7.6d+15)) .or. (.not. (b <= 2.2d-7))) 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 <= -7.6e+15) || !(b <= 2.2e-7)) {
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 <= -7.6e+15) or not (b <= 2.2e-7): 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 <= -7.6e+15) || !(b <= 2.2e-7)) 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 <= -7.6e+15) || ~((b <= 2.2e-7))) 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, -7.6e+15], N[Not[LessEqual[b, 2.2e-7]], $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 -7.6 \cdot 10^{+15} \lor \neg \left(b \leq 2.2 \cdot 10^{-7}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -7.6e15 or 2.2000000000000001e-7 < b Initial program 55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in a around 0 54.7%
if -7.6e15 < b < 2.2000000000000001e-7Initial program 97.9%
associate-*r/97.9%
/-rgt-identity97.9%
metadata-eval97.9%
associate-/l/97.9%
associate-*l/98.0%
associate-/l/98.0%
metadata-eval98.0%
metadata-eval98.0%
metadata-eval98.0%
/-rgt-identity98.0%
+-commutative98.0%
Simplified98.0%
cos-sum99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 97.9%
associate-*r/97.9%
Simplified97.9%
Final simplification79.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -7.6e+15) (not (<= b 2.3e-7))) (* r (/ (sin b) (cos b))) (* (sin b) (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -7.6e+15) || !(b <= 2.3e-7)) {
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 <= (-7.6d+15)) .or. (.not. (b <= 2.3d-7))) 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 <= -7.6e+15) || !(b <= 2.3e-7)) {
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 <= -7.6e+15) or not (b <= 2.3e-7): 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 <= -7.6e+15) || !(b <= 2.3e-7)) 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 <= -7.6e+15) || ~((b <= 2.3e-7))) 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, -7.6e+15], N[Not[LessEqual[b, 2.3e-7]], $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 -7.6 \cdot 10^{+15} \lor \neg \left(b \leq 2.3 \cdot 10^{-7}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -7.6e15 or 2.29999999999999995e-7 < b Initial program 55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in a around 0 54.7%
if -7.6e15 < b < 2.29999999999999995e-7Initial program 97.9%
associate-*r/97.9%
/-rgt-identity97.9%
metadata-eval97.9%
associate-/l/97.9%
associate-*l/98.0%
associate-/l/98.0%
metadata-eval98.0%
metadata-eval98.0%
metadata-eval98.0%
/-rgt-identity98.0%
+-commutative98.0%
Simplified98.0%
Taylor expanded in b around 0 98.0%
Final simplification79.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -7.6e+15) (not (<= b 2.3e-7))) (* (sin b) (/ r (cos b))) (* (sin b) (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -7.6e+15) || !(b <= 2.3e-7)) {
tmp = sin(b) * (r / 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 <= (-7.6d+15)) .or. (.not. (b <= 2.3d-7))) then
tmp = sin(b) * (r / 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 <= -7.6e+15) || !(b <= 2.3e-7)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -7.6e+15) or not (b <= 2.3e-7): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -7.6e+15) || !(b <= 2.3e-7)) tmp = Float64(sin(b) * Float64(r / 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 <= -7.6e+15) || ~((b <= 2.3e-7))) tmp = sin(b) * (r / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -7.6e+15], N[Not[LessEqual[b, 2.3e-7]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / 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 -7.6 \cdot 10^{+15} \lor \neg \left(b \leq 2.3 \cdot 10^{-7}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -7.6e15 or 2.29999999999999995e-7 < b Initial program 55.0%
associate-*r/55.0%
/-rgt-identity55.0%
metadata-eval55.0%
associate-/l/55.0%
associate-*l/55.1%
associate-/l/55.1%
metadata-eval55.1%
metadata-eval55.1%
metadata-eval55.1%
/-rgt-identity55.1%
+-commutative55.1%
Simplified55.1%
Taylor expanded in a around 0 54.8%
if -7.6e15 < b < 2.29999999999999995e-7Initial program 97.9%
associate-*r/97.9%
/-rgt-identity97.9%
metadata-eval97.9%
associate-/l/97.9%
associate-*l/98.0%
associate-/l/98.0%
metadata-eval98.0%
metadata-eval98.0%
metadata-eval98.0%
/-rgt-identity98.0%
+-commutative98.0%
Simplified98.0%
Taylor expanded in b around 0 98.0%
Final simplification79.8%
(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 79.8%
Final simplification79.8%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ a b)))))
double code(double r, double a, double b) {
return sin(b) * (r / 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 = sin(b) * (r / cos((a + b)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((a + b)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((a + b)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(a + b)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((a + b))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(a + b\right)}
\end{array}
Initial program 79.8%
+-commutative79.8%
Simplified79.8%
clear-num79.7%
associate-/r/79.8%
Applied egg-rr79.8%
Taylor expanded in r around 0 79.8%
Simplified79.9%
Final simplification79.9%
(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 79.8%
+-commutative79.8%
Simplified79.8%
Taylor expanded in b around 0 62.3%
Final simplification62.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.6e+20) (not (<= b 9000.0))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.6e+20) || !(b <= 9000.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 <= (-1.6d+20)) .or. (.not. (b <= 9000.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 <= -1.6e+20) || !(b <= 9000.0)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.6e+20) or not (b <= 9000.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 <= -1.6e+20) || !(b <= 9000.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 <= -1.6e+20) || ~((b <= 9000.0))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.6e+20], N[Not[LessEqual[b, 9000.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 -1.6 \cdot 10^{+20} \lor \neg \left(b \leq 9000\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.6e20 or 9e3 < b Initial program 54.5%
+-commutative54.5%
Simplified54.5%
clear-num54.5%
associate-/r/54.5%
Applied egg-rr54.5%
Taylor expanded in b around 0 11.8%
Taylor expanded in a around 0 12.9%
if -1.6e20 < b < 9e3Initial program 96.8%
associate-*r/96.8%
/-rgt-identity96.8%
metadata-eval96.8%
associate-/l/96.8%
associate-*l/96.9%
associate-/l/96.9%
metadata-eval96.9%
metadata-eval96.9%
metadata-eval96.9%
/-rgt-identity96.9%
+-commutative96.9%
Simplified96.9%
cos-sum99.7%
Applied egg-rr99.7%
Taylor expanded in b around 0 96.4%
associate-*r/96.4%
Simplified96.4%
Final simplification62.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 79.8%
+-commutative79.8%
Simplified79.8%
clear-num79.7%
associate-/r/79.8%
Applied egg-rr79.8%
Taylor expanded in b around 0 62.3%
Taylor expanded in a around 0 42.9%
Final simplification42.9%
(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 79.8%
+-commutative79.8%
Simplified79.8%
Taylor expanded in b around 0 59.2%
Taylor expanded in a around 0 39.3%
Final simplification39.3%
herbie shell --seed 2024010
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))