
(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 (- 0.0 (sin b)) (sin a) (* (cos a) (cos b))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma((0.0 - sin(b)), sin(a), (cos(a) * cos(b))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(Float64(0.0 - sin(b)), sin(a), Float64(cos(a) * cos(b))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(0.0 - N[Sin[b], $MachinePrecision]), $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(0 - \sin b, \sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 74.1%
cos-sumN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-sub0N/A
--lowering--.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.5
Applied egg-rr99.5%
sub0-negN/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f6499.5
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (let* ((t_0 (/ (sin b) (cos (+ b a)))) (t_1 (* r (tan b)))) (if (<= t_0 -0.025) t_1 (if (<= t_0 0.0015) (* 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 * tan(b);
double tmp;
if (t_0 <= -0.025) {
tmp = t_1;
} else if (t_0 <= 0.0015) {
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 * tan(b)
if (t_0 <= (-0.025d0)) then
tmp = t_1
else if (t_0 <= 0.0015d0) 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.tan(b);
double tmp;
if (t_0 <= -0.025) {
tmp = t_1;
} else if (t_0 <= 0.0015) {
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.tan(b) tmp = 0 if t_0 <= -0.025: tmp = t_1 elif t_0 <= 0.0015: 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(r * tan(b)) tmp = 0.0 if (t_0 <= -0.025) tmp = t_1; elseif (t_0 <= 0.0015) 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 * tan(b); tmp = 0.0; if (t_0 <= -0.025) tmp = t_1; elseif (t_0 <= 0.0015) 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[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.025], t$95$1, If[LessEqual[t$95$0, 0.0015], 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 := r \cdot \tan b\\
\mathbf{if}\;t\_0 \leq -0.025:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.0015:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.025000000000000001 or 0.0015 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 50.6%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6450.7
Applied egg-rr50.7%
Taylor expanded in a around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6451.3
Simplified51.3%
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6451.4
Applied egg-rr51.4%
if -0.025000000000000001 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.0015Initial program 97.6%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6497.6
Simplified97.6%
Final simplification74.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((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 * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 74.1%
cos-sumN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.5
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (* (/ (- b a) -1.0) (/ (+ b a) (- a b)))))))
double code(double r, double a, double b) {
return sin(b) * (r / cos((((b - a) / -1.0) * ((b + a) / (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((((b - a) / (-1.0d0)) * ((b + a) / (a - b)))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((((b - a) / -1.0) * ((b + a) / (a - b)))));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((((b - a) / -1.0) * ((b + a) / (a - b)))))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(Float64(Float64(b - a) / -1.0) * Float64(Float64(b + a) / Float64(a - b)))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((((b - a) / -1.0) * ((b + a) / (a - b))))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(N[(N[(b - a), $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] / N[(a - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(\frac{b - a}{-1} \cdot \frac{b + a}{a - b}\right)}
\end{array}
Initial program 74.1%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6474.1
Applied egg-rr74.1%
+-commutativeN/A
flip-+N/A
frac-2negN/A
difference-of-squaresN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub0-negN/A
neg-mul-1N/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
associate--r-N/A
+-commutativeN/A
sub0-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
--lowering--.f6474.4
Applied egg-rr74.4%
Final simplification74.4%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (* (- a b) (/ (+ b a) (- b a)))))))
double code(double r, double a, double b) {
return r * (sin(b) / cos(((a - b) * ((b + a) / (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(((a - b) * ((b + a) / (b - a)))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos(((a - b) * ((b + a) / (b - a)))));
}
def code(r, a, b): return r * (math.sin(b) / math.cos(((a - b) * ((b + a) / (b - a)))))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(Float64(Float64(a - b) * Float64(Float64(b + a) / Float64(b - a)))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos(((a - b) * ((b + a) / (b - a))))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(\left(a - b\right) \cdot \frac{b + a}{b - a}\right)}
\end{array}
Initial program 74.1%
flip-+N/A
frac-2negN/A
distribute-frac-negN/A
cos-negN/A
cos-lowering-cos.f64N/A
/-lowering-/.f64N/A
difference-of-squaresN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f64N/A
--lowering--.f6448.4
Applied egg-rr48.4%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate--r-N/A
+-commutativeN/A
sub0-negN/A
sub-negN/A
--lowering--.f6474.4
Applied egg-rr74.4%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ b a)))))
double code(double r, double a, double b) {
return sin(b) * (r / 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 = sin(b) * (r / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((b + a)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((b + a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((b + a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(b + a\right)}
\end{array}
Initial program 74.1%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6474.1
Applied egg-rr74.1%
Final simplification74.1%
(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 74.1%
Final simplification74.1%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (tan b))))
(if (<= b -0.076)
t_0
(if (<= b 0.032)
(*
r
(/
(*
b
(fma
(* b b)
(fma
b
(* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
-0.16666666666666666)
1.0))
(cos (+ b a))))
(/ 1.0 (/ 1.0 t_0))))))
double code(double r, double a, double b) {
double t_0 = r * tan(b);
double tmp;
if (b <= -0.076) {
tmp = t_0;
} else if (b <= 0.032) {
tmp = r * ((b * fma((b * b), fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos((b + a)));
} else {
tmp = 1.0 / (1.0 / t_0);
}
return tmp;
}
function code(r, a, b) t_0 = Float64(r * tan(b)) tmp = 0.0 if (b <= -0.076) tmp = t_0; elseif (b <= 0.032) tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), 1.0)) / cos(Float64(b + a)))); else tmp = Float64(1.0 / Float64(1.0 / t_0)); end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.076], t$95$0, If[LessEqual[b, 0.032], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -0.076:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.032:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0}}\\
\end{array}
\end{array}
if b < -0.0759999999999999981Initial program 56.6%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6456.7
Applied egg-rr56.7%
Taylor expanded in a around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6458.2
Simplified58.2%
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6458.2
Applied egg-rr58.2%
if -0.0759999999999999981 < b < 0.032000000000000001Initial program 97.6%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6497.6
Simplified97.6%
if 0.032000000000000001 < b Initial program 42.9%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6442.9
Applied egg-rr42.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6442.6
Simplified42.6%
associate-*l/N/A
*-commutativeN/A
clear-numN/A
/-lowering-/.f64N/A
clear-numN/A
*-commutativeN/A
associate-*l/N/A
/-lowering-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6442.7
Applied egg-rr42.7%
Final simplification74.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (tan b))))
(if (<= b -0.0305)
t_0
(if (<= b 0.029)
(*
r
(/
(*
b
(fma
(* b b)
(fma (* b b) 0.008333333333333333 -0.16666666666666666)
1.0))
(cos (+ b a))))
(/ 1.0 (/ 1.0 t_0))))))
double code(double r, double a, double b) {
double t_0 = r * tan(b);
double tmp;
if (b <= -0.0305) {
tmp = t_0;
} else if (b <= 0.029) {
tmp = r * ((b * fma((b * b), fma((b * b), 0.008333333333333333, -0.16666666666666666), 1.0)) / cos((b + a)));
} else {
tmp = 1.0 / (1.0 / t_0);
}
return tmp;
}
function code(r, a, b) t_0 = Float64(r * tan(b)) tmp = 0.0 if (b <= -0.0305) tmp = t_0; elseif (b <= 0.029) tmp = Float64(r * Float64(Float64(b * fma(Float64(b * b), fma(Float64(b * b), 0.008333333333333333, -0.16666666666666666), 1.0)) / cos(Float64(b + a)))); else tmp = Float64(1.0 / Float64(1.0 / t_0)); end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.0305], t$95$0, If[LessEqual[b, 0.029], N[(r * N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -0.0305:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.029:\\
\;\;\;\;r \cdot \frac{b \cdot \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b \cdot b, 0.008333333333333333, -0.16666666666666666\right), 1\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0}}\\
\end{array}
\end{array}
if b < -0.030499999999999999Initial program 56.6%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6456.7
Applied egg-rr56.7%
Taylor expanded in a around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6458.2
Simplified58.2%
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6458.2
Applied egg-rr58.2%
if -0.030499999999999999 < b < 0.0290000000000000015Initial program 97.6%
Taylor expanded in b around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6497.6
Simplified97.6%
if 0.0290000000000000015 < b Initial program 42.9%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6442.9
Applied egg-rr42.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6442.6
Simplified42.6%
associate-*l/N/A
*-commutativeN/A
clear-numN/A
/-lowering-/.f64N/A
clear-numN/A
*-commutativeN/A
associate-*l/N/A
/-lowering-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6442.7
Applied egg-rr42.7%
Final simplification74.5%
(FPCore (r a b) :precision binary64 (* r (tan b)))
double code(double r, double a, double b) {
return r * tan(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 * tan(b)
end function
public static double code(double r, double a, double b) {
return r * Math.tan(b);
}
def code(r, a, b): return r * math.tan(b)
function code(r, a, b) return Float64(r * tan(b)) end
function tmp = code(r, a, b) tmp = r * tan(b); end
code[r_, a_, b_] := N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \tan b
\end{array}
Initial program 74.1%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sin-lowering-sin.f6474.1
Applied egg-rr74.1%
Taylor expanded in a around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6459.2
Simplified59.2%
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6459.2
Applied egg-rr59.2%
(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 74.1%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6451.2
Simplified51.2%
Taylor expanded in a around 0
Simplified36.0%
Final simplification36.0%
herbie shell --seed 2024199
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))