
(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 14 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 (- b)) (sin a) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma(sin(-b), sin(a), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(sin(Float64(-b)), sin(a), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[Sin[(-b)], $MachinePrecision] * N[Sin[a], $MachinePrecision] + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\mathsf{fma}\left(\sin \left(-b\right), \sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 79.4%
cos-sumN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
sin-negN/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.6
Applied egg-rr99.6%
Taylor expanded in r around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
accelerator-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
neg-mul-1N/A
sin-lowering-sin.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6499.6
Simplified99.6%
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.6
Applied egg-rr99.6%
(FPCore (r a b) :precision binary64 (let* ((t_0 (/ (sin b) (cos (+ b a)))) (t_1 (* r (tan b)))) (if (<= t_0 -2e-7) t_1 (if (<= t_0 0.05) (* 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 <= -2e-7) {
tmp = t_1;
} else if (t_0 <= 0.05) {
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 <= (-2d-7)) then
tmp = t_1
else if (t_0 <= 0.05d0) 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 <= -2e-7) {
tmp = t_1;
} else if (t_0 <= 0.05) {
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 <= -2e-7: tmp = t_1 elif t_0 <= 0.05: 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 <= -2e-7) tmp = t_1; elseif (t_0 <= 0.05) 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 <= -2e-7) tmp = t_1; elseif (t_0 <= 0.05) 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, -2e-7], t$95$1, If[LessEqual[t$95$0, 0.05], 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 -2 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.05:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -1.9999999999999999e-7 or 0.050000000000000003 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 57.6%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6458.4
Simplified58.4%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6458.4
Applied egg-rr58.4%
if -1.9999999999999999e-7 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 0.050000000000000003Initial program 99.3%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6499.2
Simplified99.2%
Final simplification79.8%
(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 79.4%
cos-sumN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
sin-negN/A
sin-lowering-sin.f64N/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f6499.6
Applied egg-rr99.6%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (fma (cos b) (cos a) (* (sin a) (- (sin b)))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), (sin(a) * -sin(b))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(a) * Float64(-sin(b)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin a \cdot \left(-\sin b\right)\right)}
\end{array}
Initial program 79.4%
cos-sumN/A
sub-negN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
neg-lowering-neg.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f6499.6
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b)
:precision binary64
(if (<= b -260000.0)
(* r (tan b))
(if (<= b 2050.0)
(*
r
(/
(fma
(fma
b
(* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
-0.16666666666666666)
(* b (* b b))
b)
(cos (+ b a))))
(/ (* (sin b) r) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -260000.0) {
tmp = r * tan(b);
} else if (b <= 2050.0) {
tmp = r * (fma(fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), (b * (b * b)), b) / cos((b + a)));
} else {
tmp = (sin(b) * r) / cos(b);
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if (b <= -260000.0) tmp = Float64(r * tan(b)); elseif (b <= 2050.0) tmp = Float64(r * Float64(fma(fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), Float64(b * Float64(b * b)), b) / cos(Float64(b + a)))); else tmp = Float64(Float64(sin(b) * r) / cos(b)); end return tmp end
code[r_, a_, b_] := If[LessEqual[b, -260000.0], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2050.0], N[(r * N[(N[(N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -260000:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 2050:\\
\;\;\;\;r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), b \cdot \left(b \cdot b\right), b\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos b}\\
\end{array}
\end{array}
if b < -2.6e5Initial program 53.8%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6455.7
Simplified55.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6455.9
Applied egg-rr55.9%
if -2.6e5 < b < 2050Initial program 98.0%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
Simplified98.0%
if 2050 < b Initial program 61.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6462.0
Simplified62.0%
Final simplification79.9%
(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(Float64(sin(b) * 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[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos \left(b + a\right)}
\end{array}
Initial program 79.4%
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f64N/A
+-commutativeN/A
+-lowering-+.f6479.4
Applied egg-rr79.4%
Final simplification79.4%
(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 79.4%
Final simplification79.4%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (tan b))))
(if (<= b -260000.0)
t_0
(if (<= b 2050.0)
(*
r
(/
(fma
(fma
b
(* b (fma (* b b) -0.0001984126984126984 0.008333333333333333))
-0.16666666666666666)
(* b (* b b))
b)
(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 <= -260000.0) {
tmp = t_0;
} else if (b <= 2050.0) {
tmp = r * (fma(fma(b, (b * fma((b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), (b * (b * b)), b) / 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 <= -260000.0) tmp = t_0; elseif (b <= 2050.0) tmp = Float64(r * Float64(fma(fma(b, Float64(b * fma(Float64(b * b), -0.0001984126984126984, 0.008333333333333333)), -0.16666666666666666), Float64(b * Float64(b * b)), b) / 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, -260000.0], t$95$0, If[LessEqual[b, 2050.0], N[(r * N[(N[(N[(b * N[(b * N[(N[(b * b), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision] + b), $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 -260000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 2050:\\
\;\;\;\;r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b \cdot b, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), b \cdot \left(b \cdot b\right), b\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0}}\\
\end{array}
\end{array}
if b < -2.6e5Initial program 53.8%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6455.7
Simplified55.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6455.9
Applied egg-rr55.9%
if -2.6e5 < b < 2050Initial program 98.0%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
Simplified98.0%
if 2050 < b Initial program 61.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6462.0
Simplified62.0%
clear-numN/A
/-lowering-/.f64N/A
clear-numN/A
/-lowering-/.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6461.8
Applied egg-rr61.8%
Final simplification79.9%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (tan b))))
(if (<= b -260000.0)
t_0
(if (<= b 0.04)
(* r (/ (fma b (* b (* b -0.16666666666666666)) b) (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 <= -260000.0) {
tmp = t_0;
} else if (b <= 0.04) {
tmp = r * (fma(b, (b * (b * -0.16666666666666666)), b) / 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 <= -260000.0) tmp = t_0; elseif (b <= 0.04) tmp = Float64(r * Float64(fma(b, Float64(b * Float64(b * -0.16666666666666666)), b) / 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, -260000.0], t$95$0, If[LessEqual[b, 0.04], N[(r * N[(N[(b * N[(b * N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + b), $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 -260000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.04:\\
\;\;\;\;r \cdot \frac{\mathsf{fma}\left(b, b \cdot \left(b \cdot -0.16666666666666666\right), b\right)}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0}}\\
\end{array}
\end{array}
if b < -2.6e5Initial program 53.8%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6455.7
Simplified55.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6455.9
Applied egg-rr55.9%
if -2.6e5 < b < 0.0400000000000000008Initial program 98.7%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6498.6
Simplified98.6%
if 0.0400000000000000008 < b Initial program 61.5%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6461.6
Simplified61.6%
clear-numN/A
/-lowering-/.f64N/A
clear-numN/A
/-lowering-/.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6461.4
Applied egg-rr61.4%
Final simplification79.8%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (tan b))))
(if (<= b -3.2e-7)
t_0
(if (<= b 0.04) (* r (/ b (cos 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 <= -3.2e-7) {
tmp = t_0;
} else if (b <= 0.04) {
tmp = r * (b / cos(a));
} else {
tmp = 1.0 / (1.0 / 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 * tan(b)
if (b <= (-3.2d-7)) then
tmp = t_0
else if (b <= 0.04d0) then
tmp = r * (b / cos(a))
else
tmp = 1.0d0 / (1.0d0 / t_0)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = r * Math.tan(b);
double tmp;
if (b <= -3.2e-7) {
tmp = t_0;
} else if (b <= 0.04) {
tmp = r * (b / Math.cos(a));
} else {
tmp = 1.0 / (1.0 / t_0);
}
return tmp;
}
def code(r, a, b): t_0 = r * math.tan(b) tmp = 0 if b <= -3.2e-7: tmp = t_0 elif b <= 0.04: tmp = r * (b / math.cos(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 <= -3.2e-7) tmp = t_0; elseif (b <= 0.04) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(1.0 / Float64(1.0 / t_0)); end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * tan(b); tmp = 0.0; if (b <= -3.2e-7) tmp = t_0; elseif (b <= 0.04) tmp = r * (b / cos(a)); else tmp = 1.0 / (1.0 / t_0); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.2e-7], t$95$0, If[LessEqual[b, 0.04], N[(r * N[(b / N[Cos[a], $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 -3.2 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.04:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{t\_0}}\\
\end{array}
\end{array}
if b < -3.2000000000000001e-7Initial program 54.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6455.6
Simplified55.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6455.7
Applied egg-rr55.7%
if -3.2000000000000001e-7 < b < 0.0400000000000000008Initial program 99.3%
Taylor expanded in b around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6499.3
Simplified99.3%
if 0.0400000000000000008 < b Initial program 61.5%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6461.6
Simplified61.6%
clear-numN/A
/-lowering-/.f64N/A
clear-numN/A
/-lowering-/.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6461.4
Applied egg-rr61.4%
Final simplification79.8%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* r (tan b)))) (if (<= b -3.2e-7) t_0 (if (<= b 0.04) (* r (/ b (cos a))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * tan(b);
double tmp;
if (b <= -3.2e-7) {
tmp = t_0;
} else if (b <= 0.04) {
tmp = r * (b / cos(a));
} 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 * tan(b)
if (b <= (-3.2d-7)) then
tmp = t_0
else if (b <= 0.04d0) then
tmp = r * (b / cos(a))
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.tan(b);
double tmp;
if (b <= -3.2e-7) {
tmp = t_0;
} else if (b <= 0.04) {
tmp = r * (b / Math.cos(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * math.tan(b) tmp = 0 if b <= -3.2e-7: tmp = t_0 elif b <= 0.04: tmp = r * (b / math.cos(a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * tan(b)) tmp = 0.0 if (b <= -3.2e-7) tmp = t_0; elseif (b <= 0.04) tmp = Float64(r * Float64(b / cos(a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * tan(b); tmp = 0.0; if (b <= -3.2e-7) tmp = t_0; elseif (b <= 0.04) tmp = r * (b / cos(a)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.2e-7], t$95$0, If[LessEqual[b, 0.04], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \tan b\\
\mathbf{if}\;b \leq -3.2 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.04:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -3.2000000000000001e-7 or 0.0400000000000000008 < b Initial program 57.6%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6458.4
Simplified58.4%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6458.4
Applied egg-rr58.4%
if -3.2000000000000001e-7 < b < 0.0400000000000000008Initial program 99.3%
Taylor expanded in b around 0
/-lowering-/.f64N/A
cos-lowering-cos.f6499.3
Simplified99.3%
Final simplification79.8%
(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 79.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
cos-lowering-cos.f6461.4
Simplified61.4%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
quot-tanN/A
tan-lowering-tan.f6461.4
Applied egg-rr61.4%
Final simplification61.4%
(FPCore (r a b) :precision binary64 (* (sin b) r))
double code(double r, double a, double b) {
return sin(b) * r;
}
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
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * r;
}
def code(r, a, b): return math.sin(b) * r
function code(r, a, b) return Float64(sin(b) * r) end
function tmp = code(r, a, b) tmp = sin(b) * r; end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot r
\end{array}
Initial program 79.4%
Taylor expanded in b around 0
cos-lowering-cos.f6457.4
Simplified57.4%
Taylor expanded in a around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6439.5
Simplified39.5%
Final simplification39.5%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return b * r;
}
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
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 79.4%
Taylor expanded in b around 0
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
cos-lowering-cos.f6454.0
Simplified54.0%
Taylor expanded in a around 0
*-lowering-*.f6435.6
Simplified35.6%
herbie shell --seed 2024204
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))