
(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 15 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 (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 77.0%
associate-*r/77.0%
+-commutative77.0%
Simplified77.0%
cos-sum99.6%
cancel-sign-sub-inv99.6%
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 77.0%
+-commutative77.0%
Simplified77.0%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (/ (- (* (cos b) (cos a)) (* (sin b) (sin a))) (sin b))))
double code(double r, double a, double b) {
return r / (((cos(b) * cos(a)) - (sin(b) * sin(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) * cos(a)) - (sin(b) * sin(a))) / sin(b))
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))) / Math.sin(b));
}
def code(r, a, b): return r / (((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))) / math.sin(b))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))) / sin(b))) end
function tmp = code(r, a, b) tmp = r / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / sin(b)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos b \cdot \cos a - \sin b \cdot \sin a}{\sin b}}
\end{array}
Initial program 77.0%
associate-*r/77.0%
+-commutative77.0%
Simplified77.0%
cos-sum99.6%
cancel-sign-sub-inv99.6%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in r around 0 99.6%
mul-1-neg99.6%
distribute-lft-neg-out99.6%
+-commutative99.6%
*-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
Simplified99.6%
sub-neg99.6%
Applied egg-rr99.6%
+-commutative99.6%
distribute-lft-neg-in99.6%
*-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in b around inf 99.6%
*-commutative99.6%
associate-*r*99.6%
neg-mul-199.6%
*-commutative99.6%
fma-def99.6%
associate-/l*99.5%
fma-def99.5%
+-commutative99.5%
distribute-rgt-neg-out99.5%
*-commutative99.5%
unsub-neg99.5%
Simplified99.5%
Final simplification99.5%
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $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{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 77.0%
associate-*r/77.0%
+-commutative77.0%
Simplified77.0%
cos-sum99.5%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00052) (not (<= a 2050000000000.0))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00052) || !(a <= 2050000000000.0)) {
tmp = r * (sin(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 ((a <= (-0.00052d0)) .or. (.not. (a <= 2050000000000.0d0))) then
tmp = r * (sin(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 ((a <= -0.00052) || !(a <= 2050000000000.0)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.00052) or not (a <= 2050000000000.0): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.00052) || !(a <= 2050000000000.0)) tmp = Float64(r * Float64(sin(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 ((a <= -0.00052) || ~((a <= 2050000000000.0))) tmp = r * (sin(b) / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.00052], N[Not[LessEqual[a, 2050000000000.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00052 \lor \neg \left(a \leq 2050000000000\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -5.19999999999999954e-4 or 2.05e12 < a Initial program 58.9%
+-commutative58.9%
Simplified58.9%
Taylor expanded in b around 0 58.5%
if -5.19999999999999954e-4 < a < 2.05e12Initial program 97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in a around 0 97.1%
Final simplification76.8%
(FPCore (r a b)
:precision binary64
(if (<= a -0.000195)
(* r (/ (sin b) (cos a)))
(if (<= a 2050000000000.0)
(* r (/ (sin b) (cos b)))
(* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.000195) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 2050000000000.0) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = sin(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 (a <= (-0.000195d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 2050000000000.0d0) then
tmp = r * (sin(b) / cos(b))
else
tmp = sin(b) * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.000195) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 2050000000000.0) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.000195: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 2050000000000.0: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.000195) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 2050000000000.0) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(sin(b) * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.000195) tmp = r * (sin(b) / cos(a)); elseif (a <= 2050000000000.0) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.000195], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2050000000000.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000195:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 2050000000000:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -1.94999999999999996e-4Initial program 58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 57.6%
if -1.94999999999999996e-4 < a < 2.05e12Initial program 97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in a around 0 97.1%
if 2.05e12 < a Initial program 59.3%
*-commutative59.3%
associate-/r/59.3%
+-commutative59.3%
Simplified59.3%
clear-num59.3%
inv-pow59.3%
Applied egg-rr59.3%
unpow-159.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in b around 0 59.3%
Taylor expanded in b around inf 59.4%
associate-*r/59.4%
*-commutative59.4%
Simplified59.4%
Final simplification76.8%
(FPCore (r a b)
:precision binary64
(if (<= a -0.002)
(* r (/ (sin b) (cos a)))
(if (<= a 2050000000000.0)
(* r (/ (sin b) (cos b)))
(/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.002) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 2050000000000.0) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = r / (cos(a) / sin(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 <= (-0.002d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 2050000000000.0d0) then
tmp = r * (sin(b) / cos(b))
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.002) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 2050000000000.0) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.002: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 2050000000000.0: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.002) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 2050000000000.0) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.002) tmp = r * (sin(b) / cos(a)); elseif (a <= 2050000000000.0) tmp = r * (sin(b) / cos(b)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.002], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2050000000000.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.002:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 2050000000000:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -2e-3Initial program 58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 57.6%
if -2e-3 < a < 2.05e12Initial program 97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in a around 0 97.1%
if 2.05e12 < a Initial program 59.3%
*-commutative59.3%
associate-/r/59.3%
+-commutative59.3%
Simplified59.3%
clear-num59.3%
inv-pow59.3%
Applied egg-rr59.3%
unpow-159.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in b around 0 59.3%
Taylor expanded in b around inf 59.4%
*-commutative59.4%
associate-/l*59.5%
Simplified59.5%
Final simplification76.8%
(FPCore (r a b)
:precision binary64
(if (<= a -1.15e-5)
(* r (/ (sin b) (cos a)))
(if (<= a 2050000000000.0)
(/ (* r (sin b)) (cos b))
(/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -1.15e-5) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 2050000000000.0) {
tmp = (r * sin(b)) / cos(b);
} else {
tmp = r / (cos(a) / sin(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 <= (-1.15d-5)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 2050000000000.0d0) then
tmp = (r * sin(b)) / cos(b)
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -1.15e-5) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 2050000000000.0) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -1.15e-5: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 2050000000000.0: tmp = (r * math.sin(b)) / math.cos(b) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -1.15e-5) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 2050000000000.0) tmp = Float64(Float64(r * sin(b)) / cos(b)); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -1.15e-5) tmp = r * (sin(b) / cos(a)); elseif (a <= 2050000000000.0) tmp = (r * sin(b)) / cos(b); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -1.15e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2050000000000.0], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.15 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 2050000000000:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -1.15e-5Initial program 58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 57.6%
if -1.15e-5 < a < 2.05e12Initial program 97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in a around 0 97.2%
if 2.05e12 < a Initial program 59.3%
*-commutative59.3%
associate-/r/59.3%
+-commutative59.3%
Simplified59.3%
clear-num59.3%
inv-pow59.3%
Applied egg-rr59.3%
unpow-159.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in b around 0 59.3%
Taylor expanded in b around inf 59.4%
*-commutative59.4%
associate-/l*59.5%
Simplified59.5%
Final simplification76.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.0%
Final simplification77.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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 77.0%
associate-*r/77.0%
+-commutative77.0%
Simplified77.0%
Final simplification77.0%
(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 77.0%
+-commutative77.0%
Simplified77.0%
Taylor expanded in b around 0 55.6%
Final simplification55.6%
(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.0%
+-commutative77.0%
Simplified77.0%
Taylor expanded in b around 0 52.2%
Final simplification52.2%
(FPCore (r a b) :precision binary64 (* r (sin b)))
double code(double r, double a, double b) {
return r * 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 * sin(b)
end function
public static double code(double r, double a, double b) {
return r * Math.sin(b);
}
def code(r, a, b): return r * math.sin(b)
function code(r, a, b) return Float64(r * sin(b)) end
function tmp = code(r, a, b) tmp = r * sin(b); end
code[r_, a_, b_] := N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \sin b
\end{array}
Initial program 77.0%
*-commutative77.0%
associate-/r/76.9%
+-commutative76.9%
Simplified76.9%
clear-num76.8%
inv-pow76.8%
Applied egg-rr76.8%
unpow-176.8%
+-commutative76.8%
Simplified76.8%
Taylor expanded in b around 0 55.4%
Taylor expanded in a around 0 37.3%
Final simplification37.3%
(FPCore (r a b) :precision binary64 (* r (/ 1.0 (+ (* b -0.3333333333333333) (/ 1.0 b)))))
double code(double r, double a, double b) {
return r * (1.0 / ((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 * (1.0d0 / ((b * (-0.3333333333333333d0)) + (1.0d0 / b)))
end function
public static double code(double r, double a, double b) {
return r * (1.0 / ((b * -0.3333333333333333) + (1.0 / b)));
}
def code(r, a, b): return r * (1.0 / ((b * -0.3333333333333333) + (1.0 / b)))
function code(r, a, b) return Float64(r * Float64(1.0 / Float64(Float64(b * -0.3333333333333333) + Float64(1.0 / b)))) end
function tmp = code(r, a, b) tmp = r * (1.0 / ((b * -0.3333333333333333) + (1.0 / b))); end
code[r_, a_, b_] := N[(r * N[(1.0 / N[(N[(b * -0.3333333333333333), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{1}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Initial program 77.0%
associate-*r/77.0%
+-commutative77.0%
Simplified77.0%
cos-sum99.6%
cancel-sign-sub-inv99.6%
fma-def99.6%
Applied egg-rr99.6%
associate-/l*99.5%
div-inv99.5%
distribute-lft-neg-out99.5%
fma-neg99.5%
cos-sum76.9%
Applied egg-rr76.9%
Taylor expanded in b around 0 52.8%
fma-def52.8%
distribute-rgt-out--52.8%
metadata-eval52.8%
neg-mul-152.8%
+-commutative52.8%
unsub-neg52.8%
Simplified52.8%
Taylor expanded in a around 0 34.1%
Final simplification34.1%
(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.0%
+-commutative77.0%
Simplified77.0%
Taylor expanded in b around 0 52.2%
Taylor expanded in a around 0 34.1%
Final simplification34.1%
herbie shell --seed 2023207
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))