
(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 13 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 (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 75.5%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (/ r (- (/ (* (cos a) (cos b)) (sin b)) (sin a))))
double code(double r, double a, double b) {
return r / (((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 / (((cos(a) * cos(b)) / sin(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / (((Math.cos(a) * Math.cos(b)) / Math.sin(b)) - Math.sin(a));
}
def code(r, a, b): return r / (((math.cos(a) * math.cos(b)) / math.sin(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(a) * cos(b)) / sin(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / (((cos(a) * cos(b)) / sin(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a \cdot \cos b}{\sin b} - \sin a}
\end{array}
Initial program 75.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6475.4
Applied rewrites75.4%
lift-/.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in a around inf
lower-sin.f6499.5
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (* r (/ 1.0 (- (/ (cos a) (tan b)) (sin a)))))
double code(double r, double a, double b) {
return r * (1.0 / ((cos(a) / tan(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 * (1.0d0 / ((cos(a) / tan(b)) - sin(a)))
end function
public static double code(double r, double a, double b) {
return r * (1.0 / ((Math.cos(a) / Math.tan(b)) - Math.sin(a)));
}
def code(r, a, b): return r * (1.0 / ((math.cos(a) / math.tan(b)) - math.sin(a)))
function code(r, a, b) return Float64(r * Float64(1.0 / Float64(Float64(cos(a) / tan(b)) - sin(a)))) end
function tmp = code(r, a, b) tmp = r * (1.0 / ((cos(a) / tan(b)) - sin(a))); end
code[r_, a_, b_] := N[(r * N[(1.0 / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{1}{\frac{\cos a}{\tan b} - \sin a}
\end{array}
Initial program 75.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6475.4
Applied rewrites75.4%
lift-/.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in a around inf
lower-sin.f6499.5
Applied rewrites99.5%
lift-/.f64N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
lower-neg.f64N/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
lower-/.f6499.4
Applied rewrites99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (/ (cos a) (tan b)) (sin a))))
double code(double r, double a, double b) {
return r / ((cos(a) / tan(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 / ((cos(a) / tan(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) / Math.tan(b)) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(a) / math.tan(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / tan(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / tan(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\tan b} - \sin a}
\end{array}
Initial program 75.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6475.4
Applied rewrites75.4%
lift-/.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in a around inf
lower-sin.f6499.5
Applied rewrites99.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6499.5
Applied rewrites99.5%
(FPCore (r a b)
:precision binary64
(if (or (<= b -0.36) (not (<= b 0.055)))
(* (/ r (cos b)) (sin b))
(/
(*
(*
r
(fma
(fma 0.008333333333333333 (* b b) -0.16666666666666666)
(* b b)
1.0))
b)
(cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.36) || !(b <= 0.055)) {
tmp = (r / cos(b)) * sin(b);
} else {
tmp = ((r * fma(fma(0.008333333333333333, (b * b), -0.16666666666666666), (b * b), 1.0)) * b) / cos((a + b));
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if ((b <= -0.36) || !(b <= 0.055)) tmp = Float64(Float64(r / cos(b)) * sin(b)); else tmp = Float64(Float64(Float64(r * fma(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666), Float64(b * b), 1.0)) * b) / cos(Float64(a + b))); end return tmp end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.36], N[Not[LessEqual[b, 0.055]], $MachinePrecision]], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(N[(r * N[(N[(0.008333333333333333 * N[(b * b), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.36 \lor \neg \left(b \leq 0.055\right):\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(r \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, b \cdot b, -0.16666666666666666\right), b \cdot b, 1\right)\right) \cdot b}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -0.35999999999999999 or 0.0550000000000000003 < b Initial program 56.2%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6455.1
Applied rewrites55.1%
if -0.35999999999999999 < b < 0.0550000000000000003Initial program 98.1%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.1%
Final simplification74.9%
(FPCore (r a b)
:precision binary64
(if (<= b -0.36)
(/ (* r (sin b)) (cos b))
(if (<= b 0.055)
(/
(*
(*
r
(fma
(fma 0.008333333333333333 (* b b) -0.16666666666666666)
(* b b)
1.0))
b)
(cos (+ a b)))
(* (/ r (cos b)) (sin b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.36) {
tmp = (r * sin(b)) / cos(b);
} else if (b <= 0.055) {
tmp = ((r * fma(fma(0.008333333333333333, (b * b), -0.16666666666666666), (b * b), 1.0)) * b) / cos((a + b));
} else {
tmp = (r / cos(b)) * sin(b);
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if (b <= -0.36) tmp = Float64(Float64(r * sin(b)) / cos(b)); elseif (b <= 0.055) tmp = Float64(Float64(Float64(r * fma(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666), Float64(b * b), 1.0)) * b) / cos(Float64(a + b))); else tmp = Float64(Float64(r / cos(b)) * sin(b)); end return tmp end
code[r_, a_, b_] := If[LessEqual[b, -0.36], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.055], N[(N[(N[(r * N[(N[(0.008333333333333333 * N[(b * b), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.36:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{elif}\;b \leq 0.055:\\
\;\;\;\;\frac{\left(r \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, b \cdot b, -0.16666666666666666\right), b \cdot b, 1\right)\right) \cdot b}{\cos \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\end{array}
\end{array}
if b < -0.35999999999999999Initial program 53.6%
Taylor expanded in a around 0
lower-cos.f6452.0
Applied rewrites52.0%
if -0.35999999999999999 < b < 0.0550000000000000003Initial program 98.1%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.1%
if 0.0550000000000000003 < b Initial program 58.5%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6458.2
Applied rewrites58.2%
(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}
Initial program 75.5%
(FPCore (r a b) :precision binary64 (* (/ r (cos (+ a b))) (sin b)))
double code(double r, double a, double b) {
return (r / cos((a + b))) * 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 / cos((a + b))) * sin(b)
end function
public static double code(double r, double a, double b) {
return (r / Math.cos((a + b))) * Math.sin(b);
}
def code(r, a, b): return (r / math.cos((a + b))) * math.sin(b)
function code(r, a, b) return Float64(Float64(r / cos(Float64(a + b))) * sin(b)) end
function tmp = code(r, a, b) tmp = (r / cos((a + b))) * sin(b); end
code[r_, a_, b_] := N[(N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos \left(a + b\right)} \cdot \sin b
\end{array}
Initial program 75.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.5
Applied rewrites75.5%
(FPCore (r a b)
:precision binary64
(if (or (<= b -22.0) (not (<= b 4.0)))
(/ (* r (sin b)) 1.0)
(/
(*
(*
r
(fma
(fma 0.008333333333333333 (* b b) -0.16666666666666666)
(* b b)
1.0))
b)
(cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -22.0) || !(b <= 4.0)) {
tmp = (r * sin(b)) / 1.0;
} else {
tmp = ((r * fma(fma(0.008333333333333333, (b * b), -0.16666666666666666), (b * b), 1.0)) * b) / cos((a + b));
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if ((b <= -22.0) || !(b <= 4.0)) tmp = Float64(Float64(r * sin(b)) / 1.0); else tmp = Float64(Float64(Float64(r * fma(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666), Float64(b * b), 1.0)) * b) / cos(Float64(a + b))); end return tmp end
code[r_, a_, b_] := If[Or[LessEqual[b, -22.0], N[Not[LessEqual[b, 4.0]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision], N[(N[(N[(r * N[(N[(0.008333333333333333 * N[(b * b), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -22 \lor \neg \left(b \leq 4\right):\\
\;\;\;\;\frac{r \cdot \sin b}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(r \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, b \cdot b, -0.16666666666666666\right), b \cdot b, 1\right)\right) \cdot b}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -22 or 4 < b Initial program 56.2%
Taylor expanded in b around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f646.8
Applied rewrites6.8%
Taylor expanded in a around 0
Applied rewrites6.4%
Taylor expanded in a around 0
Applied rewrites12.6%
if -22 < b < 4Initial program 98.1%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.1%
Final simplification52.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.4) (not (<= b 1.2))) (/ (* r (sin b)) 1.0) (* (/ r (cos a)) b)))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.4) || !(b <= 1.2)) {
tmp = (r * sin(b)) / 1.0;
} else {
tmp = (r / cos(a)) * 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.4d0)) .or. (.not. (b <= 1.2d0))) then
tmp = (r * sin(b)) / 1.0d0
else
tmp = (r / cos(a)) * b
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -1.4) || !(b <= 1.2)) {
tmp = (r * Math.sin(b)) / 1.0;
} else {
tmp = (r / Math.cos(a)) * b;
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.4) or not (b <= 1.2): tmp = (r * math.sin(b)) / 1.0 else: tmp = (r / math.cos(a)) * b return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.4) || !(b <= 1.2)) tmp = Float64(Float64(r * sin(b)) / 1.0); else tmp = Float64(Float64(r / cos(a)) * b); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.4) || ~((b <= 1.2))) tmp = (r * sin(b)) / 1.0; else tmp = (r / cos(a)) * b; end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.4], N[Not[LessEqual[b, 1.2]], $MachinePrecision]], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision], N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \lor \neg \left(b \leq 1.2\right):\\
\;\;\;\;\frac{r \cdot \sin b}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos a} \cdot b\\
\end{array}
\end{array}
if b < -1.3999999999999999 or 1.19999999999999996 < b Initial program 56.2%
Taylor expanded in b around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f646.8
Applied rewrites6.8%
Taylor expanded in a around 0
Applied rewrites6.4%
Taylor expanded in a around 0
Applied rewrites12.6%
if -1.3999999999999999 < b < 1.19999999999999996Initial program 98.1%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6497.9
Applied rewrites97.9%
Final simplification51.9%
(FPCore (r a b) :precision binary64 (* (/ r (cos a)) b))
double code(double r, double a, double b) {
return (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 = (r / cos(a)) * b
end function
public static double code(double r, double a, double b) {
return (r / Math.cos(a)) * b;
}
def code(r, a, b): return (r / math.cos(a)) * b
function code(r, a, b) return Float64(Float64(r / cos(a)) * b) end
function tmp = code(r, a, b) tmp = (r / cos(a)) * b; end
code[r_, a_, b_] := N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos a} \cdot b
\end{array}
Initial program 75.5%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6447.3
Applied rewrites47.3%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (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 * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 75.5%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6447.3
Applied rewrites47.3%
Applied rewrites47.3%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return b * r;
}
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
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 75.5%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6447.3
Applied rewrites47.3%
Taylor expanded in a around 0
Applied rewrites31.3%
herbie shell --seed 2024303
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))