
(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 (/ r (- (/ (* (cos b) (cos a)) (sin b)) (sin a))))
double code(double r, double a, double b) {
return 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 = r / (((cos(b) * cos(a)) / sin(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / (((Math.cos(b) * Math.cos(a)) / Math.sin(b)) - Math.sin(a));
}
def code(r, a, b): return r / (((math.cos(b) * math.cos(a)) / math.sin(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(b) * cos(a)) / sin(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / (((cos(b) * cos(a)) / sin(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos b \cdot \cos a}{\sin b} - \sin a}
\end{array}
Initial program 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.5%
div-sub99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (/ (cos a) (tan b)) (sin a))))
double code(double r, double a, double b) {
return r / ((cos(a) / tan(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) / tan(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) / Math.tan(b)) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(a) / math.tan(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / tan(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / tan(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\tan b} - \sin a}
\end{array}
Initial program 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.5%
div-sub99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 99.5%
expm1-log1p-u78.7%
expm1-udef32.7%
clear-num32.7%
*-un-lft-identity32.7%
*-commutative32.7%
times-frac32.7%
tan-quot32.7%
Applied egg-rr32.7%
expm1-def78.6%
expm1-log1p99.5%
associate-/r*99.5%
remove-double-div99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.000195) (not (<= b 4.4e-8))) (* (sin b) (/ r (cos b))) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000195) || !(b <= 4.4e-8)) {
tmp = sin(b) * (r / cos(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.000195d0)) .or. (.not. (b <= 4.4d-8))) then
tmp = sin(b) * (r / cos(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.000195) || !(b <= 4.4e-8)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.000195) or not (b <= 4.4e-8): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.000195) || !(b <= 4.4e-8)) tmp = Float64(sin(b) * Float64(r / cos(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.000195) || ~((b <= 4.4e-8))) tmp = sin(b) * (r / cos(b)); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.000195], N[Not[LessEqual[b, 4.4e-8]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.000195 \lor \neg \left(b \leq 4.4 \cdot 10^{-8}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.94999999999999996e-4 or 4.3999999999999997e-8 < b Initial program 56.9%
associate-/l*57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in a around 0 56.6%
associate-/l*56.7%
associate-/r/56.5%
Simplified56.5%
if -1.94999999999999996e-4 < b < 4.3999999999999997e-8Initial program 99.3%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in b around 0 99.3%
associate-/r/99.3%
Applied egg-rr99.3%
Final simplification77.6%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.88) (not (<= a 26000000.0))) (* r (/ (sin b) (cos a))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * (1.0 / ((1.0 / tan(b)) - 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 ((a <= (-0.88d0)) .or. (.not. (a <= 26000000.0d0))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.88) or not (a <= 26000000.0): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.88) || !(a <= 26000000.0)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.88) || ~((a <= 26000000.0))) tmp = r * (sin(b) / cos(a)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.88], N[Not[LessEqual[a, 26000000.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.88 \lor \neg \left(a \leq 26000000\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.880000000000000004 or 2.6e7 < a Initial program 58.5%
associate-/l*58.6%
+-commutative58.6%
Simplified58.6%
clear-num57.3%
associate-/r/58.4%
clear-num58.5%
Applied egg-rr58.5%
Taylor expanded in b around 0 58.5%
if -0.880000000000000004 < a < 2.6e7Initial program 97.0%
associate-/l*97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in a around 0 97.5%
+-commutative97.5%
mul-1-neg97.5%
unsub-neg97.5%
Simplified97.5%
div-inv97.5%
clear-num97.5%
quot-tan97.6%
Applied egg-rr97.6%
Final simplification78.0%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.88) (not (<= a 26000000.0))) (/ r (/ (cos a) (sin b))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
tmp = r / (cos(a) / sin(b));
} else {
tmp = r * (1.0 / ((1.0 / tan(b)) - 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 ((a <= (-0.88d0)) .or. (.not. (a <= 26000000.0d0))) then
tmp = r / (cos(a) / sin(b))
else
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.88) or not (a <= 26000000.0): tmp = r / (math.cos(a) / math.sin(b)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.88) || !(a <= 26000000.0)) tmp = Float64(r / Float64(cos(a) / sin(b))); else tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.88) || ~((a <= 26000000.0))) tmp = r / (cos(a) / sin(b)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.88], N[Not[LessEqual[a, 26000000.0]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.88 \lor \neg \left(a \leq 26000000\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.880000000000000004 or 2.6e7 < a Initial program 58.5%
associate-/l*58.6%
+-commutative58.6%
Simplified58.6%
Taylor expanded in b around 0 58.5%
if -0.880000000000000004 < a < 2.6e7Initial program 97.0%
associate-/l*97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in a around 0 97.5%
+-commutative97.5%
mul-1-neg97.5%
unsub-neg97.5%
Simplified97.5%
div-inv97.5%
clear-num97.5%
quot-tan97.6%
Applied egg-rr97.6%
Final simplification78.1%
(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 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
associate-/r/77.8%
Applied egg-rr77.8%
Final simplification77.8%
(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 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
clear-num77.1%
associate-/r/77.7%
clear-num77.8%
Applied egg-rr77.8%
Final simplification77.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.0014) (not (<= b 4.4e-8))) (/ r (- (/ 1.0 (tan b)) a)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.0014) || !(b <= 4.4e-8)) {
tmp = r / ((1.0 / tan(b)) - a);
} 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.0014d0)) .or. (.not. (b <= 4.4d-8))) then
tmp = r / ((1.0d0 / tan(b)) - a)
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.0014) || !(b <= 4.4e-8)) {
tmp = r / ((1.0 / Math.tan(b)) - a);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.0014) or not (b <= 4.4e-8): tmp = r / ((1.0 / math.tan(b)) - a) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.0014) || !(b <= 4.4e-8)) tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); 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.0014) || ~((b <= 4.4e-8))) tmp = r / ((1.0 / tan(b)) - a); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.0014], N[Not[LessEqual[b, 4.4e-8]], $MachinePrecision]], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.0014 \lor \neg \left(b \leq 4.4 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -0.00139999999999999999 or 4.3999999999999997e-8 < b Initial program 56.9%
associate-/l*57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in a around 0 54.3%
+-commutative54.3%
mul-1-neg54.3%
unsub-neg54.3%
Simplified54.3%
expm1-log1p-u35.7%
expm1-udef13.5%
clear-num13.5%
quot-tan13.5%
Applied egg-rr13.5%
expm1-def35.7%
expm1-log1p54.4%
Simplified54.4%
if -0.00139999999999999999 < b < 4.3999999999999997e-8Initial program 99.3%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in b around 0 99.3%
associate-/r/99.3%
Applied egg-rr99.3%
Final simplification76.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.6) (not (<= b 76000000000.0))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.6) || !(b <= 76000000000.0)) {
tmp = r * sin(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 <= (-1.6d0)) .or. (.not. (b <= 76000000000.0d0))) then
tmp = r * sin(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 <= -1.6) || !(b <= 76000000000.0)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.6) or not (b <= 76000000000.0): tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.6) || !(b <= 76000000000.0)) tmp = Float64(r * sin(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 <= -1.6) || ~((b <= 76000000000.0))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.6], N[Not[LessEqual[b, 76000000000.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \lor \neg \left(b \leq 76000000000\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.6000000000000001 or 7.6e10 < b Initial program 56.1%
+-commutative56.1%
Simplified56.1%
Taylor expanded in a around 0 53.6%
mul-1-neg53.6%
unsub-neg53.6%
Simplified53.6%
Taylor expanded in b around 0 11.5%
if -1.6000000000000001 < b < 7.6e10Initial program 97.5%
associate-/l*97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in b around 0 95.4%
associate-/r/95.5%
Applied egg-rr95.5%
Final simplification55.4%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (b / 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 = r * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
clear-num77.1%
associate-/r/77.7%
clear-num77.8%
Applied egg-rr77.8%
Taylor expanded in b around 0 51.6%
Final simplification51.6%
(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(b * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = b * (r / cos(a)); end
code[r_, a_, b_] := N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{r}{\cos a}
\end{array}
Initial program 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 51.6%
associate-/r/51.6%
Applied egg-rr51.6%
Final simplification51.6%
(FPCore (r a b) :precision binary64 (/ r (+ (* b -0.3333333333333333) (/ 1.0 b))))
double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / 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 * (-0.3333333333333333d0)) + (1.0d0 / b))
end function
public static double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / b));
}
def code(r, a, b): return r / ((b * -0.3333333333333333) + (1.0 / b))
function code(r, a, b) return Float64(r / Float64(Float64(b * -0.3333333333333333) + Float64(1.0 / b))) end
function tmp = code(r, a, b) tmp = r / ((b * -0.3333333333333333) + (1.0 / b)); end
code[r_, a_, b_] := N[(r / N[(N[(b * -0.3333333333333333), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Initial program 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 52.8%
+-commutative52.8%
neg-mul-152.8%
unsub-neg52.8%
fma-def52.8%
distribute-rgt-out--52.8%
metadata-eval52.8%
Simplified52.8%
Taylor expanded in a around 0 33.5%
Final simplification33.5%
(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 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 51.6%
Taylor expanded in a around 0 32.5%
*-commutative32.5%
Simplified32.5%
Final simplification32.5%
herbie shell --seed 2023301
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))