
(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 13 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) (fma (sin b) (- (sin a)) (* (/ -1.0 (/ -1.0 (cos a))) (cos b)))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(sin(b), -sin(a), ((-1.0 / (-1.0 / cos(a))) * cos(b)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(sin(b), Float64(-sin(a)), Float64(Float64(-1.0 / Float64(-1.0 / cos(a))) * cos(b)))) * r) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision]) + N[(N[(-1.0 / N[(-1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\sin b, -\sin a, \frac{-1}{\frac{-1}{\cos a}} \cdot \cos b\right)} \cdot r
\end{array}
Initial program 79.4%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
/-rgt-identityN/A
clear-numN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6499.6
Applied rewrites99.6%
lift-/.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.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (cos (+ a b)))
(t_1 (/ (sin b) t_0))
(t_2 (* (/ r (cos b)) (sin b))))
(if (<= t_1 -0.02)
t_2
(if (<= t_1 2e-16)
(* (/ (fma (* b b) (* -0.16666666666666666 b) b) t_0) r)
t_2))))
double code(double r, double a, double b) {
double t_0 = cos((a + b));
double t_1 = sin(b) / t_0;
double t_2 = (r / cos(b)) * sin(b);
double tmp;
if (t_1 <= -0.02) {
tmp = t_2;
} else if (t_1 <= 2e-16) {
tmp = (fma((b * b), (-0.16666666666666666 * b), b) / t_0) * r;
} else {
tmp = t_2;
}
return tmp;
}
function code(r, a, b) t_0 = cos(Float64(a + b)) t_1 = Float64(sin(b) / t_0) t_2 = Float64(Float64(r / cos(b)) * sin(b)) tmp = 0.0 if (t_1 <= -0.02) tmp = t_2; elseif (t_1 <= 2e-16) tmp = Float64(Float64(fma(Float64(b * b), Float64(-0.16666666666666666 * b), b) / t_0) * r); else tmp = t_2; end return 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]}, Block[{t$95$2 = N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.02], t$95$2, If[LessEqual[t$95$1, 2e-16], N[(N[(N[(N[(b * b), $MachinePrecision] * N[(-0.16666666666666666 * b), $MachinePrecision] + b), $MachinePrecision] / t$95$0), $MachinePrecision] * r), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(a + b\right)\\
t_1 := \frac{\sin b}{t\_0}\\
t_2 := \frac{r}{\cos b} \cdot \sin b\\
\mathbf{if}\;t\_1 \leq -0.02:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b \cdot b, -0.16666666666666666 \cdot b, b\right)}{t\_0} \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0200000000000000004 or 2e-16 < (/.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.f6453.5
Applied rewrites53.5%
if -0.0200000000000000004 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 2e-16Initial program 99.6%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
cube-unmultN/A
lower-pow.f6499.6
Applied rewrites99.6%
Applied rewrites99.6%
Final simplification79.6%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (cos (+ a b)))
(t_1 (/ (sin b) t_0))
(t_2 (/ r (- (pow (tan b) -1.0) a))))
(if (<= t_1 -0.02)
t_2
(if (<= t_1 2e-16)
(* (/ (fma (* b b) (* -0.16666666666666666 b) b) t_0) r)
t_2))))
double code(double r, double a, double b) {
double t_0 = cos((a + b));
double t_1 = sin(b) / t_0;
double t_2 = r / (pow(tan(b), -1.0) - a);
double tmp;
if (t_1 <= -0.02) {
tmp = t_2;
} else if (t_1 <= 2e-16) {
tmp = (fma((b * b), (-0.16666666666666666 * b), b) / t_0) * r;
} else {
tmp = t_2;
}
return tmp;
}
function code(r, a, b) t_0 = cos(Float64(a + b)) t_1 = Float64(sin(b) / t_0) t_2 = Float64(r / Float64((tan(b) ^ -1.0) - a)) tmp = 0.0 if (t_1 <= -0.02) tmp = t_2; elseif (t_1 <= 2e-16) tmp = Float64(Float64(fma(Float64(b * b), Float64(-0.16666666666666666 * b), b) / t_0) * r); else tmp = t_2; end return 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]}, Block[{t$95$2 = N[(r / N[(N[Power[N[Tan[b], $MachinePrecision], -1.0], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.02], t$95$2, If[LessEqual[t$95$1, 2e-16], N[(N[(N[(N[(b * b), $MachinePrecision] * N[(-0.16666666666666666 * b), $MachinePrecision] + b), $MachinePrecision] / t$95$0), $MachinePrecision] * r), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(a + b\right)\\
t_1 := \frac{\sin b}{t\_0}\\
t_2 := \frac{r}{{\tan b}^{-1} - a}\\
\mathbf{if}\;t\_1 \leq -0.02:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b \cdot b, -0.16666666666666666 \cdot b, b\right)}{t\_0} \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0200000000000000004 or 2e-16 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 53.0%
lift-/.f64N/A
clear-numN/A
inv-powN/A
pow-to-expN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-log.f64N/A
lower-/.f6429.7
Applied rewrites29.7%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6450.7
Applied rewrites50.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
un-div-invN/A
lower-/.f6450.6
Applied rewrites50.6%
if -0.0200000000000000004 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 2e-16Initial program 99.6%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
unpow2N/A
cube-unmultN/A
lower-pow.f6499.6
Applied rewrites99.6%
Applied rewrites99.6%
Final simplification78.4%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (fma (sin b) (- (sin a)) (* (cos a) (cos b)))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(sin(b), -sin(a), (cos(a) * cos(b)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(sin(b), Float64(-sin(a)), Float64(cos(a) * cos(b)))) * r) end
code[r_, a_, b_] := N[(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] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos a \cdot \cos b\right)} \cdot r
\end{array}
Initial program 79.4%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (fma (cos b) (cos a) (* (- (sin b)) (sin a)))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(cos(b), cos(a), (-sin(b) * sin(a)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(cos(b), cos(a), Float64(Float64(-sin(b)) * sin(a)))) * r) end
code[r_, a_, b_] := N[(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] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)} \cdot r
\end{array}
Initial program 79.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.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (fma (- (sin a)) (sin b) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma(-sin(a), sin(b), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(Float64(-sin(a)), sin(b), Float64(cos(a) * cos(b)))) 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[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\mathsf{fma}\left(-\sin a, \sin b, \cos a \cdot \cos b\right)}
\end{array}
Initial program 79.4%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
Taylor expanded in r around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-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%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (<= b -1.32e-5) (* (/ r (cos b)) (sin b)) (if (<= b 7.5e-29) (* (/ b (cos a)) r) (/ (* (sin b) r) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.32e-5) {
tmp = (r / cos(b)) * sin(b);
} else if (b <= 7.5e-29) {
tmp = (b / cos(a)) * r;
} 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) :: tmp
if (b <= (-1.32d-5)) then
tmp = (r / cos(b)) * sin(b)
else if (b <= 7.5d-29) then
tmp = (b / cos(a)) * r
else
tmp = (sin(b) * r) / cos(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -1.32e-5) {
tmp = (r / Math.cos(b)) * Math.sin(b);
} else if (b <= 7.5e-29) {
tmp = (b / Math.cos(a)) * r;
} else {
tmp = (Math.sin(b) * r) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.32e-5: tmp = (r / math.cos(b)) * math.sin(b) elif b <= 7.5e-29: tmp = (b / math.cos(a)) * r else: tmp = (math.sin(b) * r) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.32e-5) tmp = Float64(Float64(r / cos(b)) * sin(b)); elseif (b <= 7.5e-29) tmp = Float64(Float64(b / cos(a)) * r); else tmp = Float64(Float64(sin(b) * r) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -1.32e-5) tmp = (r / cos(b)) * sin(b); elseif (b <= 7.5e-29) tmp = (b / cos(a)) * r; else tmp = (sin(b) * r) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.32e-5], N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-29], N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.32 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\cos b} \cdot \sin b\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-29}:\\
\;\;\;\;\frac{b}{\cos a} \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos b}\\
\end{array}
\end{array}
if b < -1.32000000000000007e-5Initial program 56.7%
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.f6456.8
Applied rewrites56.8%
if -1.32000000000000007e-5 < b < 7.50000000000000006e-29Initial program 99.6%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
if 7.50000000000000006e-29 < b Initial program 51.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
Taylor expanded in a around 0
lower-cos.f6452.4
Applied rewrites52.4%
Final simplification79.6%
(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 79.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6479.4
Applied rewrites79.4%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (cos (+ a b))) r))
double code(double r, double a, double b) {
return (sin(b) / cos((a + 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) / cos((a + b))) * r
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) / Math.cos((a + b))) * r;
}
def code(r, a, b): return (math.sin(b) / math.cos((a + b))) * r
function code(r, a, b) return Float64(Float64(sin(b) / cos(Float64(a + b))) * r) end
function tmp = code(r, a, b) tmp = (sin(b) / cos((a + b))) * r; end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\cos \left(a + b\right)} \cdot r
\end{array}
Initial program 79.4%
Final simplification79.4%
(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 79.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6479.4
Applied rewrites79.4%
Taylor expanded in b around 0
lower-*.f6458.3
Applied rewrites58.3%
(FPCore (r a b) :precision binary64 (* (/ b (cos a)) r))
double code(double r, double a, double b) {
return (b / cos(a)) * 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 / cos(a)) * r
end function
public static double code(double r, double a, double b) {
return (b / Math.cos(a)) * r;
}
def code(r, a, b): return (b / math.cos(a)) * r
function code(r, a, b) return Float64(Float64(b / cos(a)) * r) end
function tmp = code(r, a, b) tmp = (b / cos(a)) * r; end
code[r_, a_, b_] := N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{\cos a} \cdot r
\end{array}
Initial program 79.4%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6458.2
Applied rewrites58.2%
Final simplification58.2%
(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 79.4%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6458.2
Applied rewrites58.2%
(FPCore (r a b) :precision binary64 (* (/ b 1.0) r))
double code(double r, double a, double b) {
return (b / 1.0) * 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 / 1.0d0) * r
end function
public static double code(double r, double a, double b) {
return (b / 1.0) * r;
}
def code(r, a, b): return (b / 1.0) * r
function code(r, a, b) return Float64(Float64(b / 1.0) * r) end
function tmp = code(r, a, b) tmp = (b / 1.0) * r; end
code[r_, a_, b_] := N[(N[(b / 1.0), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{1} \cdot r
\end{array}
Initial program 79.4%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6458.2
Applied rewrites58.2%
Taylor expanded in a around 0
Applied rewrites40.2%
Final simplification40.2%
herbie shell --seed 2024331
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))