
(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 20 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 (/ (* r (sin b)) (fma (sin b) (- (sin a)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(b), -sin(a), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(b), Float64(-sin(a)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $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{r \cdot \sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 74.8%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
cos-sum99.4%
sub-neg99.4%
Applied egg-rr99.4%
+-commutative99.4%
distribute-rgt-neg-in99.4%
fma-define99.5%
*-commutative99.5%
Simplified99.5%
(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(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $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{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 74.8%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-define99.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 74.8%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
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(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 74.8%
+-commutative74.8%
Simplified74.8%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00015) (not (<= b 0.102))) (* r (/ (sin b) (cos b))) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00015) || !(b <= 0.102)) {
tmp = r * (sin(b) / cos(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 <= (-0.00015d0)) .or. (.not. (b <= 0.102d0))) then
tmp = r * (sin(b) / cos(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 <= -0.00015) || !(b <= 0.102)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00015) or not (b <= 0.102): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.00015) || !(b <= 0.102)) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.00015) || ~((b <= 0.102))) tmp = r * (sin(b) / cos(b)); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00015], N[Not[LessEqual[b, 0.102]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00015 \lor \neg \left(b \leq 0.102\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -1.49999999999999987e-4 or 0.101999999999999993 < b Initial program 55.9%
+-commutative55.9%
Simplified55.9%
Taylor expanded in a around 0 56.5%
associate-/l*56.5%
Simplified56.5%
if -1.49999999999999987e-4 < b < 0.101999999999999993Initial program 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in b around 0 98.4%
Final simplification75.1%
(FPCore (r a b) :precision binary64 (if (<= b -0.00017) (* (sin b) (/ r (cos b))) (if (<= b 0.102) (/ (* r b) (cos a)) (/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.00017) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 0.102) {
tmp = (r * b) / cos(a);
} else {
tmp = (r * sin(b)) / 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 (b <= (-0.00017d0)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 0.102d0) then
tmp = (r * b) / cos(a)
else
tmp = (r * sin(b)) / cos(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -0.00017) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 0.102) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = (r * Math.sin(b)) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.00017: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 0.102: tmp = (r * b) / math.cos(a) else: tmp = (r * math.sin(b)) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.00017) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 0.102) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(Float64(r * sin(b)) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.00017) tmp = sin(b) * (r / cos(b)); elseif (b <= 0.102) tmp = (r * b) / cos(a); else tmp = (r * sin(b)) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.00017], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.102], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00017:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 0.102:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -1.7e-4Initial program 49.1%
associate-*r/49.0%
+-commutative49.0%
Simplified49.0%
associate-*r/49.1%
*-commutative49.1%
div-inv49.1%
associate-*l*49.1%
Applied egg-rr49.1%
Taylor expanded in a around 0 50.5%
if -1.7e-4 < b < 0.101999999999999993Initial program 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in b around 0 98.4%
if 0.101999999999999993 < b Initial program 62.2%
+-commutative62.2%
Simplified62.2%
Taylor expanded in a around 0 62.1%
Final simplification75.2%
(FPCore (r a b) :precision binary64 (if (<= b -3.8e-6) (* (sin b) (/ r (cos b))) (if (<= b 0.102) (/ (* r b) (cos a)) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -3.8e-6) {
tmp = sin(b) * (r / cos(b));
} else if (b <= 0.102) {
tmp = (r * b) / cos(a);
} else {
tmp = r * (sin(b) / 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 (b <= (-3.8d-6)) then
tmp = sin(b) * (r / cos(b))
else if (b <= 0.102d0) then
tmp = (r * b) / cos(a)
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -3.8e-6) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else if (b <= 0.102) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -3.8e-6: tmp = math.sin(b) * (r / math.cos(b)) elif b <= 0.102: tmp = (r * b) / math.cos(a) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -3.8e-6) tmp = Float64(sin(b) * Float64(r / cos(b))); elseif (b <= 0.102) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -3.8e-6) tmp = sin(b) * (r / cos(b)); elseif (b <= 0.102) tmp = (r * b) / cos(a); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -3.8e-6], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.102], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-6}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{elif}\;b \leq 0.102:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -3.8e-6Initial program 49.1%
associate-*r/49.0%
+-commutative49.0%
Simplified49.0%
associate-*r/49.1%
*-commutative49.1%
div-inv49.1%
associate-*l*49.1%
Applied egg-rr49.1%
Taylor expanded in a around 0 50.5%
if -3.8e-6 < b < 0.101999999999999993Initial program 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in b around 0 98.4%
if 0.101999999999999993 < b Initial program 62.2%
+-commutative62.2%
Simplified62.2%
Taylor expanded in a around 0 62.1%
associate-/l*62.1%
Simplified62.1%
Final simplification75.2%
(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}
Initial program 74.8%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
cos-sum99.4%
sub-neg99.4%
Applied egg-rr99.4%
+-commutative99.4%
distribute-rgt-neg-in99.4%
fma-define99.5%
*-commutative99.5%
Simplified99.5%
add-log-exp99.4%
Applied egg-rr99.4%
fma-undefine99.4%
+-commutative99.4%
rem-log-exp99.4%
*-commutative99.4%
add-sqr-sqrt52.4%
sqrt-unprod88.2%
sqr-neg88.2%
sqrt-unprod35.8%
add-sqr-sqrt74.9%
cos-diff74.9%
Applied egg-rr74.9%
(FPCore (r a b) :precision binary64 (/ (sin b) (/ (cos (+ b a)) r)))
double code(double r, double a, double b) {
return sin(b) / (cos((b + 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 = sin(b) / (cos((b + a)) / r)
end function
public static double code(double r, double a, double b) {
return Math.sin(b) / (Math.cos((b + a)) / r);
}
def code(r, a, b): return math.sin(b) / (math.cos((b + a)) / r)
function code(r, a, b) return Float64(sin(b) / Float64(cos(Float64(b + a)) / r)) end
function tmp = code(r, a, b) tmp = sin(b) / (cos((b + a)) / r); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\frac{\cos \left(b + a\right)}{r}}
\end{array}
Initial program 74.8%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
associate-*r/74.8%
*-commutative74.8%
div-inv74.8%
associate-*l*74.8%
Applied egg-rr74.8%
Taylor expanded in b around inf 74.8%
*-lft-identity74.8%
+-commutative74.8%
associate-*l/74.7%
associate-*r*74.8%
associate-/r/74.7%
associate-*l/74.8%
*-lft-identity74.8%
Simplified74.8%
(FPCore (r a b) :precision binary64 (/ r (/ (cos (+ b a)) (sin b))))
double code(double r, double a, double b) {
return r / (cos((b + 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 = r / (cos((b + a)) / sin(b))
end function
public static double code(double r, double a, double b) {
return r / (Math.cos((b + a)) / Math.sin(b));
}
def code(r, a, b): return r / (math.cos((b + a)) / math.sin(b))
function code(r, a, b) return Float64(r / Float64(cos(Float64(b + a)) / sin(b))) end
function tmp = code(r, a, b) tmp = r / (cos((b + a)) / sin(b)); end
code[r_, a_, b_] := N[(r / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos \left(b + a\right)}{\sin b}}
\end{array}
Initial program 74.8%
+-commutative74.8%
Simplified74.8%
clear-num74.7%
un-div-inv74.8%
Applied egg-rr74.8%
(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 74.8%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
*-commutative74.8%
associate-/l*74.8%
Applied egg-rr74.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 74.8%
Final simplification74.8%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos a))))
double code(double r, double a, double b) {
return r * (sin(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 * (sin(b) / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos(a));
}
def code(r, a, b): return r * (math.sin(b) / math.cos(a))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(a))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos(a)); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a}
\end{array}
Initial program 74.8%
+-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 49.6%
(FPCore (r a b) :precision binary64 (/ (* r b) (cos (- a b))))
double code(double r, double a, double b) {
return (r * 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 * b) / cos((a - b))
end function
public static double code(double r, double a, double b) {
return (r * b) / Math.cos((a - b));
}
def code(r, a, b): return (r * b) / math.cos((a - b))
function code(r, a, b) return Float64(Float64(r * b) / cos(Float64(a - b))) end
function tmp = code(r, a, b) tmp = (r * b) / cos((a - b)); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[N[(a - b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos \left(a - b\right)}
\end{array}
Initial program 74.8%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
cos-sum99.4%
sub-neg99.4%
Applied egg-rr99.4%
+-commutative99.4%
distribute-rgt-neg-in99.4%
fma-define99.5%
*-commutative99.5%
Simplified99.5%
add-log-exp99.4%
Applied egg-rr99.4%
fma-undefine99.4%
+-commutative99.4%
rem-log-exp99.4%
*-commutative99.4%
add-sqr-sqrt52.4%
sqrt-unprod88.2%
sqr-neg88.2%
sqrt-unprod35.8%
add-sqr-sqrt74.9%
cos-diff74.9%
Applied egg-rr74.9%
Taylor expanded in b around 0 46.0%
*-commutative46.0%
Simplified46.0%
(FPCore (r a b) :precision binary64 (/ (* r b) (cos (+ b a))))
double code(double r, double a, double b) {
return (r * 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 * b) / cos((b + a))
end function
public static double code(double r, double a, double b) {
return (r * b) / Math.cos((b + a));
}
def code(r, a, b): return (r * b) / math.cos((b + a))
function code(r, a, b) return Float64(Float64(r * b) / cos(Float64(b + a))) end
function tmp = code(r, a, b) tmp = (r * b) / cos((b + a)); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos \left(b + a\right)}
\end{array}
Initial program 74.8%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 46.0%
(FPCore (r a b) :precision binary64 (* r (/ b (cos (+ b a)))))
double code(double r, double a, double b) {
return r * (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 * (b / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos((b + a)));
}
def code(r, a, b): return r * (b / math.cos((b + a)))
function code(r, a, b) return Float64(r * Float64(b / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = r * (b / cos((b + a))); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos \left(b + a\right)}
\end{array}
Initial program 74.8%
+-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 46.0%
(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(Float64(r * b) / cos(a)) end
function tmp = code(r, a, b) tmp = (r * b) / cos(a); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos a}
\end{array}
Initial program 74.8%
+-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 45.9%
Final simplification45.9%
(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 74.8%
+-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 45.9%
*-commutative45.9%
associate-/l*45.9%
Simplified45.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(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 74.8%
+-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 45.9%
associate-/l*45.9%
Simplified45.9%
(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 74.8%
+-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 45.9%
associate-/l*45.9%
Simplified45.9%
Taylor expanded in a around 0 28.9%
*-commutative28.9%
Simplified28.9%
herbie shell --seed 2024144
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))