
(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
(let* ((t_0 (* (sin b) (sin a))))
(/
(* r (sin b))
(+ (- (* (cos a) (cos b)) t_0) (fma (- (sin b)) (sin a) t_0)))))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return (r * sin(b)) / (((cos(a) * cos(b)) - t_0) + fma(-sin(b), sin(a), t_0));
}
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(Float64(r * sin(b)) / Float64(Float64(Float64(cos(a) * cos(b)) - t_0) + fma(Float64(-sin(b)), sin(a), t_0))) end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\frac{r \cdot \sin b}{\left(\cos a \cdot \cos b - t\_0\right) + \mathsf{fma}\left(-\sin b, \sin a, t\_0\right)}
\end{array}
\end{array}
Initial program 73.5%
+-commutative73.5%
Simplified73.5%
cos-sum99.4%
*-un-lft-identity99.4%
prod-diff99.4%
Applied egg-rr99.4%
*-rgt-identity99.4%
fma-neg99.4%
*-commutative99.4%
*-commutative99.4%
fma-undefine99.4%
*-rgt-identity99.4%
distribute-lft-neg-in99.4%
*-rgt-identity99.4%
fma-undefine99.4%
*-commutative99.4%
Simplified99.4%
Final simplification99.4%
(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 73.5%
associate-/l*73.6%
remove-double-neg73.6%
remove-double-neg73.6%
+-commutative73.6%
Simplified73.6%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 73.5%
+-commutative73.5%
Simplified73.5%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (sin b) (- (sin a)) (cos (+ b a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(b), -sin(a), cos((b + a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(b), Float64(-sin(a)), cos(Float64(b + a)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision]) + N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos \left(b + a\right)\right)}
\end{array}
Initial program 73.5%
+-commutative73.5%
Simplified73.5%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-define99.4%
Applied egg-rr99.4%
Applied egg-rr12.6%
count-212.6%
*-commutative12.6%
Simplified12.6%
Applied egg-rr75.5%
fma-undefine75.5%
*-commutative75.5%
fma-define75.5%
Simplified75.5%
Final simplification75.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (* (cos a) (cos b))))
double code(double r, double a, double b) {
return (r * sin(b)) / (cos(a) * cos(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) * cos(b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / (Math.cos(a) * Math.cos(b));
}
def code(r, a, b): return (r * math.sin(b)) / (math.cos(a) * math.cos(b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(cos(a) * cos(b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / (cos(a) * cos(b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b}
\end{array}
Initial program 73.5%
+-commutative73.5%
Simplified73.5%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-define99.4%
Applied egg-rr99.4%
Applied egg-rr74.6%
Final simplification74.6%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return r * (sin(b) / (cos(a) * cos(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) * cos(b)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / (Math.cos(a) * Math.cos(b)));
}
def code(r, a, b): return r * (math.sin(b) / (math.cos(a) * math.cos(b)))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(cos(a) * cos(b)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / (cos(a) * cos(b))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b}
\end{array}
Initial program 73.5%
associate-/l*73.6%
remove-double-neg73.6%
remove-double-neg73.6%
+-commutative73.6%
Simplified73.6%
cos-sum99.4%
Applied egg-rr99.4%
Applied egg-rr74.1%
fma-undefine74.1%
*-lft-identity74.1%
unpow274.1%
rem-3cbrt-rft74.7%
sub-neg74.7%
+-inverses74.7%
+-lft-identity74.7%
fma-undefine74.7%
distribute-rgt-out74.7%
Simplified74.7%
Final simplification74.7%
(FPCore (r a b) :precision binary64 (if (or (<= a -4e-5) (not (<= a 1.2e-7))) (* r (/ (sin b) (cos a))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -4e-5) || !(a <= 1.2e-7)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * tan(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 <= (-4d-5)) .or. (.not. (a <= 1.2d-7))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -4e-5) || !(a <= 1.2e-7)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -4e-5) or not (a <= 1.2e-7): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -4e-5) || !(a <= 1.2e-7)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -4e-5) || ~((a <= 1.2e-7))) tmp = r * (sin(b) / cos(a)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -4e-5], N[Not[LessEqual[a, 1.2e-7]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-5} \lor \neg \left(a \leq 1.2 \cdot 10^{-7}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -4.00000000000000033e-5 or 1.19999999999999989e-7 < a Initial program 51.5%
associate-/l*51.6%
remove-double-neg51.6%
remove-double-neg51.6%
+-commutative51.6%
Simplified51.6%
Taylor expanded in b around 0 52.2%
if -4.00000000000000033e-5 < a < 1.19999999999999989e-7Initial program 98.1%
+-commutative98.1%
Simplified98.1%
associate-*r/98.0%
*-commutative98.0%
add-sqr-sqrt54.2%
associate-*r*54.3%
Applied egg-rr54.3%
Taylor expanded in a around 0 54.3%
pow154.3%
*-commutative54.3%
*-commutative54.3%
associate-*r*54.2%
add-sqr-sqrt98.0%
quot-tan98.2%
Applied egg-rr98.2%
unpow198.2%
Simplified98.2%
Final simplification74.0%
(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 73.5%
associate-/l*73.6%
remove-double-neg73.6%
remove-double-neg73.6%
+-commutative73.6%
Simplified73.6%
Final simplification73.6%
(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 73.5%
+-commutative73.5%
Simplified73.5%
*-commutative73.5%
associate-/l*73.6%
Applied egg-rr73.6%
Final simplification73.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.028) (not (<= b 0.00058))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.028) || !(b <= 0.00058)) {
tmp = r * tan(b);
} else {
tmp = b * (r / cos(a));
}
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.028d0)) .or. (.not. (b <= 0.00058d0))) then
tmp = r * tan(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.028) || !(b <= 0.00058)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.028) or not (b <= 0.00058): tmp = r * math.tan(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.028) || !(b <= 0.00058)) tmp = Float64(r * tan(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.028) || ~((b <= 0.00058))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.028], N[Not[LessEqual[b, 0.00058]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.028 \lor \neg \left(b \leq 0.00058\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -0.0280000000000000006 or 5.8e-4 < b Initial program 52.8%
+-commutative52.8%
Simplified52.8%
associate-*r/52.8%
*-commutative52.8%
add-sqr-sqrt29.5%
associate-*r*29.5%
Applied egg-rr29.5%
Taylor expanded in a around 0 29.1%
pow129.1%
*-commutative29.1%
*-commutative29.1%
associate-*r*29.1%
add-sqr-sqrt52.3%
quot-tan52.4%
Applied egg-rr52.4%
unpow152.4%
Simplified52.4%
if -0.0280000000000000006 < b < 5.8e-4Initial program 98.5%
associate-/l*98.7%
remove-double-neg98.7%
remove-double-neg98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in b around 0 98.5%
associate-/l*98.6%
Simplified98.6%
Final simplification73.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -5.5e-5) (not (<= b 0.0006))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5.5e-5) || !(b <= 0.0006)) {
tmp = r * tan(b);
} else {
tmp = r * (b / cos(a));
}
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 <= (-5.5d-5)) .or. (.not. (b <= 0.0006d0))) then
tmp = r * tan(b)
else
tmp = r * (b / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -5.5e-5) || !(b <= 0.0006)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -5.5e-5) or not (b <= 0.0006): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -5.5e-5) || !(b <= 0.0006)) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -5.5e-5) || ~((b <= 0.0006))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -5.5e-5], N[Not[LessEqual[b, 0.0006]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-5} \lor \neg \left(b \leq 0.0006\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -5.5000000000000002e-5 or 5.99999999999999947e-4 < b Initial program 52.8%
+-commutative52.8%
Simplified52.8%
associate-*r/52.8%
*-commutative52.8%
add-sqr-sqrt29.5%
associate-*r*29.5%
Applied egg-rr29.5%
Taylor expanded in a around 0 29.1%
pow129.1%
*-commutative29.1%
*-commutative29.1%
associate-*r*29.1%
add-sqr-sqrt52.3%
quot-tan52.4%
Applied egg-rr52.4%
unpow152.4%
Simplified52.4%
if -5.5000000000000002e-5 < b < 5.99999999999999947e-4Initial program 98.5%
associate-/l*98.7%
remove-double-neg98.7%
remove-double-neg98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in b around 0 98.7%
Final simplification73.4%
(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 73.5%
+-commutative73.5%
Simplified73.5%
associate-*r/73.6%
*-commutative73.6%
add-sqr-sqrt38.6%
associate-*r*38.6%
Applied egg-rr38.6%
Taylor expanded in a around 0 31.6%
pow131.6%
*-commutative31.6%
*-commutative31.6%
associate-*r*31.6%
add-sqr-sqrt58.9%
quot-tan59.0%
Applied egg-rr59.0%
unpow159.0%
Simplified59.0%
Final simplification59.0%
(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 73.5%
associate-/l*73.6%
remove-double-neg73.6%
remove-double-neg73.6%
+-commutative73.6%
Simplified73.6%
Taylor expanded in b around 0 47.0%
associate-/l*47.0%
Simplified47.0%
Taylor expanded in a around 0 32.4%
Final simplification32.4%
herbie shell --seed 2024044
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))