
(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 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(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 (* r (/ (sin b) (fma (cos b) (cos a) (* (/ (- -1.0) (/ -1.0 (sin b))) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), ((-(-1.0) / (-1.0 / sin(b))) * sin(a))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(Float64(Float64(-(-1.0)) / Float64(-1.0 / sin(b))) * sin(a))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[((--1.0) / N[(-1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \frac{--1}{\frac{-1}{\sin b}} \cdot \sin a\right)}
\end{array}
Initial program 75.4%
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.4
Applied rewrites99.4%
remove-double-divN/A
unpow-1N/A
lift-pow.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift-pow.f64N/A
unpow-1N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6499.4
Applied rewrites99.4%
Final simplification99.4%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (cos (+ a b))) (t_1 (/ (sin b) t_0)))
(if (or (<= t_1 -0.005) (not (<= t_1 5e-22)))
(* (/ r (cos b)) (sin b))
(/ (* r b) t_0))))
double code(double r, double a, double b) {
double t_0 = cos((a + b));
double t_1 = sin(b) / t_0;
double tmp;
if ((t_1 <= -0.005) || !(t_1 <= 5e-22)) {
tmp = (r / cos(b)) * sin(b);
} else {
tmp = (r * b) / 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) :: t_1
real(8) :: tmp
t_0 = cos((a + b))
t_1 = sin(b) / t_0
if ((t_1 <= (-0.005d0)) .or. (.not. (t_1 <= 5d-22))) then
tmp = (r / cos(b)) * sin(b)
else
tmp = (r * b) / t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.cos((a + b));
double t_1 = Math.sin(b) / t_0;
double tmp;
if ((t_1 <= -0.005) || !(t_1 <= 5e-22)) {
tmp = (r / Math.cos(b)) * Math.sin(b);
} else {
tmp = (r * b) / t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.cos((a + b)) t_1 = math.sin(b) / t_0 tmp = 0 if (t_1 <= -0.005) or not (t_1 <= 5e-22): tmp = (r / math.cos(b)) * math.sin(b) else: tmp = (r * b) / t_0 return tmp
function code(r, a, b) t_0 = cos(Float64(a + b)) t_1 = Float64(sin(b) / t_0) tmp = 0.0 if ((t_1 <= -0.005) || !(t_1 <= 5e-22)) tmp = Float64(Float64(r / cos(b)) * sin(b)); else tmp = Float64(Float64(r * b) / t_0); end return tmp end
function tmp_2 = code(r, a, b) t_0 = cos((a + b)); t_1 = sin(b) / t_0; tmp = 0.0; if ((t_1 <= -0.005) || ~((t_1 <= 5e-22))) tmp = (r / cos(b)) * sin(b); else tmp = (r * b) / t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[b], $MachinePrecision] / t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -0.005], N[Not[LessEqual[t$95$1, 5e-22]], $MachinePrecision]], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(a + b\right)\\
t_1 := \frac{\sin b}{t\_0}\\
\mathbf{if}\;t\_1 \leq -0.005 \lor \neg \left(t\_1 \leq 5 \cdot 10^{-22}\right):\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{t\_0}\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0050000000000000001 or 4.99999999999999954e-22 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 57.6%
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.1
Applied rewrites58.1%
if -0.0050000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 4.99999999999999954e-22Initial program 99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Final simplification75.7%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (cos (+ a b))) (t_1 (/ (sin b) t_0)))
(if (<= t_1 -0.005)
(/ (* (sin b) r) (cos b))
(if (<= t_1 5e-22) (/ (* r b) t_0) (* (/ r (cos b)) (sin b))))))
double code(double r, double a, double b) {
double t_0 = cos((a + b));
double t_1 = sin(b) / t_0;
double tmp;
if (t_1 <= -0.005) {
tmp = (sin(b) * r) / cos(b);
} else if (t_1 <= 5e-22) {
tmp = (r * b) / t_0;
} else {
tmp = (r / cos(b)) * 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((a + b))
t_1 = sin(b) / t_0
if (t_1 <= (-0.005d0)) then
tmp = (sin(b) * r) / cos(b)
else if (t_1 <= 5d-22) then
tmp = (r * b) / t_0
else
tmp = (r / cos(b)) * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.cos((a + b));
double t_1 = Math.sin(b) / t_0;
double tmp;
if (t_1 <= -0.005) {
tmp = (Math.sin(b) * r) / Math.cos(b);
} else if (t_1 <= 5e-22) {
tmp = (r * b) / t_0;
} else {
tmp = (r / Math.cos(b)) * Math.sin(b);
}
return tmp;
}
def code(r, a, b): t_0 = math.cos((a + b)) t_1 = math.sin(b) / t_0 tmp = 0 if t_1 <= -0.005: tmp = (math.sin(b) * r) / math.cos(b) elif t_1 <= 5e-22: tmp = (r * b) / t_0 else: tmp = (r / math.cos(b)) * math.sin(b) return tmp
function code(r, a, b) t_0 = cos(Float64(a + b)) t_1 = Float64(sin(b) / t_0) tmp = 0.0 if (t_1 <= -0.005) tmp = Float64(Float64(sin(b) * r) / cos(b)); elseif (t_1 <= 5e-22) tmp = Float64(Float64(r * b) / t_0); else tmp = Float64(Float64(r / cos(b)) * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = cos((a + b)); t_1 = sin(b) / t_0; tmp = 0.0; if (t_1 <= -0.005) tmp = (sin(b) * r) / cos(b); elseif (t_1 <= 5e-22) tmp = (r * b) / t_0; else tmp = (r / cos(b)) * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[b], $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -0.005], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-22], N[(N[(r * b), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(a + b\right)\\
t_1 := \frac{\sin b}{t\_0}\\
\mathbf{if}\;t\_1 \leq -0.005:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos b}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{r \cdot b}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0050000000000000001Initial program 57.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6457.3
Applied rewrites57.3%
Taylor expanded in a around 0
lower-cos.f6457.6
Applied rewrites57.6%
if -0.0050000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 4.99999999999999954e-22Initial program 99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
if 4.99999999999999954e-22 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 58.1%
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.7
Applied rewrites58.7%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (cos (+ a b))) (t_1 (/ (sin b) t_0)))
(if (<= t_1 -0.005)
(* r (/ (sin b) (cos b)))
(if (<= t_1 5e-22) (/ (* r b) t_0) (* (/ r (cos b)) (sin b))))))
double code(double r, double a, double b) {
double t_0 = cos((a + b));
double t_1 = sin(b) / t_0;
double tmp;
if (t_1 <= -0.005) {
tmp = r * (sin(b) / cos(b));
} else if (t_1 <= 5e-22) {
tmp = (r * b) / t_0;
} else {
tmp = (r / cos(b)) * 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((a + b))
t_1 = sin(b) / t_0
if (t_1 <= (-0.005d0)) then
tmp = r * (sin(b) / cos(b))
else if (t_1 <= 5d-22) then
tmp = (r * b) / t_0
else
tmp = (r / cos(b)) * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.cos((a + b));
double t_1 = Math.sin(b) / t_0;
double tmp;
if (t_1 <= -0.005) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (t_1 <= 5e-22) {
tmp = (r * b) / t_0;
} else {
tmp = (r / Math.cos(b)) * Math.sin(b);
}
return tmp;
}
def code(r, a, b): t_0 = math.cos((a + b)) t_1 = math.sin(b) / t_0 tmp = 0 if t_1 <= -0.005: tmp = r * (math.sin(b) / math.cos(b)) elif t_1 <= 5e-22: tmp = (r * b) / t_0 else: tmp = (r / math.cos(b)) * math.sin(b) return tmp
function code(r, a, b) t_0 = cos(Float64(a + b)) t_1 = Float64(sin(b) / t_0) tmp = 0.0 if (t_1 <= -0.005) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (t_1 <= 5e-22) tmp = Float64(Float64(r * b) / t_0); else tmp = Float64(Float64(r / cos(b)) * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = cos((a + b)); t_1 = sin(b) / t_0; tmp = 0.0; if (t_1 <= -0.005) tmp = r * (sin(b) / cos(b)); elseif (t_1 <= 5e-22) tmp = (r * b) / t_0; else tmp = (r / cos(b)) * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[b], $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -0.005], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-22], N[(N[(r * b), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(a + b\right)\\
t_1 := \frac{\sin b}{t\_0}\\
\mathbf{if}\;t\_1 \leq -0.005:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\frac{r \cdot b}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0050000000000000001Initial program 57.3%
Taylor expanded in a around 0
lower-cos.f6457.6
Applied rewrites57.6%
if -0.0050000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 4.99999999999999954e-22Initial program 99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
if 4.99999999999999954e-22 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 58.1%
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.7
Applied rewrites58.7%
(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.4%
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.4
Applied rewrites99.4%
Taylor expanded in r around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
associate-*r*N/A
mul-1-negN/A
sin-negN/A
lower-fma.f64N/A
sin-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.4
Applied rewrites99.4%
(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(Float64(sin(b) * 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[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos \left(a + b\right)}
\end{array}
Initial program 75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6475.4
Applied rewrites75.4%
(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.4%
(FPCore (r a b) :precision binary64 (/ (/ r (cos (+ a b))) (/ (fma (* b b) 0.16666666666666666 1.0) b)))
double code(double r, double a, double b) {
return (r / cos((a + b))) / (fma((b * b), 0.16666666666666666, 1.0) / b);
}
function code(r, a, b) return Float64(Float64(r / cos(Float64(a + b))) / Float64(fma(Float64(b * b), 0.16666666666666666, 1.0) / b)) end
code[r_, a_, b_] := N[(N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{r}{\cos \left(a + b\right)}}{\frac{\mathsf{fma}\left(b \cdot b, 0.16666666666666666, 1\right)}{b}}
\end{array}
Initial program 75.4%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
div-invN/A
associate-/r*N/A
*-lft-identityN/A
associate-*l/N/A
lower-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6475.2
Applied rewrites75.2%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6445.9
Applied rewrites45.9%
(FPCore (r a b) :precision binary64 (/ (* r b) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * 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 * b) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * b) / Math.cos((a + b));
}
def code(r, a, b): return (r * b) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * b) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * b) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos \left(a + b\right)}
\end{array}
Initial program 75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6475.4
Applied rewrites75.4%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f6445.6
Applied rewrites45.6%
(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.4%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6445.5
Applied rewrites45.5%
(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.4%
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.4
Applied rewrites99.4%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6445.4
Applied rewrites45.4%
(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.4%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6445.5
Applied rewrites45.5%
Taylor expanded in a around 0
Applied rewrites29.9%
herbie shell --seed 2024313
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))