
(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 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(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 (/ (* (sin b) r) (fma (- (sin a)) (sin b) (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma(-sin(a), sin(b), (cos(b) * cos(a)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(Float64(-sin(a)), sin(b), Float64(cos(b) * cos(a)))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[((-N[Sin[a], $MachinePrecision]) * N[Sin[b], $MachinePrecision] + N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\mathsf{fma}\left(-\sin a, \sin b, \cos b \cdot \cos a\right)}
\end{array}
Initial program 75.5%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.5
Applied rewrites99.5%
Taylor expanded in r around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.5
Applied rewrites99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ a b)))))
(if (or (<= t_0 -0.08) (not (<= t_0 0.01)))
(* (/ r (cos b)) (sin b))
(/ (* (sin b) r) (cos a)))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((a + b));
double tmp;
if ((t_0 <= -0.08) || !(t_0 <= 0.01)) {
tmp = (r / cos(b)) * sin(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) :: t_0
real(8) :: tmp
t_0 = sin(b) / cos((a + b))
if ((t_0 <= (-0.08d0)) .or. (.not. (t_0 <= 0.01d0))) then
tmp = (r / cos(b)) * sin(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 t_0 = Math.sin(b) / Math.cos((a + b));
double tmp;
if ((t_0 <= -0.08) || !(t_0 <= 0.01)) {
tmp = (r / Math.cos(b)) * Math.sin(b);
} else {
tmp = (Math.sin(b) * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((a + b)) tmp = 0 if (t_0 <= -0.08) or not (t_0 <= 0.01): tmp = (r / math.cos(b)) * math.sin(b) else: tmp = (math.sin(b) * r) / math.cos(a) return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(a + b))) tmp = 0.0 if ((t_0 <= -0.08) || !(t_0 <= 0.01)) tmp = Float64(Float64(r / cos(b)) * sin(b)); else tmp = Float64(Float64(sin(b) * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) / cos((a + b)); tmp = 0.0; if ((t_0 <= -0.08) || ~((t_0 <= 0.01))) tmp = (r / cos(b)) * sin(b); else tmp = (sin(b) * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.08], N[Not[LessEqual[t$95$0, 0.01]], $MachinePrecision]], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
\mathbf{if}\;t\_0 \leq -0.08 \lor \neg \left(t\_0 \leq 0.01\right):\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos a}\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0800000000000000017 or 0.0100000000000000002 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 54.3%
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.f6453.2
Applied rewrites53.2%
if -0.0800000000000000017 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.0100000000000000002Initial program 97.4%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6497.3
Applied rewrites97.3%
Taylor expanded in b around 0
lower-cos.f6497.5
Applied rewrites97.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Final simplification75.1%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ a b)))))
(if (or (<= t_0 -0.08) (not (<= t_0 0.01)))
(* (/ r (cos b)) (sin b))
(* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((a + b));
double tmp;
if ((t_0 <= -0.08) || !(t_0 <= 0.01)) {
tmp = (r / cos(b)) * sin(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) :: t_0
real(8) :: tmp
t_0 = sin(b) / cos((a + b))
if ((t_0 <= (-0.08d0)) .or. (.not. (t_0 <= 0.01d0))) then
tmp = (r / cos(b)) * sin(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 t_0 = Math.sin(b) / Math.cos((a + b));
double tmp;
if ((t_0 <= -0.08) || !(t_0 <= 0.01)) {
tmp = (r / Math.cos(b)) * Math.sin(b);
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((a + b)) tmp = 0 if (t_0 <= -0.08) or not (t_0 <= 0.01): tmp = (r / math.cos(b)) * math.sin(b) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(a + b))) tmp = 0.0 if ((t_0 <= -0.08) || !(t_0 <= 0.01)) tmp = Float64(Float64(r / cos(b)) * sin(b)); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) / cos((a + b)); tmp = 0.0; if ((t_0 <= -0.08) || ~((t_0 <= 0.01))) tmp = (r / cos(b)) * sin(b); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.08], N[Not[LessEqual[t$95$0, 0.01]], $MachinePrecision]], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
\mathbf{if}\;t\_0 \leq -0.08 \lor \neg \left(t\_0 \leq 0.01\right):\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0800000000000000017 or 0.0100000000000000002 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 54.3%
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.f6453.2
Applied rewrites53.2%
if -0.0800000000000000017 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.0100000000000000002Initial program 97.4%
Taylor expanded in b around 0
lower-cos.f6497.6
Applied rewrites97.6%
Final simplification75.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.34) (not (<= b 1.08e-8))) (* (/ r (cos b)) (sin b)) (* r (/ (fma (* b b) (* b -0.16666666666666666) b) (cos (+ a b))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.34) || !(b <= 1.08e-8)) {
tmp = (r / cos(b)) * sin(b);
} else {
tmp = r * (fma((b * b), (b * -0.16666666666666666), b) / cos((a + b)));
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if ((b <= -0.34) || !(b <= 1.08e-8)) tmp = Float64(Float64(r / cos(b)) * sin(b)); else tmp = Float64(r * Float64(fma(Float64(b * b), Float64(b * -0.16666666666666666), b) / cos(Float64(a + b)))); end return tmp end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.34], N[Not[LessEqual[b, 1.08e-8]], $MachinePrecision]], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[(N[(b * b), $MachinePrecision] * N[(b * -0.16666666666666666), $MachinePrecision] + b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.34 \lor \neg \left(b \leq 1.08 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\mathsf{fma}\left(b \cdot b, b \cdot -0.16666666666666666, b\right)}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -0.340000000000000024 or 1.0800000000000001e-8 < b Initial program 54.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.f6453.6
Applied rewrites53.6%
if -0.340000000000000024 < b < 1.0800000000000001e-8Initial program 97.5%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
cube-unmultN/A
lower-pow.f6497.5
Applied rewrites97.5%
Applied rewrites97.5%
Final simplification75.0%
(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
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6475.5
Applied rewrites75.5%
(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 75.5%
(FPCore (r a b) :precision binary64 (if (<= b 1.08e-8) (* r (/ b (cos a))) (* (/ r 1.0) (sin b))))
double code(double r, double a, double b) {
double tmp;
if (b <= 1.08e-8) {
tmp = r * (b / cos(a));
} else {
tmp = (r / 1.0) * sin(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.08d-8) then
tmp = r * (b / cos(a))
else
tmp = (r / 1.0d0) * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 1.08e-8) {
tmp = r * (b / Math.cos(a));
} else {
tmp = (r / 1.0) * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 1.08e-8: tmp = r * (b / math.cos(a)) else: tmp = (r / 1.0) * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 1.08e-8) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(Float64(r / 1.0) * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 1.08e-8) tmp = r * (b / cos(a)); else tmp = (r / 1.0) * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 1.08e-8], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r / 1.0), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{-8}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{1} \cdot \sin b\\
\end{array}
\end{array}
if b < 1.0800000000000001e-8Initial program 83.4%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6465.8
Applied rewrites65.8%
if 1.0800000000000001e-8 < b Initial program 53.3%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6453.4
Applied rewrites53.4%
Taylor expanded in b around 0
lower-cos.f6413.5
Applied rewrites13.5%
Taylor expanded in a around 0
Applied rewrites13.9%
(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
lower-/.f64N/A
lower-cos.f6449.8
Applied rewrites49.8%
(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%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.5
Applied rewrites99.5%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6449.8
Applied rewrites49.8%
(FPCore (r a b) :precision binary64 (* r (/ b 1.0)))
double code(double r, double a, double b) {
return r * (b / 1.0);
}
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 / 1.0d0)
end function
public static double code(double r, double a, double b) {
return r * (b / 1.0);
}
def code(r, a, b): return r * (b / 1.0)
function code(r, a, b) return Float64(r * Float64(b / 1.0)) end
function tmp = code(r, a, b) tmp = r * (b / 1.0); end
code[r_, a_, b_] := N[(r * N[(b / 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{1}
\end{array}
Initial program 75.5%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6449.8
Applied rewrites49.8%
Taylor expanded in a around 0
Applied rewrites34.1%
(FPCore (r a b) :precision binary64 (* r (fma (* b b) a b)))
double code(double r, double a, double b) {
return r * fma((b * b), a, b);
}
function code(r, a, b) return Float64(r * fma(Float64(b * b), a, b)) end
code[r_, a_, b_] := N[(r * N[(N[(b * b), $MachinePrecision] * a + b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \mathsf{fma}\left(b \cdot b, a, b\right)
\end{array}
Initial program 75.5%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
associate-/l*N/A
associate-*r*N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lower-cos.f6449.6
Applied rewrites49.6%
Taylor expanded in a around 0
Applied rewrites32.5%
(FPCore (r a b) :precision binary64 (* r (fma (* a b) b b)))
double code(double r, double a, double b) {
return r * fma((a * b), b, b);
}
function code(r, a, b) return Float64(r * fma(Float64(a * b), b, b)) end
code[r_, a_, b_] := N[(r * N[(N[(a * b), $MachinePrecision] * b + b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \mathsf{fma}\left(a \cdot b, b, b\right)
\end{array}
Initial program 75.5%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
associate-/l*N/A
associate-*r*N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lower-cos.f6449.6
Applied rewrites49.6%
Taylor expanded in a around 0
Applied rewrites32.5%
Applied rewrites32.4%
(FPCore (r a b) :precision binary64 (* r (* (* a b) b)))
double code(double r, double a, double b) {
return r * ((a * b) * 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 * ((a * b) * b)
end function
public static double code(double r, double a, double b) {
return r * ((a * b) * b);
}
def code(r, a, b): return r * ((a * b) * b)
function code(r, a, b) return Float64(r * Float64(Float64(a * b) * b)) end
function tmp = code(r, a, b) tmp = r * ((a * b) * b); end
code[r_, a_, b_] := N[(r * N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \left(\left(a \cdot b\right) \cdot b\right)
\end{array}
Initial program 75.5%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
associate-/l*N/A
associate-*r*N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lower-cos.f6449.6
Applied rewrites49.6%
Taylor expanded in a around 0
Applied rewrites32.5%
Taylor expanded in a around inf
Applied rewrites17.0%
Applied rewrites17.0%
herbie shell --seed 2024307
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))