
(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 16 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 (* (/ (sin b) (- (* (cos b) (cos a)) (* (sin b) (sin a)))) r))
double code(double r, double a, double b) {
return (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(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) * cos(a)) - (sin(b) * sin(a)))) * r
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)))) * r;
}
def code(r, a, b): return (math.sin(b) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))) * r
function code(r, a, b) return Float64(Float64(sin(b) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) * r) end
function tmp = code(r, a, b) tmp = (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))) * r; end
code[r_, a_, b_] := N[(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] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a} \cdot r
\end{array}
Initial program 75.9%
associate-/l*75.8%
remove-double-neg75.8%
sin-neg75.8%
neg-mul-175.8%
associate-/r*75.8%
associate-/l*75.9%
*-commutative75.9%
associate-*l/75.9%
associate-/l*75.9%
sin-neg75.9%
distribute-lft-neg-in75.9%
distribute-rgt-neg-in75.9%
associate-/l*75.9%
metadata-eval75.9%
/-rgt-identity75.9%
+-commutative75.9%
Simplified75.9%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (cos b)) (/ (- r) (- (cos a)))))
double code(double r, double a, double b) {
return (sin(b) / cos(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 = (sin(b) / cos(b)) * (-r / -cos(a))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) / Math.cos(b)) * (-r / -Math.cos(a));
}
def code(r, a, b): return (math.sin(b) / math.cos(b)) * (-r / -math.cos(a))
function code(r, a, b) return Float64(Float64(sin(b) / cos(b)) * Float64(Float64(-r) / Float64(-cos(a)))) end
function tmp = code(r, a, b) tmp = (sin(b) / cos(b)) * (-r / -cos(a)); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[((-r) / (-N[Cos[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\cos b} \cdot \frac{-r}{-\cos a}
\end{array}
Initial program 75.9%
associate-/l*75.8%
remove-double-neg75.8%
sin-neg75.8%
neg-mul-175.8%
associate-/r*75.8%
associate-/l*75.9%
*-commutative75.9%
associate-*l/75.9%
associate-/l*75.9%
sin-neg75.9%
distribute-lft-neg-in75.9%
distribute-rgt-neg-in75.9%
associate-/l*75.9%
metadata-eval75.9%
/-rgt-identity75.9%
+-commutative75.9%
Simplified75.9%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult77.0%
cos-sum77.2%
div-sub77.2%
cos-diff99.4%
add-sqr-sqrt53.3%
sqrt-unprod87.4%
sqr-neg87.4%
sqrt-unprod43.4%
add-sqr-sqrt77.1%
sub-neg77.1%
cos-sum77.4%
cos-sum77.1%
Applied egg-rr77.1%
+-inverses77.1%
Simplified77.1%
frac-2neg77.1%
associate-*l/77.1%
distribute-lft-neg-in77.1%
distribute-rgt-neg-in77.1%
--rgt-identity77.1%
distribute-rgt-neg-in77.1%
Applied egg-rr77.1%
times-frac77.1%
Simplified77.1%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (/ r (/ (cos b) (/ (sin b) (cos a)))))
double code(double r, double a, double b) {
return r / (cos(b) / (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 / (cos(b) / (sin(b) / cos(a)))
end function
public static double code(double r, double a, double b) {
return r / (Math.cos(b) / (Math.sin(b) / Math.cos(a)));
}
def code(r, a, b): return r / (math.cos(b) / (math.sin(b) / math.cos(a)))
function code(r, a, b) return Float64(r / Float64(cos(b) / Float64(sin(b) / cos(a)))) end
function tmp = code(r, a, b) tmp = r / (cos(b) / (sin(b) / cos(a))); end
code[r_, a_, b_] := N[(r / N[(N[Cos[b], $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos b}{\frac{\sin b}{\cos a}}}
\end{array}
Initial program 75.9%
associate-/l*75.8%
remove-double-neg75.8%
sin-neg75.8%
neg-mul-175.8%
associate-/r*75.8%
associate-/l*75.9%
*-commutative75.9%
associate-*l/75.9%
associate-/l*75.9%
sin-neg75.9%
distribute-lft-neg-in75.9%
distribute-rgt-neg-in75.9%
associate-/l*75.9%
metadata-eval75.9%
/-rgt-identity75.9%
+-commutative75.9%
Simplified75.9%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult77.0%
cos-sum77.2%
div-sub77.2%
cos-diff99.4%
add-sqr-sqrt53.3%
sqrt-unprod87.4%
sqr-neg87.4%
sqrt-unprod43.4%
add-sqr-sqrt77.1%
sub-neg77.1%
cos-sum77.4%
cos-sum77.1%
Applied egg-rr77.1%
+-inverses77.1%
Simplified77.1%
*-commutative77.1%
clear-num77.1%
un-div-inv77.1%
--rgt-identity77.1%
associate-/l*77.1%
Applied egg-rr77.1%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (* (cos b) (cos a))))
double code(double r, double a, double b) {
return (sin(b) * r) / (cos(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 = (sin(b) * r) / (cos(b) * cos(a))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / (Math.cos(b) * Math.cos(a));
}
def code(r, a, b): return (math.sin(b) * r) / (math.cos(b) * math.cos(a))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(cos(b) * cos(a))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / (cos(b) * cos(a)); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos b \cdot \cos a}
\end{array}
Initial program 75.9%
associate-/l*75.8%
remove-double-neg75.8%
sin-neg75.8%
neg-mul-175.8%
associate-/r*75.8%
associate-/l*75.9%
*-commutative75.9%
associate-*l/75.9%
associate-/l*75.9%
sin-neg75.9%
distribute-lft-neg-in75.9%
distribute-rgt-neg-in75.9%
associate-/l*75.9%
metadata-eval75.9%
/-rgt-identity75.9%
+-commutative75.9%
Simplified75.9%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult77.0%
cos-sum77.2%
div-sub77.2%
cos-diff99.4%
add-sqr-sqrt53.3%
sqrt-unprod87.4%
sqr-neg87.4%
sqrt-unprod43.4%
add-sqr-sqrt77.1%
sub-neg77.1%
cos-sum77.4%
cos-sum77.1%
Applied egg-rr77.1%
+-inverses77.1%
Simplified77.1%
--rgt-identity77.1%
associate-*l/77.1%
*-commutative77.1%
Applied egg-rr77.1%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (/ (/ (* (sin b) r) (cos b)) (cos a)))
double code(double r, double a, double b) {
return ((sin(b) * r) / cos(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 = ((sin(b) * r) / cos(b)) / cos(a)
end function
public static double code(double r, double a, double b) {
return ((Math.sin(b) * r) / Math.cos(b)) / Math.cos(a);
}
def code(r, a, b): return ((math.sin(b) * r) / math.cos(b)) / math.cos(a)
function code(r, a, b) return Float64(Float64(Float64(sin(b) * r) / cos(b)) / cos(a)) end
function tmp = code(r, a, b) tmp = ((sin(b) * r) / cos(b)) / cos(a); end
code[r_, a_, b_] := N[(N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\sin b \cdot r}{\cos b}}{\cos a}
\end{array}
Initial program 75.9%
associate-/l*75.8%
remove-double-neg75.8%
sin-neg75.8%
neg-mul-175.8%
associate-/r*75.8%
associate-/l*75.9%
*-commutative75.9%
associate-*l/75.9%
associate-/l*75.9%
sin-neg75.9%
distribute-lft-neg-in75.9%
distribute-rgt-neg-in75.9%
associate-/l*75.9%
metadata-eval75.9%
/-rgt-identity75.9%
+-commutative75.9%
Simplified75.9%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult77.0%
cos-sum77.2%
div-sub77.2%
cos-diff99.4%
add-sqr-sqrt53.3%
sqrt-unprod87.4%
sqr-neg87.4%
sqrt-unprod43.4%
add-sqr-sqrt77.1%
sub-neg77.1%
cos-sum77.4%
cos-sum77.1%
Applied egg-rr77.1%
+-inverses77.1%
Simplified77.1%
--rgt-identity77.1%
associate-*l/77.1%
*-commutative77.1%
associate-/r*77.1%
Applied egg-rr77.1%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0065) (not (<= a 0.00185))) (/ r (/ (cos a) (sin b))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0065) || !(a <= 0.00185)) {
tmp = r / (cos(a) / sin(b));
} 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.0065d0)) .or. (.not. (a <= 0.00185d0))) then
tmp = r / (cos(a) / sin(b))
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.0065) || !(a <= 0.00185)) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0065) or not (a <= 0.00185): tmp = r / (math.cos(a) / math.sin(b)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0065) || !(a <= 0.00185)) tmp = Float64(r / Float64(cos(a) / sin(b))); 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.0065) || ~((a <= 0.00185))) tmp = r / (cos(a) / sin(b)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0065], N[Not[LessEqual[a, 0.00185]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $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.0065 \lor \neg \left(a \leq 0.00185\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -0.0064999999999999997 or 0.0018500000000000001 < a Initial program 56.6%
associate-/l*56.7%
+-commutative56.7%
Simplified56.7%
Taylor expanded in b around 0 56.4%
if -0.0064999999999999997 < a < 0.0018500000000000001Initial program 97.7%
associate-/l*97.5%
remove-double-neg97.5%
sin-neg97.5%
neg-mul-197.5%
associate-/r*97.5%
associate-/l*97.7%
*-commutative97.7%
associate-*l/97.7%
associate-/l*97.7%
sin-neg97.7%
distribute-lft-neg-in97.7%
distribute-rgt-neg-in97.7%
associate-/l*97.7%
metadata-eval97.7%
/-rgt-identity97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in a around 0 97.7%
Final simplification75.8%
(FPCore (r a b) :precision binary64 (if (<= a -0.0065) (* r (/ (sin b) (cos a))) (if (<= a 0.0018) (* r (/ (sin b) (cos b))) (* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.0065) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 0.0018) {
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.0065d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 0.0018d0) 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.0065) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 0.0018) {
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.0065: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 0.0018: 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.0065) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 0.0018) 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.0065) tmp = r * (sin(b) / cos(a)); elseif (a <= 0.0018) 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.0065], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.0018], 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.0065:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 0.0018:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -0.0064999999999999997Initial program 51.3%
associate-/l*51.4%
remove-double-neg51.4%
sin-neg51.4%
neg-mul-151.4%
associate-/r*51.4%
associate-/l*51.3%
*-commutative51.3%
associate-*l/51.4%
associate-/l*51.4%
sin-neg51.4%
distribute-lft-neg-in51.4%
distribute-rgt-neg-in51.4%
associate-/l*51.4%
metadata-eval51.4%
/-rgt-identity51.4%
+-commutative51.4%
Simplified51.4%
Taylor expanded in b around 0 52.1%
if -0.0064999999999999997 < a < 0.0018Initial program 97.7%
associate-/l*97.5%
remove-double-neg97.5%
sin-neg97.5%
neg-mul-197.5%
associate-/r*97.5%
associate-/l*97.7%
*-commutative97.7%
associate-*l/97.7%
associate-/l*97.7%
sin-neg97.7%
distribute-lft-neg-in97.7%
distribute-rgt-neg-in97.7%
associate-/l*97.7%
metadata-eval97.7%
/-rgt-identity97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in a around 0 97.7%
if 0.0018 < a Initial program 61.9%
+-commutative61.9%
Simplified61.9%
Taylor expanded in b around 0 60.7%
associate-/l*60.8%
associate-/r/60.8%
Applied egg-rr60.8%
Final simplification75.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.36e+14) (not (<= b 3.6e+15))) (fabs (* (sin b) r)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.36e+14) || !(b <= 3.6e+15)) {
tmp = fabs((sin(b) * r));
} 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 <= (-1.36d+14)) .or. (.not. (b <= 3.6d+15))) then
tmp = abs((sin(b) * r))
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 <= -1.36e+14) || !(b <= 3.6e+15)) {
tmp = Math.abs((Math.sin(b) * r));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.36e+14) or not (b <= 3.6e+15): tmp = math.fabs((math.sin(b) * r)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.36e+14) || !(b <= 3.6e+15)) tmp = abs(Float64(sin(b) * r)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.36e+14) || ~((b <= 3.6e+15))) tmp = abs((sin(b) * r)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.36e+14], N[Not[LessEqual[b, 3.6e+15]], $MachinePrecision]], N[Abs[N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]], $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.36 \cdot 10^{+14} \lor \neg \left(b \leq 3.6 \cdot 10^{+15}\right):\\
\;\;\;\;\left|\sin b \cdot r\right|\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.36e14 or 3.6e15 < b Initial program 51.3%
+-commutative51.3%
Simplified51.3%
Taylor expanded in b around 0 11.0%
Taylor expanded in a around 0 11.2%
add-sqr-sqrt5.3%
sqrt-unprod7.1%
pow27.1%
*-commutative7.1%
Applied egg-rr7.1%
unpow27.1%
rem-sqrt-square11.0%
Simplified11.0%
if -1.36e14 < b < 3.6e15Initial program 95.6%
associate-/l*95.5%
remove-double-neg95.5%
sin-neg95.5%
neg-mul-195.5%
associate-/r*95.5%
associate-/l*95.6%
*-commutative95.6%
associate-*l/95.6%
associate-/l*95.6%
sin-neg95.6%
distribute-lft-neg-in95.6%
distribute-rgt-neg-in95.6%
associate-/l*95.6%
metadata-eval95.6%
/-rgt-identity95.6%
+-commutative95.6%
Simplified95.6%
Taylor expanded in b around 0 94.3%
Final simplification57.2%
(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 75.9%
associate-/l*75.8%
+-commutative75.8%
Simplified75.8%
associate-/r/75.9%
Applied egg-rr75.9%
Final simplification75.9%
(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 75.9%
associate-/l*75.8%
remove-double-neg75.8%
sin-neg75.8%
neg-mul-175.8%
associate-/r*75.8%
associate-/l*75.9%
*-commutative75.9%
associate-*l/75.9%
associate-/l*75.9%
sin-neg75.9%
distribute-lft-neg-in75.9%
distribute-rgt-neg-in75.9%
associate-/l*75.9%
metadata-eval75.9%
/-rgt-identity75.9%
+-commutative75.9%
Simplified75.9%
Final simplification75.9%
(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 75.9%
associate-/l*75.8%
remove-double-neg75.8%
sin-neg75.8%
neg-mul-175.8%
associate-/r*75.8%
associate-/l*75.9%
*-commutative75.9%
associate-*l/75.9%
associate-/l*75.9%
sin-neg75.9%
distribute-lft-neg-in75.9%
distribute-rgt-neg-in75.9%
associate-/l*75.9%
metadata-eval75.9%
/-rgt-identity75.9%
+-commutative75.9%
Simplified75.9%
cos-sum99.5%
Applied egg-rr99.5%
sub-neg99.5%
add-sqr-sqrt55.5%
sqrt-unprod88.4%
sqr-neg88.4%
sqrt-unprod42.2%
add-sqr-sqrt75.6%
cos-diff76.1%
Applied egg-rr76.1%
Final simplification76.1%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(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 = sin(b) * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in b around 0 57.2%
associate-/l*57.2%
associate-/r/57.2%
Applied egg-rr57.2%
Final simplification57.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -72000.0) (not (<= b 2800000000.0))) (* (sin b) r) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -72000.0) || !(b <= 2800000000.0)) {
tmp = sin(b) * r;
} 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 <= (-72000.0d0)) .or. (.not. (b <= 2800000000.0d0))) then
tmp = sin(b) * r
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 <= -72000.0) || !(b <= 2800000000.0)) {
tmp = Math.sin(b) * r;
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -72000.0) or not (b <= 2800000000.0): tmp = math.sin(b) * r else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -72000.0) || !(b <= 2800000000.0)) tmp = Float64(sin(b) * r); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -72000.0) || ~((b <= 2800000000.0))) tmp = sin(b) * r; else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -72000.0], N[Not[LessEqual[b, 2800000000.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -72000 \lor \neg \left(b \leq 2800000000\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -72000 or 2.8e9 < b Initial program 51.0%
+-commutative51.0%
Simplified51.0%
Taylor expanded in b around 0 11.1%
Taylor expanded in a around 0 11.4%
if -72000 < b < 2.8e9Initial program 96.8%
associate-/l*96.7%
remove-double-neg96.7%
sin-neg96.7%
neg-mul-196.7%
associate-/r*96.7%
associate-/l*96.8%
*-commutative96.8%
associate-*l/96.8%
associate-/l*96.8%
sin-neg96.8%
distribute-lft-neg-in96.8%
distribute-rgt-neg-in96.8%
associate-/l*96.8%
metadata-eval96.8%
/-rgt-identity96.8%
+-commutative96.8%
Simplified96.8%
Taylor expanded in b around 0 96.1%
Final simplification57.4%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* (sin b) r)))
(if (<= b -32000.0)
(/ 1.0 (/ 1.0 t_0))
(if (<= b 58000000.0) (* r (/ b (cos a))) t_0))))
double code(double r, double a, double b) {
double t_0 = sin(b) * r;
double tmp;
if (b <= -32000.0) {
tmp = 1.0 / (1.0 / t_0);
} else if (b <= 58000000.0) {
tmp = r * (b / cos(a));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = sin(b) * r
if (b <= (-32000.0d0)) then
tmp = 1.0d0 / (1.0d0 / t_0)
else if (b <= 58000000.0d0) then
tmp = r * (b / cos(a))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.sin(b) * r;
double tmp;
if (b <= -32000.0) {
tmp = 1.0 / (1.0 / t_0);
} else if (b <= 58000000.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) * r tmp = 0 if b <= -32000.0: tmp = 1.0 / (1.0 / t_0) elif b <= 58000000.0: tmp = r * (b / math.cos(a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(sin(b) * r) tmp = 0.0 if (b <= -32000.0) tmp = Float64(1.0 / Float64(1.0 / t_0)); elseif (b <= 58000000.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) * r; tmp = 0.0; if (b <= -32000.0) tmp = 1.0 / (1.0 / t_0); elseif (b <= 58000000.0) tmp = r * (b / cos(a)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -32000.0], N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 58000000.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot r\\
\mathbf{if}\;b \leq -32000:\\
\;\;\;\;\frac{1}{\frac{1}{t_0}}\\
\mathbf{elif}\;b \leq 58000000:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -32000Initial program 44.7%
+-commutative44.7%
Simplified44.7%
Taylor expanded in b around 0 12.3%
clear-num12.3%
inv-pow12.3%
associate-/r*12.3%
Applied egg-rr12.3%
unpow-112.3%
associate-/l/12.3%
*-commutative12.3%
Simplified12.3%
Taylor expanded in a around 0 12.0%
if -32000 < b < 5.8e7Initial program 96.8%
associate-/l*96.7%
remove-double-neg96.7%
sin-neg96.7%
neg-mul-196.7%
associate-/r*96.7%
associate-/l*96.8%
*-commutative96.8%
associate-*l/96.8%
associate-/l*96.8%
sin-neg96.8%
distribute-lft-neg-in96.8%
distribute-rgt-neg-in96.8%
associate-/l*96.8%
metadata-eval96.8%
/-rgt-identity96.8%
+-commutative96.8%
Simplified96.8%
Taylor expanded in b around 0 96.1%
if 5.8e7 < b Initial program 57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in b around 0 9.9%
Taylor expanded in a around 0 10.9%
Final simplification57.4%
(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 75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in b around 0 57.2%
Taylor expanded in a around 0 38.3%
Final simplification38.3%
(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 75.9%
associate-/l*75.8%
remove-double-neg75.8%
sin-neg75.8%
neg-mul-175.8%
associate-/r*75.8%
associate-/l*75.9%
*-commutative75.9%
associate-*l/75.9%
associate-/l*75.9%
sin-neg75.9%
distribute-lft-neg-in75.9%
distribute-rgt-neg-in75.9%
associate-/l*75.9%
metadata-eval75.9%
/-rgt-identity75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in b around 0 53.8%
Taylor expanded in a around 0 34.7%
Final simplification34.7%
herbie shell --seed 2024022
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))