
(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 11 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 (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(r * Float64(sin(b) / fma(sin(Float64(-b)), sin(a), Float64(cos(a) * cos(b))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[(-b)], $MachinePrecision] * N[Sin[a], $MachinePrecision] + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin \left(-b\right), \sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 78.8%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-sin.f64N/A
sin-negN/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
(FPCore (r a b) :precision binary64 (let* ((t_0 (/ (sin b) (cos (+ b a)))) (t_1 (/ (* r (sin b)) (cos b)))) (if (<= t_0 -0.002) t_1 (if (<= t_0 2e-11) (* b (/ r (cos a))) t_1))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((b + a));
double t_1 = (r * sin(b)) / cos(b);
double tmp;
if (t_0 <= -0.002) {
tmp = t_1;
} else if (t_0 <= 2e-11) {
tmp = b * (r / cos(a));
} else {
tmp = t_1;
}
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 = sin(b) / cos((b + a))
t_1 = (r * sin(b)) / cos(b)
if (t_0 <= (-0.002d0)) then
tmp = t_1
else if (t_0 <= 2d-11) then
tmp = b * (r / cos(a))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.sin(b) / Math.cos((b + a));
double t_1 = (r * Math.sin(b)) / Math.cos(b);
double tmp;
if (t_0 <= -0.002) {
tmp = t_1;
} else if (t_0 <= 2e-11) {
tmp = b * (r / Math.cos(a));
} else {
tmp = t_1;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((b + a)) t_1 = (r * math.sin(b)) / math.cos(b) tmp = 0 if t_0 <= -0.002: tmp = t_1 elif t_0 <= 2e-11: tmp = b * (r / math.cos(a)) else: tmp = t_1 return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(b + a))) t_1 = Float64(Float64(r * sin(b)) / cos(b)) tmp = 0.0 if (t_0 <= -0.002) tmp = t_1; elseif (t_0 <= 2e-11) tmp = Float64(b * Float64(r / cos(a))); else tmp = t_1; end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) / cos((b + a)); t_1 = (r * sin(b)) / cos(b); tmp = 0.0; if (t_0 <= -0.002) tmp = t_1; elseif (t_0 <= 2e-11) tmp = b * (r / cos(a)); else tmp = t_1; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.002], t$95$1, If[LessEqual[t$95$0, 2e-11], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\
t_1 := \frac{r \cdot \sin b}{\cos b}\\
\mathbf{if}\;t\_0 \leq -0.002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -2e-3 or 1.99999999999999988e-11 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 58.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6458.5
Applied rewrites58.5%
if -2e-3 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 1.99999999999999988e-11Initial program 99.2%
Taylor expanded in b around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6499.3
Applied rewrites99.3%
Final simplification78.7%
(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(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(-Float64(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[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \sin a\right)}
\end{array}
Initial program 78.8%
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
lower-neg.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (/ (sin b) (cos a))))) (if (<= a -0.000135) t_0 (if (<= a 0.0028) (* r (/ (sin b) (cos b))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * (sin(b) / cos(a));
double tmp;
if (a <= -0.000135) {
tmp = t_0;
} else if (a <= 0.0028) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = 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) / cos(a))
if (a <= (-0.000135d0)) then
tmp = t_0
else if (a <= 0.0028d0) then
tmp = r * (sin(b) / cos(b))
else
tmp = 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) / Math.cos(a));
double tmp;
if (a <= -0.000135) {
tmp = t_0;
} else if (a <= 0.0028) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * (math.sin(b) / math.cos(a)) tmp = 0 if a <= -0.000135: tmp = t_0 elif a <= 0.0028: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * Float64(sin(b) / cos(a))) tmp = 0.0 if (a <= -0.000135) tmp = t_0; elseif (a <= 0.0028) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * (sin(b) / cos(a)); tmp = 0.0; if (a <= -0.000135) tmp = t_0; elseif (a <= 0.0028) tmp = r * (sin(b) / cos(b)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.000135], t$95$0, If[LessEqual[a, 0.0028], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \frac{\sin b}{\cos a}\\
\mathbf{if}\;a \leq -0.000135:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.0028:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -1.35000000000000002e-4 or 0.00279999999999999997 < a Initial program 57.1%
Taylor expanded in b around 0
lower-cos.f6457.3
Applied rewrites57.3%
if -1.35000000000000002e-4 < a < 0.00279999999999999997Initial program 98.7%
Taylor expanded in a around 0
lower-cos.f6498.7
Applied rewrites98.7%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (/ (sin b) (cos a))))) (if (<= a -0.000135) t_0 (if (<= a 0.0028) (/ (* r (sin b)) (cos b)) t_0))))
double code(double r, double a, double b) {
double t_0 = r * (sin(b) / cos(a));
double tmp;
if (a <= -0.000135) {
tmp = t_0;
} else if (a <= 0.0028) {
tmp = (r * sin(b)) / cos(b);
} else {
tmp = 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) / cos(a))
if (a <= (-0.000135d0)) then
tmp = t_0
else if (a <= 0.0028d0) then
tmp = (r * sin(b)) / cos(b)
else
tmp = 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) / Math.cos(a));
double tmp;
if (a <= -0.000135) {
tmp = t_0;
} else if (a <= 0.0028) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * (math.sin(b) / math.cos(a)) tmp = 0 if a <= -0.000135: tmp = t_0 elif a <= 0.0028: tmp = (r * math.sin(b)) / math.cos(b) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * Float64(sin(b) / cos(a))) tmp = 0.0 if (a <= -0.000135) tmp = t_0; elseif (a <= 0.0028) tmp = Float64(Float64(r * sin(b)) / cos(b)); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * (sin(b) / cos(a)); tmp = 0.0; if (a <= -0.000135) tmp = t_0; elseif (a <= 0.0028) tmp = (r * sin(b)) / cos(b); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.000135], t$95$0, If[LessEqual[a, 0.0028], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \frac{\sin b}{\cos a}\\
\mathbf{if}\;a \leq -0.000135:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 0.0028:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -1.35000000000000002e-4 or 0.00279999999999999997 < a Initial program 57.1%
Taylor expanded in b around 0
lower-cos.f6457.3
Applied rewrites57.3%
if -1.35000000000000002e-4 < a < 0.00279999999999999997Initial program 98.7%
Taylor expanded in a around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
(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 78.8%
Final simplification78.8%
(FPCore (r a b)
:precision binary64
(if (<= b -72.0)
(* r (/ (sin b) (fma a (* a -0.5) 1.0)))
(*
r
(/
(fma
(fma (* b b) 0.008333333333333333 -0.16666666666666666)
(* b (* b b))
b)
(cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -72.0) {
tmp = r * (sin(b) / fma(a, (a * -0.5), 1.0));
} else {
tmp = r * (fma(fma((b * b), 0.008333333333333333, -0.16666666666666666), (b * (b * b)), b) / cos((b + a)));
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if (b <= -72.0) tmp = Float64(r * Float64(sin(b) / fma(a, Float64(a * -0.5), 1.0))); else tmp = Float64(r * Float64(fma(fma(Float64(b * b), 0.008333333333333333, -0.16666666666666666), Float64(b * Float64(b * b)), b) / cos(Float64(b + a)))); end return tmp end
code[r_, a_, b_] := If[LessEqual[b, -72.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[(a * N[(a * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[(N[(N[(b * b), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -72:\\
\;\;\;\;r \cdot \frac{\sin b}{\mathsf{fma}\left(a, a \cdot -0.5, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(b \cdot b, 0.008333333333333333, -0.16666666666666666\right), b \cdot \left(b \cdot b\right), b\right)}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -72Initial program 64.0%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6463.6
Applied rewrites63.6%
Taylor expanded in b around 0
Applied rewrites10.4%
if -72 < b Initial program 83.2%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6466.9
Applied rewrites66.9%
Final simplification53.8%
(FPCore (r a b) :precision binary64 (if (<= b -30.0) (* r (/ (sin b) (fma a (* a -0.5) 1.0))) (* r (/ (fma b (* b (* b -0.16666666666666666)) b) (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -30.0) {
tmp = r * (sin(b) / fma(a, (a * -0.5), 1.0));
} else {
tmp = r * (fma(b, (b * (b * -0.16666666666666666)), b) / cos((b + a)));
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if (b <= -30.0) tmp = Float64(r * Float64(sin(b) / fma(a, Float64(a * -0.5), 1.0))); else tmp = Float64(r * Float64(fma(b, Float64(b * Float64(b * -0.16666666666666666)), b) / cos(Float64(b + a)))); end return tmp end
code[r_, a_, b_] := If[LessEqual[b, -30.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[(a * N[(a * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[(b * N[(b * N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -30:\\
\;\;\;\;r \cdot \frac{\sin b}{\mathsf{fma}\left(a, a \cdot -0.5, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\mathsf{fma}\left(b, b \cdot \left(b \cdot -0.16666666666666666\right), b\right)}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -30Initial program 64.0%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6463.6
Applied rewrites63.6%
Taylor expanded in b around 0
Applied rewrites10.4%
if -30 < b Initial program 83.2%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.7
Applied rewrites66.7%
Final simplification53.8%
(FPCore (r a b) :precision binary64 (/ (* r b) (cos (+ b a))))
double code(double r, double a, double b) {
return (r * 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 * b) / cos((b + a))
end function
public static double code(double r, double a, double b) {
return (r * b) / Math.cos((b + a));
}
def code(r, a, b): return (r * b) / math.cos((b + a))
function code(r, a, b) return Float64(Float64(r * b) / cos(Float64(b + a))) end
function tmp = code(r, a, b) tmp = (r * b) / cos((b + a)); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos \left(b + a\right)}
\end{array}
Initial program 78.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6478.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.7
Applied rewrites78.7%
Taylor expanded in b around 0
lower-*.f6452.0
Applied rewrites52.0%
Final simplification52.0%
(FPCore (r a b) :precision binary64 (* b (/ r (cos a))))
double code(double r, double a, double b) {
return 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 = b * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return b * (r / Math.cos(a));
}
def code(r, a, b): return b * (r / math.cos(a))
function code(r, a, b) return Float64(b * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = b * (r / cos(a)); end
code[r_, a_, b_] := N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{r}{\cos a}
\end{array}
Initial program 78.8%
Taylor expanded in b around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6452.0
Applied rewrites52.0%
(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 78.8%
Taylor expanded in b around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6452.0
Applied rewrites52.0%
Taylor expanded in a around 0
Applied rewrites34.4%
Final simplification34.4%
herbie shell --seed 2024225
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))