
(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 (cos b) (cos a) (* (sin b) (- (sin a))))))
double code(double r, double a, double b) {
return (sin(b) * r) / fma(cos(b), cos(a), (sin(b) * -sin(a)));
}
function code(r, a, b) return Float64(Float64(sin(b) * r) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) 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[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in r around 0 99.5%
*-commutative99.5%
+-commutative99.5%
*-commutative99.5%
*-commutative99.5%
neg-mul-199.5%
distribute-lft-neg-in99.5%
fma-def99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (fma (cos b) (cos a) (* (sin b) (- (sin a)))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), (sin(b) * -sin(a))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))))) end
code[r_, a_, b_] := N[(r * 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]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(b) * cos(a)) - (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(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (sin(b) * r) / ((cos(b) * cos(a)) - (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 = (sin(b) * r) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (math.sin(b) * r) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in r around 0 99.5%
*-commutative99.5%
+-commutative99.5%
*-commutative99.5%
*-commutative99.5%
neg-mul-199.5%
distribute-lft-neg-in99.5%
fma-def99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
distribute-rgt-neg-out99.6%
fma-neg99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -6.2e-6) (not (<= a 0.000112))) (* r (/ (sin b) (cos a))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -6.2e-6) || !(a <= 0.000112)) {
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 <= (-6.2d-6)) .or. (.not. (a <= 0.000112d0))) 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 <= -6.2e-6) || !(a <= 0.000112)) {
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 <= -6.2e-6) or not (a <= 0.000112): 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 <= -6.2e-6) || !(a <= 0.000112)) 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 <= -6.2e-6) || ~((a <= 0.000112))) tmp = r * (sin(b) / cos(a)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -6.2e-6], N[Not[LessEqual[a, 0.000112]], $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 -6.2 \cdot 10^{-6} \lor \neg \left(a \leq 0.000112\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -6.1999999999999999e-6 or 1.11999999999999998e-4 < a Initial program 54.6%
+-commutative54.6%
Simplified54.6%
Taylor expanded in b around 0 55.9%
if -6.1999999999999999e-6 < a < 1.11999999999999998e-4Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in a around 0 98.8%
*-commutative98.8%
associate-/l*98.7%
Simplified98.7%
associate-/r/98.9%
quot-tan98.9%
Applied egg-rr98.9%
Final simplification76.7%
(FPCore (r a b) :precision binary64 (if (or (<= a -5.7e-6) (not (<= a 0.00012))) (/ (* (sin b) r) (cos a)) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -5.7e-6) || !(a <= 0.00012)) {
tmp = (sin(b) * r) / 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 <= (-5.7d-6)) .or. (.not. (a <= 0.00012d0))) then
tmp = (sin(b) * r) / 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 <= -5.7e-6) || !(a <= 0.00012)) {
tmp = (Math.sin(b) * r) / Math.cos(a);
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -5.7e-6) or not (a <= 0.00012): tmp = (math.sin(b) * r) / math.cos(a) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -5.7e-6) || !(a <= 0.00012)) tmp = Float64(Float64(sin(b) * r) / cos(a)); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -5.7e-6) || ~((a <= 0.00012))) tmp = (sin(b) * r) / cos(a); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -5.7e-6], N[Not[LessEqual[a, 0.00012]], $MachinePrecision]], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.7 \cdot 10^{-6} \lor \neg \left(a \leq 0.00012\right):\\
\;\;\;\;\frac{\sin b \cdot r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -5.6999999999999996e-6 or 1.20000000000000003e-4 < a Initial program 54.6%
+-commutative54.6%
Simplified54.6%
cos-sum99.3%
cancel-sign-sub-inv99.3%
fma-def99.4%
Applied egg-rr99.4%
Taylor expanded in r around 0 99.4%
*-commutative99.4%
+-commutative99.4%
*-commutative99.4%
*-commutative99.4%
neg-mul-199.4%
distribute-lft-neg-in99.4%
fma-def99.5%
distribute-lft-neg-in99.5%
distribute-rgt-neg-in99.5%
Simplified99.5%
Taylor expanded in b around 0 56.0%
if -5.6999999999999996e-6 < a < 1.20000000000000003e-4Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in a around 0 98.8%
*-commutative98.8%
associate-/l*98.7%
Simplified98.7%
associate-/r/98.9%
quot-tan98.9%
Applied egg-rr98.9%
Final simplification76.8%
(FPCore (r a b) :precision binary64 (if (<= a -6.2e-6) (* r (/ (sin b) (cos a))) (if (<= a 9.2e-5) (* r (tan b)) (/ (sin b) (/ (cos a) r)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -6.2e-6) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 9.2e-5) {
tmp = r * tan(b);
} else {
tmp = sin(b) / (cos(a) / r);
}
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 <= (-6.2d-6)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 9.2d-5) then
tmp = r * tan(b)
else
tmp = sin(b) / (cos(a) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -6.2e-6) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 9.2e-5) {
tmp = r * Math.tan(b);
} else {
tmp = Math.sin(b) / (Math.cos(a) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -6.2e-6: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 9.2e-5: tmp = r * math.tan(b) else: tmp = math.sin(b) / (math.cos(a) / r) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -6.2e-6) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 9.2e-5) tmp = Float64(r * tan(b)); else tmp = Float64(sin(b) / Float64(cos(a) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -6.2e-6) tmp = r * (sin(b) / cos(a)); elseif (a <= 9.2e-5) tmp = r * tan(b); else tmp = sin(b) / (cos(a) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -6.2e-6], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 9.2e-5], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.2 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 9.2 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if a < -6.1999999999999999e-6Initial program 61.1%
+-commutative61.1%
Simplified61.1%
Taylor expanded in b around 0 62.6%
if -6.1999999999999999e-6 < a < 9.20000000000000001e-5Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in a around 0 98.8%
*-commutative98.8%
associate-/l*98.7%
Simplified98.7%
associate-/r/98.9%
quot-tan98.9%
Applied egg-rr98.9%
if 9.20000000000000001e-5 < a Initial program 47.4%
+-commutative47.4%
Simplified47.4%
cos-sum99.3%
cancel-sign-sub-inv99.3%
fma-def99.4%
Applied egg-rr99.4%
Taylor expanded in r around 0 99.3%
*-commutative99.3%
+-commutative99.3%
*-commutative99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-lft-neg-in99.3%
fma-def99.4%
distribute-lft-neg-in99.4%
distribute-rgt-neg-in99.4%
Simplified99.4%
Taylor expanded in b around 0 48.6%
Taylor expanded in b around inf 48.6%
*-commutative48.6%
associate-/l*48.6%
Simplified48.6%
Final simplification76.7%
(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 76.0%
Final simplification76.0%
(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 76.0%
+-commutative76.0%
Simplified76.0%
*-commutative76.0%
associate-*l/76.0%
Applied egg-rr76.0%
Final simplification76.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -3.5e-5) (not (<= b 9.2e-5))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -3.5e-5) || !(b <= 9.2e-5)) {
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 <= (-3.5d-5)) .or. (.not. (b <= 9.2d-5))) 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 <= -3.5e-5) || !(b <= 9.2e-5)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -3.5e-5) or not (b <= 9.2e-5): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -3.5e-5) || !(b <= 9.2e-5)) 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 <= -3.5e-5) || ~((b <= 9.2e-5))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -3.5e-5], N[Not[LessEqual[b, 9.2e-5]], $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 -3.5 \cdot 10^{-5} \lor \neg \left(b \leq 9.2 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -3.4999999999999997e-5 or 9.20000000000000001e-5 < b Initial program 56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in a around 0 56.3%
*-commutative56.3%
associate-/l*56.2%
Simplified56.2%
associate-/r/56.3%
quot-tan56.4%
Applied egg-rr56.4%
if -3.4999999999999997e-5 < b < 9.20000000000000001e-5Initial program 98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in b around 0 98.8%
associate-/l*98.6%
associate-/r/98.7%
Simplified98.7%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.6e-6) (not (<= b 4.4e-5))) (* r (tan b)) (/ (* b r) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.6e-6) || !(b <= 4.4e-5)) {
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 <= (-4.6d-6)) .or. (.not. (b <= 4.4d-5))) 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 <= -4.6e-6) || !(b <= 4.4e-5)) {
tmp = r * Math.tan(b);
} else {
tmp = (b * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.6e-6) or not (b <= 4.4e-5): tmp = r * math.tan(b) else: tmp = (b * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.6e-6) || !(b <= 4.4e-5)) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(b * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.6e-6) || ~((b <= 4.4e-5))) tmp = r * tan(b); else tmp = (b * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.6e-6], N[Not[LessEqual[b, 4.4e-5]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-6} \lor \neg \left(b \leq 4.4 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\end{array}
\end{array}
if b < -4.6e-6 or 4.3999999999999999e-5 < b Initial program 56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in a around 0 56.3%
*-commutative56.3%
associate-/l*56.2%
Simplified56.2%
associate-/r/56.3%
quot-tan56.4%
Applied egg-rr56.4%
if -4.6e-6 < b < 4.3999999999999999e-5Initial program 98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in b around 0 98.8%
Final simplification76.3%
(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 76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in r around 0 99.5%
*-commutative99.5%
+-commutative99.5%
*-commutative99.5%
*-commutative99.5%
neg-mul-199.5%
distribute-lft-neg-in99.5%
fma-def99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in b around 0 53.2%
Taylor expanded in a around 0 36.5%
*-commutative36.5%
Simplified36.5%
Final simplification36.5%
(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 76.0%
+-commutative76.0%
Simplified76.0%
Taylor expanded in a around 0 60.3%
*-commutative60.3%
associate-/l*60.2%
Simplified60.2%
associate-/r/60.3%
quot-tan60.4%
Applied egg-rr60.4%
Final simplification60.4%
(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 76.0%
+-commutative76.0%
Simplified76.0%
Taylor expanded in b around 0 48.9%
associate-/l*48.8%
associate-/r/48.8%
Simplified48.8%
Taylor expanded in a around 0 32.9%
Final simplification32.9%
herbie shell --seed 2023285
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))