
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t_1 + \left(eh \cdot \cos t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t_1 + \left(eh \cdot \cos t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(+
(* (* ew (sin t)) (/ 1.0 (hypot 1.0 t_1)))
(* (sin (atan t_1)) (* eh (cos t)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs((((ew * sin(t)) * (1.0 / hypot(1.0, t_1))) + (sin(atan(t_1)) * (eh * cos(t)))));
}
public static double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / Math.tan(t);
return Math.abs((((ew * Math.sin(t)) * (1.0 / Math.hypot(1.0, t_1))) + (Math.sin(Math.atan(t_1)) * (eh * Math.cos(t)))));
}
def code(eh, ew, t): t_1 = (eh / ew) / math.tan(t) return math.fabs((((ew * math.sin(t)) * (1.0 / math.hypot(1.0, t_1))) + (math.sin(math.atan(t_1)) * (eh * math.cos(t)))))
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(Float64(Float64(Float64(ew * sin(t)) * Float64(1.0 / hypot(1.0, t_1))) + Float64(sin(atan(t_1)) * Float64(eh * cos(t))))) end
function tmp = code(eh, ew, t) t_1 = (eh / ew) / tan(t); tmp = abs((((ew * sin(t)) * (1.0 / hypot(1.0, t_1))) + (sin(atan(t_1)) * (eh * cos(t))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision] * N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\left(ew \cdot \sin t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, t_1\right)} + \sin \tan^{-1} t_1 \cdot \left(eh \cdot \cos t\right)\right|
\end{array}
\end{array}
Initial program 99.8%
associate-/l/99.8%
cos-atan99.8%
hypot-1-def99.8%
associate-/l/99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (sin (atan (/ (/ eh ew) (tan t)))) (* eh (cos t))) (/ ew (/ (hypot 1.0 (/ eh (* ew (tan t)))) (sin t))))))
double code(double eh, double ew, double t) {
return fabs(((sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t))) + (ew / (hypot(1.0, (eh / (ew * tan(t)))) / sin(t)))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.sin(Math.atan(((eh / ew) / Math.tan(t)))) * (eh * Math.cos(t))) + (ew / (Math.hypot(1.0, (eh / (ew * Math.tan(t)))) / Math.sin(t)))));
}
def code(eh, ew, t): return math.fabs(((math.sin(math.atan(((eh / ew) / math.tan(t)))) * (eh * math.cos(t))) + (ew / (math.hypot(1.0, (eh / (ew * math.tan(t)))) / math.sin(t)))))
function code(eh, ew, t) return abs(Float64(Float64(sin(atan(Float64(Float64(eh / ew) / tan(t)))) * Float64(eh * cos(t))) + Float64(ew / Float64(hypot(1.0, Float64(eh / Float64(ew * tan(t)))) / sin(t))))) end
function tmp = code(eh, ew, t) tmp = abs(((sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t))) + (ew / (hypot(1.0, (eh / (ew * tan(t)))) / sin(t))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(ew / N[(N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + \frac{ew}{\frac{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}{\sin t}}\right|
\end{array}
Initial program 99.8%
associate-/l/99.8%
cos-atan99.8%
hypot-1-def99.8%
associate-/l/99.8%
Applied egg-rr99.8%
un-div-inv99.8%
associate-/l*99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (sin (atan (/ (/ eh ew) (tan t)))) (* eh (cos t))) (* (* ew (sin t)) (cos (atan (/ (/ eh t) ew)))))))
double code(double eh, double ew, double t) {
return fabs(((sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t))) + ((ew * sin(t)) * cos(atan(((eh / t) / 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(((sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t))) + ((ew * sin(t)) * cos(atan(((eh / t) / ew))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.sin(Math.atan(((eh / ew) / Math.tan(t)))) * (eh * Math.cos(t))) + ((ew * Math.sin(t)) * Math.cos(Math.atan(((eh / t) / ew))))));
}
def code(eh, ew, t): return math.fabs(((math.sin(math.atan(((eh / ew) / math.tan(t)))) * (eh * math.cos(t))) + ((ew * math.sin(t)) * math.cos(math.atan(((eh / t) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(sin(atan(Float64(Float64(eh / ew) / tan(t)))) * Float64(eh * cos(t))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(Float64(eh / t) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs(((sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t))) + ((ew * sin(t)) * cos(atan(((eh / t) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / t), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 98.9%
associate-/r*98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* ew (sin t)) (/ 1.0 (hypot 1.0 (/ eh (* ew (tan t))))) (* eh (- (cos t))))))
double code(double eh, double ew, double t) {
return fabs(fma((ew * sin(t)), (1.0 / hypot(1.0, (eh / (ew * tan(t))))), (eh * -cos(t))));
}
function code(eh, ew, t) return abs(fma(Float64(ew * sin(t)), Float64(1.0 / hypot(1.0, Float64(eh / Float64(ew * tan(t))))), Float64(eh * Float64(-cos(t))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}, eh \cdot \left(-\cos t\right)\right)\right|
\end{array}
Initial program 99.8%
fma-def99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan62.2%
associate-*r/59.3%
associate-/l/59.5%
hypot-1-def68.0%
associate-/l/72.0%
Applied egg-rr72.0%
associate-/l*83.0%
associate-/r/79.0%
associate-/l/78.9%
associate-/l/79.1%
Simplified79.1%
Taylor expanded in eh around -inf 98.8%
mul-1-neg98.8%
distribute-rgt-neg-out98.8%
Simplified98.8%
associate-/l/79.1%
cos-atan79.1%
metadata-eval79.1%
hypot-udef79.1%
inv-pow79.1%
sqr-pow79.1%
associate-/r*79.1%
metadata-eval79.1%
associate-/r*79.1%
metadata-eval79.1%
Applied egg-rr98.8%
pow-sqr79.1%
metadata-eval79.1%
unpow-179.1%
Simplified98.8%
Final simplification98.8%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.6e-20) (not (<= ew 6.1e-130))) (fabs (fma (* ew (sin t)) (cos (atan (/ eh (* ew (tan t))))) (- eh))) (fabs (* eh (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.6e-20) || !(ew <= 6.1e-130)) {
tmp = fabs(fma((ew * sin(t)), cos(atan((eh / (ew * tan(t))))), -eh));
} else {
tmp = fabs((eh * cos(t)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.6e-20) || !(ew <= 6.1e-130)) tmp = abs(fma(Float64(ew * sin(t)), cos(atan(Float64(eh / Float64(ew * tan(t))))), Float64(-eh))); else tmp = abs(Float64(eh * cos(t))); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.6e-20], N[Not[LessEqual[ew, 6.1e-130]], $MachinePrecision]], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + (-eh)), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.6 \cdot 10^{-20} \lor \neg \left(ew \leq 6.1 \cdot 10^{-130}\right):\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot \sin t, \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), -eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\end{array}
\end{array}
if ew < -1.59999999999999985e-20 or 6.09999999999999996e-130 < ew Initial program 99.8%
fma-def99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan79.3%
associate-*r/74.9%
associate-/l/74.8%
hypot-1-def77.7%
associate-/l/78.6%
Applied egg-rr78.6%
associate-/l*91.8%
associate-/r/90.9%
associate-/l/90.8%
associate-/l/91.1%
Simplified91.1%
Taylor expanded in eh around -inf 98.9%
mul-1-neg98.9%
distribute-rgt-neg-out98.9%
Simplified98.9%
Taylor expanded in t around 0 84.4%
mul-1-neg84.4%
Simplified84.4%
if -1.59999999999999985e-20 < ew < 6.09999999999999996e-130Initial program 99.7%
fma-def99.7%
associate-/l/99.7%
associate-*l*99.7%
associate-/l/99.7%
Simplified99.7%
associate-*r*99.7%
sin-atan32.8%
associate-*r/32.6%
associate-/l/33.0%
hypot-1-def51.2%
associate-/l/60.7%
Applied egg-rr60.7%
associate-/l*67.9%
associate-/r/58.4%
associate-/l/58.3%
associate-/l/58.3%
Simplified58.3%
Taylor expanded in eh around -inf 98.6%
mul-1-neg98.6%
distribute-rgt-neg-out98.6%
Simplified98.6%
Taylor expanded in t around 0 72.8%
Taylor expanded in ew around 0 91.4%
mul-1-neg91.4%
distribute-rgt-neg-out91.4%
Simplified91.4%
Final simplification86.9%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* ew (sin t)) (/ 1.0 (hypot 1.0 (/ eh (* ew (tan t))))) (* eh (cos t)))))
double code(double eh, double ew, double t) {
return fabs(fma((ew * sin(t)), (1.0 / hypot(1.0, (eh / (ew * tan(t))))), (eh * cos(t))));
}
function code(eh, ew, t) return abs(fma(Float64(ew * sin(t)), Float64(1.0 / hypot(1.0, Float64(eh / Float64(ew * tan(t))))), Float64(eh * cos(t)))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}, eh \cdot \cos t\right)\right|
\end{array}
Initial program 99.8%
fma-def99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan62.2%
associate-*r/59.3%
associate-/l/59.5%
hypot-1-def68.0%
associate-/l/72.0%
Applied egg-rr72.0%
associate-/l*83.0%
associate-/r/79.0%
associate-/l/78.9%
associate-/l/79.1%
Simplified79.1%
associate-/l/79.1%
cos-atan79.1%
metadata-eval79.1%
hypot-udef79.1%
inv-pow79.1%
sqr-pow79.1%
associate-/r*79.1%
metadata-eval79.1%
associate-/r*79.1%
metadata-eval79.1%
Applied egg-rr79.1%
pow-sqr79.1%
metadata-eval79.1%
unpow-179.1%
Simplified79.1%
Taylor expanded in eh around inf 98.7%
Final simplification98.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* ew (sin t)) (* (sin (atan (/ (/ eh ew) (tan t)))) (* eh (cos t))))))
double code(double eh, double ew, double t) {
return fabs(((ew * sin(t)) + (sin(atan(((eh / ew) / tan(t)))) * (eh * cos(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(((ew * sin(t)) + (sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t)))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * Math.sin(t)) + (Math.sin(Math.atan(((eh / ew) / Math.tan(t)))) * (eh * Math.cos(t)))));
}
def code(eh, ew, t): return math.fabs(((ew * math.sin(t)) + (math.sin(math.atan(((eh / ew) / math.tan(t)))) * (eh * math.cos(t)))))
function code(eh, ew, t) return abs(Float64(Float64(ew * sin(t)) + Float64(sin(atan(Float64(Float64(eh / ew) / tan(t)))) * Float64(eh * cos(t))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * sin(t)) + (sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \sin t + \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right)\right|
\end{array}
Initial program 99.8%
associate-/l/99.8%
cos-atan99.8%
hypot-1-def99.8%
associate-/l/99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 98.5%
Final simplification98.5%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -7.2e-20) (not (<= ew 4.2e-129))) (fabs (fma (* ew (sin t)) (/ 1.0 (hypot 1.0 (/ eh (* ew (tan t))))) eh)) (fabs (* eh (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -7.2e-20) || !(ew <= 4.2e-129)) {
tmp = fabs(fma((ew * sin(t)), (1.0 / hypot(1.0, (eh / (ew * tan(t))))), eh));
} else {
tmp = fabs((eh * cos(t)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((ew <= -7.2e-20) || !(ew <= 4.2e-129)) tmp = abs(fma(Float64(ew * sin(t)), Float64(1.0 / hypot(1.0, Float64(eh / Float64(ew * tan(t))))), eh)); else tmp = abs(Float64(eh * cos(t))); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -7.2e-20], N[Not[LessEqual[ew, 4.2e-129]], $MachinePrecision]], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -7.2 \cdot 10^{-20} \lor \neg \left(ew \leq 4.2 \cdot 10^{-129}\right):\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}, eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\end{array}
\end{array}
if ew < -7.19999999999999948e-20 or 4.2e-129 < ew Initial program 99.8%
fma-def99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan79.3%
associate-*r/74.9%
associate-/l/74.8%
hypot-1-def77.7%
associate-/l/78.6%
Applied egg-rr78.6%
associate-/l*91.8%
associate-/r/90.9%
associate-/l/90.8%
associate-/l/91.1%
Simplified91.1%
associate-/l/91.1%
cos-atan91.1%
metadata-eval91.1%
hypot-udef91.1%
inv-pow91.1%
sqr-pow91.1%
associate-/r*91.1%
metadata-eval91.1%
associate-/r*91.1%
metadata-eval91.1%
Applied egg-rr91.1%
pow-sqr91.1%
metadata-eval91.1%
unpow-191.1%
Simplified91.1%
Taylor expanded in t around 0 84.4%
if -7.19999999999999948e-20 < ew < 4.2e-129Initial program 99.7%
fma-def99.7%
associate-/l/99.7%
associate-*l*99.7%
associate-/l/99.7%
Simplified99.7%
associate-*r*99.7%
sin-atan32.8%
associate-*r/32.6%
associate-/l/33.0%
hypot-1-def51.2%
associate-/l/60.7%
Applied egg-rr60.7%
associate-/l*67.9%
associate-/r/58.4%
associate-/l/58.3%
associate-/l/58.3%
Simplified58.3%
Taylor expanded in eh around -inf 98.6%
mul-1-neg98.6%
distribute-rgt-neg-out98.6%
Simplified98.6%
Taylor expanded in t around 0 72.8%
Taylor expanded in ew around 0 91.4%
mul-1-neg91.4%
distribute-rgt-neg-out91.4%
Simplified91.4%
Final simplification86.9%
(FPCore (eh ew t) :precision binary64 (if (or (<= t 1.26e-73) (not (<= t 4.2e-5))) (fabs (* eh (cos t))) (fabs (* (* ew t) (cos (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= 1.26e-73) || !(t <= 4.2e-5)) {
tmp = fabs((eh * cos(t)));
} else {
tmp = fabs(((ew * t) * cos(atan(((eh / ew) / tan(t))))));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= 1.26d-73) .or. (.not. (t <= 4.2d-5))) then
tmp = abs((eh * cos(t)))
else
tmp = abs(((ew * t) * cos(atan(((eh / ew) / tan(t))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= 1.26e-73) || !(t <= 4.2e-5)) {
tmp = Math.abs((eh * Math.cos(t)));
} else {
tmp = Math.abs(((ew * t) * Math.cos(Math.atan(((eh / ew) / Math.tan(t))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= 1.26e-73) or not (t <= 4.2e-5): tmp = math.fabs((eh * math.cos(t))) else: tmp = math.fabs(((ew * t) * math.cos(math.atan(((eh / ew) / math.tan(t)))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= 1.26e-73) || !(t <= 4.2e-5)) tmp = abs(Float64(eh * cos(t))); else tmp = abs(Float64(Float64(ew * t) * cos(atan(Float64(Float64(eh / ew) / tan(t)))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= 1.26e-73) || ~((t <= 4.2e-5))) tmp = abs((eh * cos(t))); else tmp = abs(((ew * t) * cos(atan(((eh / ew) / tan(t)))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, 1.26e-73], N[Not[LessEqual[t, 4.2e-5]], $MachinePrecision]], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * t), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.26 \cdot 10^{-73} \lor \neg \left(t \leq 4.2 \cdot 10^{-5}\right):\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(ew \cdot t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\end{array}
\end{array}
if t < 1.26000000000000001e-73 or 4.19999999999999977e-5 < t Initial program 99.8%
fma-def99.7%
associate-/l/99.7%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
associate-*r*99.7%
sin-atan60.9%
associate-*r/57.7%
associate-/l/57.9%
hypot-1-def66.6%
associate-/l/71.0%
Applied egg-rr71.0%
associate-/l*82.1%
associate-/r/77.7%
associate-/l/77.6%
associate-/l/77.8%
Simplified77.8%
Taylor expanded in eh around -inf 98.7%
mul-1-neg98.7%
distribute-rgt-neg-out98.7%
Simplified98.7%
Taylor expanded in t around 0 60.4%
Taylor expanded in ew around 0 66.9%
mul-1-neg66.9%
distribute-rgt-neg-out66.9%
Simplified66.9%
if 1.26000000000000001e-73 < t < 4.19999999999999977e-5Initial program 99.9%
fma-def99.9%
associate-/l/99.9%
associate-*l*99.9%
associate-/l/99.9%
Simplified99.9%
associate-*r*99.9%
sin-atan79.5%
associate-*r/79.1%
associate-/l/79.1%
hypot-1-def84.6%
associate-/l/84.7%
Applied egg-rr84.7%
associate-/l*94.7%
associate-/r/94.7%
associate-/l/94.6%
associate-/l/94.7%
Simplified94.7%
Taylor expanded in eh around -inf 99.9%
mul-1-neg99.9%
distribute-rgt-neg-out99.9%
Simplified99.9%
Taylor expanded in t around 0 98.4%
Taylor expanded in t around inf 78.0%
*-commutative78.0%
associate-*r*78.0%
associate-/l/78.0%
Simplified78.0%
Final simplification67.7%
(FPCore (eh ew t) :precision binary64 (fabs (* eh (cos t))))
double code(double eh, double ew, double t) {
return fabs((eh * cos(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 * cos(t)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((eh * Math.cos(t)));
}
def code(eh, ew, t): return math.fabs((eh * math.cos(t)))
function code(eh, ew, t) return abs(Float64(eh * cos(t))) end
function tmp = code(eh, ew, t) tmp = abs((eh * cos(t))); end
code[eh_, ew_, t_] := N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \cos t\right|
\end{array}
Initial program 99.8%
fma-def99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan62.2%
associate-*r/59.3%
associate-/l/59.5%
hypot-1-def68.0%
associate-/l/72.0%
Applied egg-rr72.0%
associate-/l*83.0%
associate-/r/79.0%
associate-/l/78.9%
associate-/l/79.1%
Simplified79.1%
Taylor expanded in eh around -inf 98.8%
mul-1-neg98.8%
distribute-rgt-neg-out98.8%
Simplified98.8%
Taylor expanded in t around 0 63.2%
Taylor expanded in ew around 0 63.7%
mul-1-neg63.7%
distribute-rgt-neg-out63.7%
Simplified63.7%
Final simplification63.7%
(FPCore (eh ew t) :precision binary64 (fabs eh))
double code(double eh, double ew, double t) {
return fabs(eh);
}
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)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(eh);
}
def code(eh, ew, t): return math.fabs(eh)
function code(eh, ew, t) return abs(eh) end
function tmp = code(eh, ew, t) tmp = abs(eh); end
code[eh_, ew_, t_] := N[Abs[eh], $MachinePrecision]
\begin{array}{l}
\\
\left|eh\right|
\end{array}
Initial program 99.8%
fma-def99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan62.2%
associate-*r/59.3%
associate-/l/59.5%
hypot-1-def68.0%
associate-/l/72.0%
Applied egg-rr72.0%
associate-/l*83.0%
associate-/r/79.0%
associate-/l/78.9%
associate-/l/79.1%
Simplified79.1%
Taylor expanded in eh around -inf 98.8%
mul-1-neg98.8%
distribute-rgt-neg-out98.8%
Simplified98.8%
Taylor expanded in t around 0 63.2%
Taylor expanded in t around 0 39.9%
neg-mul-139.9%
Simplified39.9%
Final simplification39.9%
herbie shell --seed 2023214
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))