
(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 (/ (* (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 74.0%
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
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/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.5
Applied rewrites99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ a b)))))
(if (or (<= t_0 -0.05) (not (<= t_0 0.005)))
(* (/ 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.05) || !(t_0 <= 0.005)) {
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.05d0)) .or. (.not. (t_0 <= 0.005d0))) 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.05) || !(t_0 <= 0.005)) {
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.05) or not (t_0 <= 0.005): 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.05) || !(t_0 <= 0.005)) 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.05) || ~((t_0 <= 0.005))) 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.05], N[Not[LessEqual[t$95$0, 0.005]], $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.05 \lor \neg \left(t\_0 \leq 0.005\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.050000000000000003 or 0.0050000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 53.0%
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.f6452.7
Applied rewrites52.7%
if -0.050000000000000003 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.0050000000000000001Initial program 98.1%
Taylor expanded in b around 0
lower-cos.f6498.1
Applied rewrites98.1%
Final simplification73.8%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ a b)))))
(if (<= t_0 -0.05)
(* (/ r (cos b)) (sin b))
(if (<= t_0 0.005) (* r (/ (sin b) (cos a))) (/ (* (sin b) r) (cos b))))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((a + b));
double tmp;
if (t_0 <= -0.05) {
tmp = (r / cos(b)) * sin(b);
} else if (t_0 <= 0.005) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = (sin(b) * r) / cos(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) :: tmp
t_0 = sin(b) / cos((a + b))
if (t_0 <= (-0.05d0)) then
tmp = (r / cos(b)) * sin(b)
else if (t_0 <= 0.005d0) then
tmp = r * (sin(b) / cos(a))
else
tmp = (sin(b) * r) / cos(b)
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.05) {
tmp = (r / Math.cos(b)) * Math.sin(b);
} else if (t_0 <= 0.005) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = (Math.sin(b) * r) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((a + b)) tmp = 0 if t_0 <= -0.05: tmp = (r / math.cos(b)) * math.sin(b) elif t_0 <= 0.005: tmp = r * (math.sin(b) / math.cos(a)) else: tmp = (math.sin(b) * r) / math.cos(b) return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(a + b))) tmp = 0.0 if (t_0 <= -0.05) tmp = Float64(Float64(r / cos(b)) * sin(b)); elseif (t_0 <= 0.005) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(Float64(sin(b) * r) / cos(b)); 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.05) tmp = (r / cos(b)) * sin(b); elseif (t_0 <= 0.005) tmp = r * (sin(b) / cos(a)); else tmp = (sin(b) * r) / cos(b); 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[LessEqual[t$95$0, -0.05], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.005], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
\mathbf{if}\;t\_0 \leq -0.05:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{elif}\;t\_0 \leq 0.005:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos b}\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.050000000000000003Initial program 48.0%
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.f6447.8
Applied rewrites47.8%
if -0.050000000000000003 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.0050000000000000001Initial program 98.1%
Taylor expanded in b around 0
lower-cos.f6498.1
Applied rewrites98.1%
if 0.0050000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 58.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.1
Applied rewrites58.1%
Taylor expanded in a around 0
lower-cos.f6457.8
Applied rewrites57.8%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ a b)))))
(if (<= t_0 -0.05)
(* (/ r (cos b)) (sin b))
(if (<= t_0 0.005) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((a + b));
double tmp;
if (t_0 <= -0.05) {
tmp = (r / cos(b)) * sin(b);
} else if (t_0 <= 0.005) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * (sin(b) / cos(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) :: tmp
t_0 = sin(b) / cos((a + b))
if (t_0 <= (-0.05d0)) then
tmp = (r / cos(b)) * sin(b)
else if (t_0 <= 0.005d0) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * (sin(b) / cos(b))
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.05) {
tmp = (r / Math.cos(b)) * Math.sin(b);
} else if (t_0 <= 0.005) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((a + b)) tmp = 0 if t_0 <= -0.05: tmp = (r / math.cos(b)) * math.sin(b) elif t_0 <= 0.005: tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(a + b))) tmp = 0.0 if (t_0 <= -0.05) tmp = Float64(Float64(r / cos(b)) * sin(b)); elseif (t_0 <= 0.005) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); 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.05) tmp = (r / cos(b)) * sin(b); elseif (t_0 <= 0.005) tmp = r * (sin(b) / cos(a)); else tmp = r * (sin(b) / cos(b)); 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[LessEqual[t$95$0, -0.05], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.005], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $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.05:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{elif}\;t\_0 \leq 0.005:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.050000000000000003Initial program 48.0%
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.f6447.8
Applied rewrites47.8%
if -0.050000000000000003 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.0050000000000000001Initial program 98.1%
Taylor expanded in b around 0
lower-cos.f6498.1
Applied rewrites98.1%
if 0.0050000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 58.0%
Taylor expanded in a around 0
lower-cos.f6457.8
Applied rewrites57.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -23.5) (not (<= b 4.4e-6))) (* (/ r (cos b)) (sin b)) (/ (* b r) (cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -23.5) || !(b <= 4.4e-6)) {
tmp = (r / cos(b)) * sin(b);
} else {
tmp = (b * 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 <= (-23.5d0)) .or. (.not. (b <= 4.4d-6))) then
tmp = (r / cos(b)) * sin(b)
else
tmp = (b * r) / cos((a + b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -23.5) || !(b <= 4.4e-6)) {
tmp = (r / Math.cos(b)) * Math.sin(b);
} else {
tmp = (b * r) / Math.cos((a + b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -23.5) or not (b <= 4.4e-6): tmp = (r / math.cos(b)) * math.sin(b) else: tmp = (b * r) / math.cos((a + b)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -23.5) || !(b <= 4.4e-6)) tmp = Float64(Float64(r / cos(b)) * sin(b)); else tmp = Float64(Float64(b * r) / cos(Float64(a + b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -23.5) || ~((b <= 4.4e-6))) tmp = (r / cos(b)) * sin(b); else tmp = (b * r) / cos((a + b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -23.5], N[Not[LessEqual[b, 4.4e-6]], $MachinePrecision]], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -23.5 \lor \neg \left(b \leq 4.4 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -23.5 or 4.4000000000000002e-6 < b Initial program 52.9%
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.f6452.4
Applied rewrites52.4%
if -23.5 < b < 4.4000000000000002e-6Initial program 98.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6498.7
Applied rewrites98.7%
Taylor expanded in b around 0
lower-*.f6498.8
Applied rewrites98.8%
Final simplification73.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(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 74.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6474.0
Applied rewrites74.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 74.0%
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-/.f6474.0
Applied rewrites74.0%
(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 74.0%
(FPCore (r a b) :precision binary64 (/ (* b r) (cos (+ a b))))
double code(double r, double a, double b) {
return (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 = (b * r) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (b * r) / Math.cos((a + b));
}
def code(r, a, b): return (b * r) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(b * r) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (b * r) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(b * r), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot r}{\cos \left(a + b\right)}
\end{array}
Initial program 74.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6474.0
Applied rewrites74.0%
Taylor expanded in b around 0
lower-*.f6448.1
Applied rewrites48.1%
(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 74.0%
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.f6448.0
Applied rewrites48.0%
(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 74.0%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6448.0
Applied rewrites48.0%
Taylor expanded in a around 0
Applied rewrites32.8%
herbie shell --seed 2024309
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))