
(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 10 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 (cos b) (cos a) (* (- (sin a)) (sin b)))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma(cos(b), cos(a), (-sin(a) * sin(b)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(cos(b), cos(a), Float64(Float64(-sin(a)) * sin(b)))) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[((-N[Sin[a], $MachinePrecision]) * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin a\right) \cdot \sin b\right)}
\end{array}
Initial program 77.3%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/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
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.4
Applied rewrites99.4%
Applied rewrites99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ a b)))))
(if (or (<= t_0 -2e-6) (not (<= t_0 2e-8)))
(* (sin b) (/ r (cos b)))
(* (/ r (cos a)) b))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((a + b));
double tmp;
if ((t_0 <= -2e-6) || !(t_0 <= 2e-8)) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = (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) :: t_0
real(8) :: tmp
t_0 = sin(b) / cos((a + b))
if ((t_0 <= (-2d-6)) .or. (.not. (t_0 <= 2d-8))) then
tmp = sin(b) * (r / cos(b))
else
tmp = (r / cos(a)) * 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 <= -2e-6) || !(t_0 <= 2e-8)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = (r / Math.cos(a)) * b;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((a + b)) tmp = 0 if (t_0 <= -2e-6) or not (t_0 <= 2e-8): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = (r / math.cos(a)) * b return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(a + b))) tmp = 0.0 if ((t_0 <= -2e-6) || !(t_0 <= 2e-8)) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(Float64(r / cos(a)) * 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 <= -2e-6) || ~((t_0 <= 2e-8))) tmp = sin(b) * (r / cos(b)); else tmp = (r / cos(a)) * 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[Or[LessEqual[t$95$0, -2e-6], N[Not[LessEqual[t$95$0, 2e-8]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(a + b\right)}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-6} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-8}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos a} \cdot b\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -1.99999999999999991e-6 or 2e-8 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 59.3%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6458.6
Applied rewrites58.6%
if -1.99999999999999991e-6 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < 2e-8Initial program 99.5%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6499.5
Applied rewrites99.5%
Final simplification76.9%
(FPCore (r a b) :precision binary64 (if (or (<= a -3.05e-5) (not (<= a 6.8e-6))) (* r (/ (sin b) (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -3.05e-5) || !(a <= 6.8e-6)) {
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) :: tmp
if ((a <= (-3.05d-5)) .or. (.not. (a <= 6.8d-6))) 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 tmp;
if ((a <= -3.05e-5) || !(a <= 6.8e-6)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -3.05e-5) or not (a <= 6.8e-6): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -3.05e-5) || !(a <= 6.8e-6)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -3.05e-5) || ~((a <= 6.8e-6))) tmp = r * (sin(b) / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -3.05e-5], N[Not[LessEqual[a, 6.8e-6]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.05 \cdot 10^{-5} \lor \neg \left(a \leq 6.8 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -3.04999999999999994e-5 or 6.80000000000000012e-6 < a Initial program 53.4%
Taylor expanded in b around 0
lower-cos.f6452.9
Applied rewrites52.9%
if -3.04999999999999994e-5 < a < 6.80000000000000012e-6Initial program 97.5%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f6497.6
Applied rewrites97.6%
Final simplification77.2%
(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 77.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.4
Applied rewrites77.4%
(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 77.3%
(FPCore (r a b)
:precision binary64
(if (or (<= b -2050000000000.0) (not (<= b 4.9)))
(* r (/ (sin b) 1.0))
(*
r
(/
(fma (fma (fma -0.16666666666666666 b 0.0) b 1.0) b 0.0)
(cos (+ a b))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2050000000000.0) || !(b <= 4.9)) {
tmp = r * (sin(b) / 1.0);
} else {
tmp = r * (fma(fma(fma(-0.16666666666666666, b, 0.0), b, 1.0), b, 0.0) / cos((a + b)));
}
return tmp;
}
function code(r, a, b) tmp = 0.0 if ((b <= -2050000000000.0) || !(b <= 4.9)) tmp = Float64(r * Float64(sin(b) / 1.0)); else tmp = Float64(r * Float64(fma(fma(fma(-0.16666666666666666, b, 0.0), b, 1.0), b, 0.0) / cos(Float64(a + b)))); end return tmp end
code[r_, a_, b_] := If[Or[LessEqual[b, -2050000000000.0], N[Not[LessEqual[b, 4.9]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[(N[(N[(-0.16666666666666666 * b + 0.0), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 0.0), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2050000000000 \lor \neg \left(b \leq 4.9\right):\\
\;\;\;\;r \cdot \frac{\sin b}{1}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, b, 0\right), b, 1\right), b, 0\right)}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -2.05e12 or 4.9000000000000004 < b Initial program 58.0%
Taylor expanded in b around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f646.6
Applied rewrites6.6%
Taylor expanded in a around 0
Applied rewrites6.5%
Taylor expanded in a around 0
Applied rewrites12.1%
if -2.05e12 < b < 4.9000000000000004Initial program 97.9%
remove-double-negN/A
lift-sin.f64N/A
sin-+PI-revN/A
sin-neg-revN/A
lower-sin.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-PI.f6410.7
Applied rewrites10.7%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites96.1%
Final simplification52.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.0064) (not (<= b 1.65e+15))) (* r (/ (sin b) 1.0)) (* r (/ b (cos (+ a b))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0064) || !(b <= 1.65e+15)) {
tmp = r * (sin(b) / 1.0);
} else {
tmp = r * (b / 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 <= (-0.0064d0)) .or. (.not. (b <= 1.65d+15))) then
tmp = r * (sin(b) / 1.0d0)
else
tmp = r * (b / cos((a + b)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0064) || !(b <= 1.65e+15)) {
tmp = r * (Math.sin(b) / 1.0);
} else {
tmp = r * (b / Math.cos((a + b)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.0064) or not (b <= 1.65e+15): tmp = r * (math.sin(b) / 1.0) else: tmp = r * (b / math.cos((a + b))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.0064) || !(b <= 1.65e+15)) tmp = Float64(r * Float64(sin(b) / 1.0)); else tmp = Float64(r * Float64(b / cos(Float64(a + b)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.0064) || ~((b <= 1.65e+15))) tmp = r * (sin(b) / 1.0); else tmp = r * (b / cos((a + b))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.0064], N[Not[LessEqual[b, 1.65e+15]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0064 \lor \neg \left(b \leq 1.65 \cdot 10^{+15}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{1}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -0.00640000000000000031 or 1.65e15 < b Initial program 57.4%
Taylor expanded in b around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f646.9
Applied rewrites6.9%
Taylor expanded in a around 0
Applied rewrites6.5%
Taylor expanded in a around 0
Applied rewrites12.2%
if -0.00640000000000000031 < b < 1.65e15Initial program 98.2%
remove-double-negN/A
lift-sin.f64N/A
sin-+PI-revN/A
sin-neg-revN/A
lower-sin.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-PI.f6411.4
Applied rewrites11.4%
Taylor expanded in b around 0
associate-*r*N/A
*-commutativeN/A
cos-negN/A
cos-PIN/A
associate-*r*N/A
metadata-evalN/A
*-rgt-identityN/A
lower-+.f64N/A
sin-negN/A
sin-PIN/A
metadata-eval94.5
Applied rewrites94.5%
Final simplification52.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.05e+14) (not (<= b 1320000000000.0))) (* r (/ (sin b) 1.0)) (* (/ r (cos a)) b)))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.05e+14) || !(b <= 1320000000000.0)) {
tmp = r * (sin(b) / 1.0);
} else {
tmp = (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 <= (-1.05d+14)) .or. (.not. (b <= 1320000000000.0d0))) then
tmp = r * (sin(b) / 1.0d0)
else
tmp = (r / cos(a)) * b
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -1.05e+14) || !(b <= 1320000000000.0)) {
tmp = r * (Math.sin(b) / 1.0);
} else {
tmp = (r / Math.cos(a)) * b;
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.05e+14) or not (b <= 1320000000000.0): tmp = r * (math.sin(b) / 1.0) else: tmp = (r / math.cos(a)) * b return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.05e+14) || !(b <= 1320000000000.0)) tmp = Float64(r * Float64(sin(b) / 1.0)); else tmp = Float64(Float64(r / cos(a)) * b); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.05e+14) || ~((b <= 1320000000000.0))) tmp = r * (sin(b) / 1.0); else tmp = (r / cos(a)) * b; end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.05e+14], N[Not[LessEqual[b, 1320000000000.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{+14} \lor \neg \left(b \leq 1320000000000\right):\\
\;\;\;\;r \cdot \frac{\sin b}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos a} \cdot b\\
\end{array}
\end{array}
if b < -1.05e14 or 1.32e12 < b Initial program 58.4%
Taylor expanded in b around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f646.5
Applied rewrites6.5%
Taylor expanded in a around 0
Applied rewrites6.4%
Taylor expanded in a around 0
Applied rewrites12.3%
if -1.05e14 < b < 1.32e12Initial program 96.0%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6491.8
Applied rewrites91.8%
Final simplification52.4%
(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 77.3%
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 (* 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 77.3%
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%
Taylor expanded in a around 0
Applied rewrites32.6%
herbie shell --seed 2024343
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))