
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (fma (/ (pow (sin b) 2.0) (sin b)) (- (sin a)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma((pow(sin(b), 2.0) / sin(b)), -sin(a), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(Float64((sin(b) ^ 2.0) / sin(b)), Float64(-sin(a)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Power[N[Sin[b], $MachinePrecision], 2.0], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $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(\frac{{\sin b}^{2}}{\sin b}, -\sin a, \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.5
Applied rewrites99.5%
+-lft-identityN/A
flip-+N/A
neg-sub0N/A
lift-neg.f64N/A
lower-/.f64N/A
metadata-evalN/A
sub0-negN/A
lower-neg.f64N/A
pow2N/A
lower-pow.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(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(b), Float64(-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 b, -\sin a, \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.5
Applied rewrites99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (- (* (cos a) (cos b)) (* (sin a) (sin b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / ((cos(a) * cos(b)) - (sin(a) * 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 = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(a) * sin(b)))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(a) * Math.sin(b)));
}
def code(r, a, b): return (math.sin(b) * r) / ((math.cos(a) * math.cos(b)) - (math.sin(a) * math.sin(b)))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(a) * sin(b)))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / ((cos(a) * cos(b)) - (sin(a) * sin(b))); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos a \cdot \cos b - \sin a \cdot \sin b}
\end{array}
Initial program 79.4%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (fma (cos a) (/ (cos b) (sin b)) (- (sin a)))))
double code(double r, double a, double b) {
return r / fma(cos(a), (cos(b) / sin(b)), -sin(a));
}
function code(r, a, b) return Float64(r / fma(cos(a), Float64(cos(b) / sin(b)), Float64(-sin(a)))) end
code[r_, a_, b_] := N[(r / N[(N[Cos[a], $MachinePrecision] * N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] + (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\mathsf{fma}\left(\cos a, \frac{\cos b}{\sin b}, -\sin a\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.5
Applied rewrites99.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
+-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
Applied rewrites79.3%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow-1N/A
div-invN/A
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
div-subN/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
*-lft-identityN/A
times-fracN/A
/-rgt-identityN/A
Applied rewrites99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (/ (* (cos a) (cos b)) (sin b)) (sin a))))
double code(double r, double a, double b) {
return r / (((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 / (((cos(a) * cos(b)) / sin(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / (((Math.cos(a) * Math.cos(b)) / Math.sin(b)) - Math.sin(a));
}
def code(r, a, b): return r / (((math.cos(a) * math.cos(b)) / math.sin(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(a) * cos(b)) / sin(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / (((cos(a) * cos(b)) / sin(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a \cdot \cos b}{\sin b} - \sin a}
\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.5
Applied rewrites99.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
+-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
Applied rewrites79.3%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow-1N/A
div-invN/A
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
Applied rewrites99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* (/ r (cos b)) (sin b))))
(if (<= b -0.0275)
t_0
(if (<= b 0.045)
(/
(*
(fma
(* (fma 0.008333333333333333 (* b b) -0.16666666666666666) r)
(* b b)
r)
b)
(cos (+ a b)))
t_0))))
double code(double r, double a, double b) {
double t_0 = (r / cos(b)) * sin(b);
double tmp;
if (b <= -0.0275) {
tmp = t_0;
} else if (b <= 0.045) {
tmp = (fma((fma(0.008333333333333333, (b * b), -0.16666666666666666) * r), (b * b), r) * b) / cos((a + b));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(Float64(r / cos(b)) * sin(b)) tmp = 0.0 if (b <= -0.0275) tmp = t_0; elseif (b <= 0.045) tmp = Float64(Float64(fma(Float64(fma(0.008333333333333333, Float64(b * b), -0.16666666666666666) * r), Float64(b * b), r) * b) / cos(Float64(a + b))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.0275], t$95$0, If[LessEqual[b, 0.045], N[(N[(N[(N[(N[(0.008333333333333333 * N[(b * b), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * r), $MachinePrecision] * N[(b * b), $MachinePrecision] + r), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{r}{\cos b} \cdot \sin b\\
\mathbf{if}\;b \leq -0.0275:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 0.045:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, b \cdot b, -0.16666666666666666\right) \cdot r, b \cdot b, r\right) \cdot b}{\cos \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -0.0275000000000000001 or 0.044999999999999998 < b Initial program 55.8%
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.f6455.6
Applied rewrites55.6%
if -0.0275000000000000001 < b < 0.044999999999999998Initial program 99.0%
Taylor expanded in b around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.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 79.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6479.4
Applied rewrites79.4%
(FPCore (r a b) :precision binary64 (if (<= b 5e+27) (/ r (* (/ (fma (* b b) 0.16666666666666666 1.0) b) (cos (+ a b)))) (/ (* (sin b) r) 1.0)))
double code(double r, double a, double b) {
double tmp;
if (b <= 5e+27) {
tmp = r / ((fma((b * b), 0.16666666666666666, 1.0) / b) * cos((a + b)));
} else {
tmp = (sin(b) * r) / 1.0;
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if (b <= 5e+27) tmp = Float64(r / Float64(Float64(fma(Float64(b * b), 0.16666666666666666, 1.0) / b) * cos(Float64(a + b)))); else tmp = Float64(Float64(sin(b) * r) / 1.0); end return tmp end
code[r_, a_, b_] := If[LessEqual[b, 5e+27], N[(r / N[(N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666 + 1.0), $MachinePrecision] / b), $MachinePrecision] * N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{+27}:\\
\;\;\;\;\frac{r}{\frac{\mathsf{fma}\left(b \cdot b, 0.16666666666666666, 1\right)}{b} \cdot \cos \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{1}\\
\end{array}
\end{array}
if b < 4.99999999999999979e27Initial program 86.6%
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%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-sumN/A
+-commutativeN/A
lift-+.f64N/A
lift-cos.f64N/A
associate-/l*N/A
Applied rewrites86.5%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6471.0
Applied rewrites71.0%
if 4.99999999999999979e27 < b Initial program 54.3%
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.3
Applied rewrites99.3%
Taylor expanded in a around 0
lower-cos.f6454.2
Applied rewrites54.2%
Taylor expanded in b around 0
Applied rewrites12.1%
Final simplification57.9%
(FPCore (r a b) :precision binary64 (if (<= b 1.12e+28) (/ (* b r) (cos a)) (/ (* (sin b) r) 1.0)))
double code(double r, double a, double b) {
double tmp;
if (b <= 1.12e+28) {
tmp = (b * r) / cos(a);
} else {
tmp = (sin(b) * r) / 1.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) :: tmp
if (b <= 1.12d+28) then
tmp = (b * r) / cos(a)
else
tmp = (sin(b) * r) / 1.0d0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 1.12e+28) {
tmp = (b * r) / Math.cos(a);
} else {
tmp = (Math.sin(b) * r) / 1.0;
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 1.12e+28: tmp = (b * r) / math.cos(a) else: tmp = (math.sin(b) * r) / 1.0 return tmp
function code(r, a, b) tmp = 0.0 if (b <= 1.12e+28) tmp = Float64(Float64(b * r) / cos(a)); else tmp = Float64(Float64(sin(b) * r) / 1.0); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 1.12e+28) tmp = (b * r) / cos(a); else tmp = (sin(b) * r) / 1.0; end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 1.12e+28], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.12 \cdot 10^{+28}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{1}\\
\end{array}
\end{array}
if b < 1.12e28Initial program 86.6%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6471.0
Applied rewrites71.0%
Applied rewrites71.0%
if 1.12e28 < b Initial program 54.3%
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.3
Applied rewrites99.3%
Taylor expanded in a around 0
lower-cos.f6454.2
Applied rewrites54.2%
Taylor expanded in b around 0
Applied rewrites12.1%
Final simplification57.9%
(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(Float64(b * r) / cos(a)) end
function tmp = code(r, a, b) tmp = (b * r) / cos(a); end
code[r_, a_, b_] := N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot r}{\cos a}
\end{array}
Initial program 79.4%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6455.9
Applied rewrites55.9%
Applied rewrites55.9%
(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%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6455.9
Applied rewrites55.9%
(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
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6455.9
Applied rewrites55.9%
Applied rewrites55.9%
Final simplification55.9%
(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
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6455.9
Applied rewrites55.9%
Taylor expanded in a around 0
Applied rewrites35.3%
herbie shell --seed 2024327
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))