
(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(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-def99.5%
Applied egg-rr99.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(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.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0024) (not (<= a 320.0))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0024) || !(a <= 320.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.0024d0)) .or. (.not. (a <= 320.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.0024) || !(a <= 320.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.0024) or not (a <= 320.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.0024) || !(a <= 320.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.0024) || ~((a <= 320.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.0024], N[Not[LessEqual[a, 320.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.0024 \lor \neg \left(a \leq 320\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -0.00239999999999999979 or 320 < a Initial program 54.6%
+-commutative54.6%
Simplified54.6%
Taylor expanded in b around 0 53.7%
if -0.00239999999999999979 < a < 320Initial program 98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in a around 0 98.2%
Final simplification77.3%
(FPCore (r a b) :precision binary64 (if (<= a -0.00195) (* r (/ (sin b) (cos a))) (if (<= a 320.0) (* r (/ (sin b) (cos b))) (/ (sin b) (/ (cos a) r)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00195) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 320.0) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = sin(b) / (cos(a) / r);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.00195d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 320.0d0) then
tmp = r * (sin(b) / cos(b))
else
tmp = sin(b) / (cos(a) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.00195) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 320.0) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = Math.sin(b) / (Math.cos(a) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.00195: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 320.0: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = math.sin(b) / (math.cos(a) / r) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.00195) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 320.0) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(sin(b) / Float64(cos(a) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.00195) tmp = r * (sin(b) / cos(a)); elseif (a <= 320.0) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) / (cos(a) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.00195], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 320.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00195:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 320:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if a < -0.0019499999999999999Initial program 47.3%
+-commutative47.3%
Simplified47.3%
Taylor expanded in b around 0 46.4%
if -0.0019499999999999999 < a < 320Initial program 98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in a around 0 98.2%
if 320 < a Initial program 63.3%
*-commutative63.3%
associate-/r/63.3%
+-commutative63.3%
Simplified63.3%
Taylor expanded in b around 0 62.3%
Final simplification77.3%
(FPCore (r a b) :precision binary64 (if (<= a -0.000185) (/ (* r (sin b)) (cos a)) (if (<= a 320.0) (* r (/ (sin b) (cos b))) (/ (sin b) (/ (cos a) r)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.000185) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 320.0) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = sin(b) / (cos(a) / r);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.000185d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 320.0d0) then
tmp = r * (sin(b) / cos(b))
else
tmp = sin(b) / (cos(a) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.000185) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 320.0) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = Math.sin(b) / (Math.cos(a) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.000185: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 320.0: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = math.sin(b) / (math.cos(a) / r) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.000185) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 320.0) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(sin(b) / Float64(cos(a) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.000185) tmp = (r * sin(b)) / cos(a); elseif (a <= 320.0) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) / (cos(a) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.000185], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 320.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000185:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 320:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if a < -1.85e-4Initial program 47.3%
associate-*r/47.3%
+-commutative47.3%
Simplified47.3%
Taylor expanded in b around 0 46.5%
if -1.85e-4 < a < 320Initial program 98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in a around 0 98.2%
if 320 < a Initial program 63.3%
*-commutative63.3%
associate-/r/63.3%
+-commutative63.3%
Simplified63.3%
Taylor expanded in b around 0 62.3%
Final simplification77.4%
(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%
Final simplification77.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 77.8%
*-commutative77.8%
associate-/r/77.6%
+-commutative77.6%
Simplified77.6%
div-inv77.7%
clear-num77.8%
*-commutative77.8%
Applied egg-rr77.8%
Final simplification77.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 77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 51.8%
Final simplification51.8%
(FPCore (r a b) :precision binary64 (if (<= b -38000.0) (* r (sin b)) (* r (/ b (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -38000.0) {
tmp = r * sin(b);
} else {
tmp = r * (b / cos((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 (b <= (-38000.0d0)) then
tmp = r * sin(b)
else
tmp = r * (b / cos((b + a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -38000.0) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -38000.0: tmp = r * math.sin(b) else: tmp = r * (b / math.cos((b + a))) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -38000.0) tmp = Float64(r * sin(b)); else tmp = Float64(r * Float64(b / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -38000.0) tmp = r * sin(b); else tmp = r * (b / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -38000.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -38000:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -38000Initial program 62.6%
+-commutative62.6%
Simplified62.6%
associate-*r/62.5%
clear-num62.3%
*-commutative62.3%
Applied egg-rr62.3%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 12.0%
if -38000 < b Initial program 84.1%
+-commutative84.1%
Simplified84.1%
Taylor expanded in b around 0 66.1%
Final simplification50.3%
(FPCore (r a b) :precision binary64 (if (<= b -65000.0) (/ 1.0 (/ (/ 1.0 (sin b)) r)) (* r (/ b (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -65000.0) {
tmp = 1.0 / ((1.0 / sin(b)) / r);
} else {
tmp = r * (b / cos((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 (b <= (-65000.0d0)) then
tmp = 1.0d0 / ((1.0d0 / sin(b)) / r)
else
tmp = r * (b / cos((b + a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -65000.0) {
tmp = 1.0 / ((1.0 / Math.sin(b)) / r);
} else {
tmp = r * (b / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -65000.0: tmp = 1.0 / ((1.0 / math.sin(b)) / r) else: tmp = r * (b / math.cos((b + a))) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -65000.0) tmp = Float64(1.0 / Float64(Float64(1.0 / sin(b)) / r)); else tmp = Float64(r * Float64(b / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -65000.0) tmp = 1.0 / ((1.0 / sin(b)) / r); else tmp = r * (b / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -65000.0], N[(1.0 / N[(N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -65000:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{\sin b}}{r}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -65000Initial program 62.6%
+-commutative62.6%
Simplified62.6%
associate-*r/62.5%
clear-num62.3%
*-commutative62.3%
Applied egg-rr62.3%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 12.0%
associate-/r*12.0%
Simplified12.0%
if -65000 < b Initial program 84.1%
+-commutative84.1%
Simplified84.1%
Taylor expanded in b around 0 66.1%
Final simplification50.3%
(FPCore (r a b) :precision binary64 (if (<= b -35000.0) (/ 1.0 (/ (/ 1.0 (sin b)) r)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -35000.0) {
tmp = 1.0 / ((1.0 / sin(b)) / r);
} else {
tmp = (r * b) / cos((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 (b <= (-35000.0d0)) then
tmp = 1.0d0 / ((1.0d0 / sin(b)) / r)
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -35000.0) {
tmp = 1.0 / ((1.0 / Math.sin(b)) / r);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -35000.0: tmp = 1.0 / ((1.0 / math.sin(b)) / r) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -35000.0) tmp = Float64(1.0 / Float64(Float64(1.0 / sin(b)) / r)); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -35000.0) tmp = 1.0 / ((1.0 / sin(b)) / r); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -35000.0], N[(1.0 / N[(N[(1.0 / N[Sin[b], $MachinePrecision]), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -35000:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{\sin b}}{r}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -35000Initial program 62.6%
+-commutative62.6%
Simplified62.6%
associate-*r/62.5%
clear-num62.3%
*-commutative62.3%
Applied egg-rr62.3%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 12.0%
associate-/r*12.0%
Simplified12.0%
if -35000 < b Initial program 84.1%
associate-*r/84.1%
+-commutative84.1%
Simplified84.1%
Taylor expanded in b around 0 66.1%
Final simplification50.3%
(FPCore (r a b) :precision binary64 (if (<= b -4500000.0) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4500000.0) {
tmp = r * sin(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 <= (-4500000.0d0)) then
tmp = r * sin(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 <= -4500000.0) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -4500000.0: tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -4500000.0) tmp = Float64(r * sin(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -4500000.0) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4500000.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4500000:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.5e6Initial program 62.6%
+-commutative62.6%
Simplified62.6%
associate-*r/62.5%
clear-num62.3%
*-commutative62.3%
Applied egg-rr62.3%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 12.0%
if -4.5e6 < b Initial program 84.1%
+-commutative84.1%
Simplified84.1%
Taylor expanded in b around 0 66.1%
Final simplification50.2%
(FPCore (r a b) :precision binary64 (if (<= b -4500000.0) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4500000.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 <= (-4500000.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 <= -4500000.0) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -4500000.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 <= -4500000.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 <= -4500000.0) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4500000.0], 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 -4500000:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -4.5e6Initial program 62.6%
+-commutative62.6%
Simplified62.6%
associate-*r/62.5%
clear-num62.3%
*-commutative62.3%
Applied egg-rr62.3%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 12.0%
if -4.5e6 < b Initial program 84.1%
+-commutative84.1%
Simplified84.1%
Taylor expanded in b around 0 66.1%
*-commutative66.1%
associate-/l*66.0%
associate-/r/66.1%
Simplified66.1%
Final simplification50.3%
(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.8%
+-commutative77.8%
Simplified77.8%
associate-*r/77.7%
clear-num77.5%
*-commutative77.5%
Applied egg-rr77.5%
Taylor expanded in b around 0 51.6%
Taylor expanded in a around 0 38.4%
Final simplification38.4%
(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%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 47.8%
Taylor expanded in a around 0 34.6%
Final simplification34.6%
herbie shell --seed 2023172
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))