
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (* (/ eh (- ew)) (tan t))))) (fabs (- (* (cos t) (* ew (cos t_1))) (* eh (* (sin t) (sin t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / -ew) * tan(t)));
return fabs(((cos(t) * (ew * cos(t_1))) - (eh * (sin(t) * sin(t_1)))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / -ew) * tan(t)))
code = abs(((cos(t) * (ew * cos(t_1))) - (eh * (sin(t) * sin(t_1)))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / -ew) * Math.tan(t)));
return Math.abs(((Math.cos(t) * (ew * Math.cos(t_1))) - (eh * (Math.sin(t) * Math.sin(t_1)))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / -ew) * math.tan(t))) return math.fabs(((math.cos(t) * (ew * math.cos(t_1))) - (eh * (math.sin(t) * math.sin(t_1)))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / Float64(-ew)) * tan(t))) return abs(Float64(Float64(cos(t) * Float64(ew * cos(t_1))) - Float64(eh * Float64(sin(t) * sin(t_1))))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / -ew) * tan(t))); tmp = abs(((cos(t) * (ew * cos(t_1))) - (eh * (sin(t) * sin(t_1))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / (-ew)), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * N[(ew * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{-ew} \cdot \tan t\right)\\
\left|\cos t \cdot \left(ew \cdot \cos t_1\right) - eh \cdot \left(\sin t \cdot \sin t_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (cos t) (* ew (/ 1.0 (hypot 1.0 (* (/ eh ew) (tan t)))))) (* eh (* (sin t) (sin (atan (* (/ eh (- ew)) (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(((cos(t) * (ew * (1.0 / hypot(1.0, ((eh / ew) * tan(t)))))) - (eh * (sin(t) * sin(atan(((eh / -ew) * tan(t))))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.cos(t) * (ew * (1.0 / Math.hypot(1.0, ((eh / ew) * Math.tan(t)))))) - (eh * (Math.sin(t) * Math.sin(Math.atan(((eh / -ew) * Math.tan(t))))))));
}
def code(eh, ew, t): return math.fabs(((math.cos(t) * (ew * (1.0 / math.hypot(1.0, ((eh / ew) * math.tan(t)))))) - (eh * (math.sin(t) * math.sin(math.atan(((eh / -ew) * math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(Float64(cos(t) * Float64(ew * Float64(1.0 / hypot(1.0, Float64(Float64(eh / ew) * tan(t)))))) - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(eh / Float64(-ew)) * tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((cos(t) * (ew * (1.0 / hypot(1.0, ((eh / ew) * tan(t)))))) - (eh * (sin(t) * sin(atan(((eh / -ew) * tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * N[(ew * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / (-ew)), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\cos t \cdot \left(ew \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{ew} \cdot \tan t\right)}\right) - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{eh}{-ew} \cdot \tan t\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
cos-atan99.8%
frac-2neg99.8%
metadata-eval99.8%
hypot-1-def99.8%
add-sqr-sqrt54.5%
sqrt-unprod95.8%
sqr-neg95.8%
sqrt-unprod45.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
neg-mul-199.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (cos t) (* ew (cos (atan (* (/ eh (- ew)) (tan t)))))) (* eh (* (sin t) (sin (atan (/ (- eh) (/ ew t)))))))))
double code(double eh, double ew, double t) {
return fabs(((cos(t) * (ew * cos(atan(((eh / -ew) * tan(t)))))) - (eh * (sin(t) * sin(atan((-eh / (ew / t))))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((cos(t) * (ew * cos(atan(((eh / -ew) * tan(t)))))) - (eh * (sin(t) * sin(atan((-eh / (ew / t))))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.cos(t) * (ew * Math.cos(Math.atan(((eh / -ew) * Math.tan(t)))))) - (eh * (Math.sin(t) * Math.sin(Math.atan((-eh / (ew / t))))))));
}
def code(eh, ew, t): return math.fabs(((math.cos(t) * (ew * math.cos(math.atan(((eh / -ew) * math.tan(t)))))) - (eh * (math.sin(t) * math.sin(math.atan((-eh / (ew / t))))))))
function code(eh, ew, t) return abs(Float64(Float64(cos(t) * Float64(ew * cos(atan(Float64(Float64(eh / Float64(-ew)) * tan(t)))))) - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(-eh) / Float64(ew / t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((cos(t) * (ew * cos(atan(((eh / -ew) * tan(t)))))) - (eh * (sin(t) * sin(atan((-eh / (ew / t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * N[(ew * N[Cos[N[ArcTan[N[(N[(eh / (-ew)), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) / N[(ew / t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\cos t \cdot \left(ew \cdot \cos \tan^{-1} \left(\frac{eh}{-ew} \cdot \tan t\right)\right) - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{t}}\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 99.1%
associate-/l*99.1%
associate-*r/99.1%
neg-mul-199.1%
Simplified99.1%
Final simplification99.1%
(FPCore (eh ew t)
:precision binary64
(if (or (<= ew -1.7e+82) (not (<= ew 1.35e+98)))
(fabs
(+ (* (cos t) (* ew (cos (atan (* (/ eh (- ew)) (tan t)))))) (* eh 0.0)))
(fabs (+ (* eh (sin t)) (/ ew (hypot 1.0 (/ eh (/ ew (tan t)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.7e+82) || !(ew <= 1.35e+98)) {
tmp = fabs(((cos(t) * (ew * cos(atan(((eh / -ew) * tan(t)))))) + (eh * 0.0)));
} else {
tmp = fabs(((eh * sin(t)) + (ew / hypot(1.0, (eh / (ew / tan(t)))))));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.7e+82) || !(ew <= 1.35e+98)) {
tmp = Math.abs(((Math.cos(t) * (ew * Math.cos(Math.atan(((eh / -ew) * Math.tan(t)))))) + (eh * 0.0)));
} else {
tmp = Math.abs(((eh * Math.sin(t)) + (ew / Math.hypot(1.0, (eh / (ew / Math.tan(t)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.7e+82) or not (ew <= 1.35e+98): tmp = math.fabs(((math.cos(t) * (ew * math.cos(math.atan(((eh / -ew) * math.tan(t)))))) + (eh * 0.0))) else: tmp = math.fabs(((eh * math.sin(t)) + (ew / math.hypot(1.0, (eh / (ew / math.tan(t))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.7e+82) || !(ew <= 1.35e+98)) tmp = abs(Float64(Float64(cos(t) * Float64(ew * cos(atan(Float64(Float64(eh / Float64(-ew)) * tan(t)))))) + Float64(eh * 0.0))); else tmp = abs(Float64(Float64(eh * sin(t)) + Float64(ew / hypot(1.0, Float64(eh / Float64(ew / tan(t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.7e+82) || ~((ew <= 1.35e+98))) tmp = abs(((cos(t) * (ew * cos(atan(((eh / -ew) * tan(t)))))) + (eh * 0.0))); else tmp = abs(((eh * sin(t)) + (ew / hypot(1.0, (eh / (ew / tan(t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.7e+82], N[Not[LessEqual[ew, 1.35e+98]], $MachinePrecision]], N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * N[(ew * N[Cos[N[ArcTan[N[(N[(eh / (-ew)), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eh * 0.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(ew / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.7 \cdot 10^{+82} \lor \neg \left(ew \leq 1.35 \cdot 10^{+98}\right):\\
\;\;\;\;\left|\cos t \cdot \left(ew \cdot \cos \tan^{-1} \left(\frac{eh}{-ew} \cdot \tan t\right)\right) + eh \cdot 0\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \sin t + \frac{ew}{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\right)}\right|\\
\end{array}
\end{array}
if ew < -1.69999999999999997e82 or 1.35e98 < ew Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 98.8%
associate-/l*98.8%
associate-*r/98.8%
neg-mul-198.8%
Simplified98.8%
Applied egg-rr94.5%
*-commutative94.5%
associate-/l*94.5%
+-inverses94.5%
associate-/r/94.5%
metadata-eval94.5%
+-inverses94.5%
*-commutative94.5%
+-inverses94.5%
Simplified94.5%
if -1.69999999999999997e82 < ew < 1.35e98Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
*-commutative99.8%
sin-atan72.5%
associate-*l/72.5%
associate-/l*72.5%
add-sqr-sqrt37.4%
sqrt-unprod56.3%
sqr-neg56.3%
sqrt-unprod34.2%
add-sqr-sqrt71.4%
Applied egg-rr80.6%
associate-/l*80.7%
associate-*l*80.6%
associate-/r/80.8%
Simplified80.8%
Taylor expanded in eh around -inf 97.9%
mul-1-neg97.9%
Simplified97.9%
Taylor expanded in t around 0 86.3%
*-commutative34.8%
associate-*r/34.8%
mul-1-neg34.8%
distribute-lft-neg-in34.8%
*-commutative34.8%
Simplified86.3%
expm1-log1p-u28.5%
expm1-udef10.4%
Applied egg-rr62.6%
expm1-def79.2%
expm1-log1p86.3%
*-commutative86.3%
associate-/r/86.3%
Simplified86.3%
Final simplification89.1%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh (sin t)) (/ (* (cos t) ew) (hypot 1.0 (* (/ eh ew) (tan t)))))))
double code(double eh, double ew, double t) {
return fabs(((eh * sin(t)) + ((cos(t) * ew) / hypot(1.0, ((eh / ew) * tan(t))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * Math.sin(t)) + ((Math.cos(t) * ew) / Math.hypot(1.0, ((eh / ew) * Math.tan(t))))));
}
def code(eh, ew, t): return math.fabs(((eh * math.sin(t)) + ((math.cos(t) * ew) / math.hypot(1.0, ((eh / ew) * math.tan(t))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * sin(t)) + Float64(Float64(cos(t) * ew) / hypot(1.0, Float64(Float64(eh / ew) * tan(t)))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * sin(t)) + ((cos(t) * ew) / hypot(1.0, ((eh / ew) * tan(t)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \sin t + \frac{\cos t \cdot ew}{\mathsf{hypot}\left(1, \frac{eh}{ew} \cdot \tan t\right)}\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
*-commutative99.8%
sin-atan82.1%
associate-*l/82.1%
associate-/l*82.1%
add-sqr-sqrt44.9%
sqrt-unprod71.1%
sqr-neg71.1%
sqrt-unprod36.5%
add-sqr-sqrt81.3%
Applied egg-rr87.3%
associate-/l*87.3%
associate-*l*87.2%
associate-/r/87.4%
Simplified87.4%
Taylor expanded in eh around -inf 98.2%
mul-1-neg98.2%
Simplified98.2%
associate-*r*63.6%
cos-atan63.3%
un-div-inv63.3%
metadata-eval63.3%
associate-*r/63.3%
*-commutative63.3%
associate-*r/63.3%
*-commutative63.3%
frac-times55.3%
sqr-neg55.3%
frac-times63.3%
*-commutative63.3%
associate-*r/63.3%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.65e+82) (not (<= ew 1.6e+100))) (fabs (+ (* eh 0.0) (/ (* (cos t) ew) (hypot 1.0 (* (/ eh ew) (tan t)))))) (fabs (+ (* eh (sin t)) (/ ew (hypot 1.0 (/ eh (/ ew (tan t)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.65e+82) || !(ew <= 1.6e+100)) {
tmp = fabs(((eh * 0.0) + ((cos(t) * ew) / hypot(1.0, ((eh / ew) * tan(t))))));
} else {
tmp = fabs(((eh * sin(t)) + (ew / hypot(1.0, (eh / (ew / tan(t)))))));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.65e+82) || !(ew <= 1.6e+100)) {
tmp = Math.abs(((eh * 0.0) + ((Math.cos(t) * ew) / Math.hypot(1.0, ((eh / ew) * Math.tan(t))))));
} else {
tmp = Math.abs(((eh * Math.sin(t)) + (ew / Math.hypot(1.0, (eh / (ew / Math.tan(t)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.65e+82) or not (ew <= 1.6e+100): tmp = math.fabs(((eh * 0.0) + ((math.cos(t) * ew) / math.hypot(1.0, ((eh / ew) * math.tan(t)))))) else: tmp = math.fabs(((eh * math.sin(t)) + (ew / math.hypot(1.0, (eh / (ew / math.tan(t))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.65e+82) || !(ew <= 1.6e+100)) tmp = abs(Float64(Float64(eh * 0.0) + Float64(Float64(cos(t) * ew) / hypot(1.0, Float64(Float64(eh / ew) * tan(t)))))); else tmp = abs(Float64(Float64(eh * sin(t)) + Float64(ew / hypot(1.0, Float64(eh / Float64(ew / tan(t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.65e+82) || ~((ew <= 1.6e+100))) tmp = abs(((eh * 0.0) + ((cos(t) * ew) / hypot(1.0, ((eh / ew) * tan(t)))))); else tmp = abs(((eh * sin(t)) + (ew / hypot(1.0, (eh / (ew / tan(t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.65e+82], N[Not[LessEqual[ew, 1.6e+100]], $MachinePrecision]], N[Abs[N[(N[(eh * 0.0), $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(ew / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.65 \cdot 10^{+82} \lor \neg \left(ew \leq 1.6 \cdot 10^{+100}\right):\\
\;\;\;\;\left|eh \cdot 0 + \frac{\cos t \cdot ew}{\mathsf{hypot}\left(1, \frac{eh}{ew} \cdot \tan t\right)}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \sin t + \frac{ew}{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\right)}\right|\\
\end{array}
\end{array}
if ew < -1.6499999999999999e82 or 1.5999999999999999e100 < ew Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 98.8%
associate-/l*98.8%
associate-*r/98.8%
neg-mul-198.8%
Simplified98.8%
Applied egg-rr94.5%
*-commutative94.5%
associate-/l*94.5%
+-inverses94.5%
associate-/r/94.5%
metadata-eval94.5%
+-inverses94.5%
*-commutative94.5%
+-inverses94.5%
Simplified94.5%
associate-*r*94.5%
cos-atan94.4%
un-div-inv94.4%
metadata-eval94.4%
associate-*r/94.4%
*-commutative94.4%
associate-*r/94.4%
*-commutative94.4%
frac-times83.4%
sqr-neg83.4%
frac-times94.4%
*-commutative94.4%
associate-*r/94.4%
Applied egg-rr94.4%
if -1.6499999999999999e82 < ew < 1.5999999999999999e100Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
*-commutative99.8%
sin-atan72.5%
associate-*l/72.5%
associate-/l*72.5%
add-sqr-sqrt37.4%
sqrt-unprod56.3%
sqr-neg56.3%
sqrt-unprod34.2%
add-sqr-sqrt71.4%
Applied egg-rr80.6%
associate-/l*80.7%
associate-*l*80.6%
associate-/r/80.8%
Simplified80.8%
Taylor expanded in eh around -inf 97.9%
mul-1-neg97.9%
Simplified97.9%
Taylor expanded in t around 0 86.3%
*-commutative34.8%
associate-*r/34.8%
mul-1-neg34.8%
distribute-lft-neg-in34.8%
*-commutative34.8%
Simplified86.3%
expm1-log1p-u28.5%
expm1-udef10.4%
Applied egg-rr62.6%
expm1-def79.2%
expm1-log1p86.3%
*-commutative86.3%
associate-/r/86.3%
Simplified86.3%
Final simplification89.1%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh 0.0) (* ew (cos (atan (* (/ eh ew) (- (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(((eh * 0.0) + (ew * cos(atan(((eh / ew) * -tan(t)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((eh * 0.0d0) + (ew * cos(atan(((eh / ew) * -tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * 0.0) + (ew * Math.cos(Math.atan(((eh / ew) * -Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs(((eh * 0.0) + (ew * math.cos(math.atan(((eh / ew) * -math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * 0.0) + Float64(ew * cos(atan(Float64(Float64(eh / ew) * Float64(-tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * 0.0) + (ew * cos(atan(((eh / ew) * -tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * 0.0), $MachinePrecision] + N[(ew * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * (-N[Tan[t], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot 0 + ew \cdot \cos \tan^{-1} \left(\frac{eh}{ew} \cdot \left(-\tan t\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 99.1%
associate-/l*99.1%
associate-*r/99.1%
neg-mul-199.1%
Simplified99.1%
Applied egg-rr63.6%
*-commutative63.6%
associate-/l*63.6%
+-inverses63.6%
associate-/r/63.6%
metadata-eval63.6%
+-inverses63.6%
*-commutative63.6%
+-inverses63.6%
Simplified63.6%
Taylor expanded in t around 0 43.7%
*-commutative43.7%
associate-*r/43.7%
mul-1-neg43.7%
distribute-lft-neg-in43.7%
*-commutative43.7%
Simplified43.7%
Final simplification43.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* t eh) (* ew (cos (atan (* (/ eh ew) (- (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(((t * eh) + (ew * cos(atan(((eh / ew) * -tan(t)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((t * eh) + (ew * cos(atan(((eh / ew) * -tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((t * eh) + (ew * Math.cos(Math.atan(((eh / ew) * -Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs(((t * eh) + (ew * math.cos(math.atan(((eh / ew) * -math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(t * eh) + Float64(ew * cos(atan(Float64(Float64(eh / ew) * Float64(-tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((t * eh) + (ew * cos(atan(((eh / ew) * -tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(t * eh), $MachinePrecision] + N[(ew * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * (-N[Tan[t], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|t \cdot eh + ew \cdot \cos \tan^{-1} \left(\frac{eh}{ew} \cdot \left(-\tan t\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
*-commutative99.8%
sin-atan82.1%
associate-*l/82.1%
associate-/l*82.1%
add-sqr-sqrt44.9%
sqrt-unprod71.1%
sqr-neg71.1%
sqrt-unprod36.5%
add-sqr-sqrt81.3%
Applied egg-rr87.3%
associate-/l*87.3%
associate-*l*87.2%
associate-/r/87.4%
Simplified87.4%
Taylor expanded in eh around -inf 98.2%
mul-1-neg98.2%
Simplified98.2%
Taylor expanded in t around 0 78.8%
*-commutative43.7%
associate-*r/43.7%
mul-1-neg43.7%
distribute-lft-neg-in43.7%
*-commutative43.7%
Simplified78.8%
Taylor expanded in t around 0 56.8%
*-commutative56.8%
mul-1-neg56.8%
*-commutative56.8%
Simplified56.8%
Final simplification56.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh (sin t)) (* ew (cos (atan (* t (/ (- eh) ew))))))))
double code(double eh, double ew, double t) {
return fabs(((eh * sin(t)) + (ew * cos(atan((t * (-eh / ew)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((eh * sin(t)) + (ew * cos(atan((t * (-eh / ew)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * Math.sin(t)) + (ew * Math.cos(Math.atan((t * (-eh / ew)))))));
}
def code(eh, ew, t): return math.fabs(((eh * math.sin(t)) + (ew * math.cos(math.atan((t * (-eh / ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * sin(t)) + Float64(ew * cos(atan(Float64(t * Float64(Float64(-eh) / ew))))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * sin(t)) + (ew * cos(atan((t * (-eh / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(ew * N[Cos[N[ArcTan[N[(t * N[((-eh) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \sin t + ew \cdot \cos \tan^{-1} \left(t \cdot \frac{-eh}{ew}\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
*-commutative99.8%
sin-atan82.1%
associate-*l/82.1%
associate-/l*82.1%
add-sqr-sqrt44.9%
sqrt-unprod71.1%
sqr-neg71.1%
sqrt-unprod36.5%
add-sqr-sqrt81.3%
Applied egg-rr87.3%
associate-/l*87.3%
associate-*l*87.2%
associate-/r/87.4%
Simplified87.4%
Taylor expanded in eh around -inf 98.2%
mul-1-neg98.2%
Simplified98.2%
Taylor expanded in t around 0 78.8%
*-commutative43.7%
associate-*r/43.7%
mul-1-neg43.7%
distribute-lft-neg-in43.7%
*-commutative43.7%
Simplified78.8%
Taylor expanded in t around 0 77.3%
associate-/l*42.1%
mul-1-neg42.1%
distribute-frac-neg42.1%
associate-/r/42.1%
Simplified77.3%
Final simplification77.3%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh (sin t)) (/ ew (hypot 1.0 (/ eh (/ ew (tan t))))))))
double code(double eh, double ew, double t) {
return fabs(((eh * sin(t)) + (ew / hypot(1.0, (eh / (ew / tan(t)))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * Math.sin(t)) + (ew / Math.hypot(1.0, (eh / (ew / Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs(((eh * math.sin(t)) + (ew / math.hypot(1.0, (eh / (ew / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * sin(t)) + Float64(ew / hypot(1.0, Float64(eh / Float64(ew / tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * sin(t)) + (ew / hypot(1.0, (eh / (ew / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(ew / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \sin t + \frac{ew}{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\right)}\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
*-commutative99.8%
sin-atan82.1%
associate-*l/82.1%
associate-/l*82.1%
add-sqr-sqrt44.9%
sqrt-unprod71.1%
sqr-neg71.1%
sqrt-unprod36.5%
add-sqr-sqrt81.3%
Applied egg-rr87.3%
associate-/l*87.3%
associate-*l*87.2%
associate-/r/87.4%
Simplified87.4%
Taylor expanded in eh around -inf 98.2%
mul-1-neg98.2%
Simplified98.2%
Taylor expanded in t around 0 78.8%
*-commutative43.7%
associate-*r/43.7%
mul-1-neg43.7%
distribute-lft-neg-in43.7%
*-commutative43.7%
Simplified78.8%
expm1-log1p-u26.8%
expm1-udef15.1%
Applied egg-rr49.6%
expm1-def60.4%
expm1-log1p78.8%
*-commutative78.8%
associate-/r/78.8%
Simplified78.8%
Final simplification78.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh 0.0) (* ew (cos (atan (* t (/ (- eh) ew))))))))
double code(double eh, double ew, double t) {
return fabs(((eh * 0.0) + (ew * cos(atan((t * (-eh / ew)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((eh * 0.0d0) + (ew * cos(atan((t * (-eh / ew)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * 0.0) + (ew * Math.cos(Math.atan((t * (-eh / ew)))))));
}
def code(eh, ew, t): return math.fabs(((eh * 0.0) + (ew * math.cos(math.atan((t * (-eh / ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * 0.0) + Float64(ew * cos(atan(Float64(t * Float64(Float64(-eh) / ew))))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * 0.0) + (ew * cos(atan((t * (-eh / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * 0.0), $MachinePrecision] + N[(ew * N[Cos[N[ArcTan[N[(t * N[((-eh) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot 0 + ew \cdot \cos \tan^{-1} \left(t \cdot \frac{-eh}{ew}\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 99.1%
associate-/l*99.1%
associate-*r/99.1%
neg-mul-199.1%
Simplified99.1%
Applied egg-rr63.6%
*-commutative63.6%
associate-/l*63.6%
+-inverses63.6%
associate-/r/63.6%
metadata-eval63.6%
+-inverses63.6%
*-commutative63.6%
+-inverses63.6%
Simplified63.6%
Taylor expanded in t around 0 43.7%
*-commutative43.7%
associate-*r/43.7%
mul-1-neg43.7%
distribute-lft-neg-in43.7%
*-commutative43.7%
Simplified43.7%
Taylor expanded in t around 0 42.1%
associate-/l*42.1%
mul-1-neg42.1%
distribute-frac-neg42.1%
associate-/r/42.1%
Simplified42.1%
Final simplification42.1%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh 0.0) (/ ew (hypot 1.0 (* (/ eh ew) (tan t)))))))
double code(double eh, double ew, double t) {
return fabs(((eh * 0.0) + (ew / hypot(1.0, ((eh / ew) * tan(t))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * 0.0) + (ew / Math.hypot(1.0, ((eh / ew) * Math.tan(t))))));
}
def code(eh, ew, t): return math.fabs(((eh * 0.0) + (ew / math.hypot(1.0, ((eh / ew) * math.tan(t))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * 0.0) + Float64(ew / hypot(1.0, Float64(Float64(eh / ew) * tan(t)))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * 0.0) + (ew / hypot(1.0, ((eh / ew) * tan(t)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * 0.0), $MachinePrecision] + N[(ew / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot 0 + \frac{ew}{\mathsf{hypot}\left(1, \frac{eh}{ew} \cdot \tan t\right)}\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in t around 0 99.1%
associate-/l*99.1%
associate-*r/99.1%
neg-mul-199.1%
Simplified99.1%
Applied egg-rr63.6%
*-commutative63.6%
associate-/l*63.6%
+-inverses63.6%
associate-/r/63.6%
metadata-eval63.6%
+-inverses63.6%
*-commutative63.6%
+-inverses63.6%
Simplified63.6%
Taylor expanded in t around 0 43.7%
*-commutative43.7%
associate-*r/43.7%
mul-1-neg43.7%
distribute-lft-neg-in43.7%
*-commutative43.7%
Simplified43.7%
expm1-log1p-u26.8%
expm1-udef15.1%
Applied egg-rr15.1%
expm1-def26.6%
expm1-log1p43.4%
Simplified43.4%
Final simplification43.4%
herbie shell --seed 2023305
(FPCore (eh ew t)
:name "Example 2 from Robby"
:precision binary64
(fabs (- (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))