
(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 12 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 (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}
Initial program 99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(+
(* (* eh (cos t)) (sin (atan t_1)))
(/ (* ew (sin t)) (hypot 1.0 t_1))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs((((eh * cos(t)) * sin(atan(t_1))) + ((ew * sin(t)) / hypot(1.0, t_1))));
}
public static double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / Math.tan(t);
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(t_1))) + ((ew * Math.sin(t)) / Math.hypot(1.0, t_1))));
}
def code(eh, ew, t): t_1 = (eh / ew) / math.tan(t) return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(t_1))) + ((ew * math.sin(t)) / math.hypot(1.0, t_1))))
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(t_1))) + Float64(Float64(ew * sin(t)) / hypot(1.0, t_1)))) end
function tmp = code(eh, ew, t) t_1 = (eh / ew) / tan(t); tmp = abs((((eh * cos(t)) * sin(atan(t_1))) + ((ew * sin(t)) / hypot(1.0, t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t\_1 + \frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, t\_1\right)}\right|
\end{array}
\end{array}
Initial program 99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (/ ew (/ (hypot 1.0 (/ eh (* ew (tan t)))) (sin t))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (ew / (hypot(1.0, (eh / (ew * tan(t)))) / sin(t)))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + (ew / (Math.hypot(1.0, (eh / (ew * Math.tan(t)))) / Math.sin(t)))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + (ew / (math.hypot(1.0, (eh / (ew * math.tan(t)))) / math.sin(t)))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(ew / Float64(hypot(1.0, Float64(eh / Float64(ew * tan(t)))) / sin(t))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (ew / (hypot(1.0, (eh / (ew * tan(t)))) / sin(t))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $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|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan 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%
add-sqr-sqrt60.7%
pow260.7%
associate-*l*60.7%
cos-atan77.4%
un-div-inv77.4%
hypot-1-def74.7%
Applied egg-rr74.7%
unpow274.7%
add-sqr-sqrt99.8%
clear-num99.7%
un-div-inv99.7%
associate-/l/99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (* (* ew (sin t)) (cos (atan (/ eh (* ew t))))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(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((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + ((ew * Math.sin(t)) * Math.cos(Math.atan((eh / (ew * t)))))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + ((ew * math.sin(t)) * math.cos(math.atan((eh / (ew * t)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(eh / Float64(ew * t))))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 99.3%
Final simplification99.3%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* ew (sin t)) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs(((ew * sin(t)) + ((eh * cos(t)) * sin(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(((ew * sin(t)) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * Math.sin(t)) + ((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.sin(t)) + ((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * sin(t)) + Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * sin(t)) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \sin t + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Initial program 99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 98.9%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -7e-84) (not (<= ew 1.8e-93))) (fabs (+ (* ew (sin t)) (* eh (sin (atan (/ (/ eh ew) (tan t))))))) (fabs (* (* eh (cos t)) (sin (atan (/ (/ eh (tan t)) ew)))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -7e-84) || !(ew <= 1.8e-93)) {
tmp = fabs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(t)))))));
} else {
tmp = fabs(((eh * cos(t)) * sin(atan(((eh / tan(t)) / ew)))));
}
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 ((ew <= (-7d-84)) .or. (.not. (ew <= 1.8d-93))) then
tmp = abs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(t)))))))
else
tmp = abs(((eh * cos(t)) * sin(atan(((eh / tan(t)) / ew)))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -7e-84) || !(ew <= 1.8e-93)) {
tmp = Math.abs(((ew * Math.sin(t)) + (eh * Math.sin(Math.atan(((eh / ew) / Math.tan(t)))))));
} else {
tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / Math.tan(t)) / ew)))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -7e-84) or not (ew <= 1.8e-93): tmp = math.fabs(((ew * math.sin(t)) + (eh * math.sin(math.atan(((eh / ew) / math.tan(t))))))) else: tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan(((eh / math.tan(t)) / ew))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -7e-84) || !(ew <= 1.8e-93)) tmp = abs(Float64(Float64(ew * sin(t)) + Float64(eh * sin(atan(Float64(Float64(eh / ew) / tan(t))))))); else tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / tan(t)) / ew))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -7e-84) || ~((ew <= 1.8e-93))) tmp = abs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(t))))))); else tmp = abs(((eh * cos(t)) * sin(atan(((eh / tan(t)) / ew))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -7e-84], N[Not[LessEqual[ew, 1.8e-93]], $MachinePrecision]], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -7 \cdot 10^{-84} \lor \neg \left(ew \leq 1.8 \cdot 10^{-93}\right):\\
\;\;\;\;\left|ew \cdot \sin t + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{\tan t}}{ew}\right)\right|\\
\end{array}
\end{array}
if ew < -7.0000000000000002e-84 or 1.8000000000000001e-93 < ew Initial program 99.8%
add-sqr-sqrt56.0%
pow256.0%
associate-*l*56.0%
cos-atan69.3%
un-div-inv69.3%
hypot-1-def64.9%
Applied egg-rr64.9%
Taylor expanded in ew around inf 55.8%
unpow255.8%
add-sqr-sqrt99.1%
*-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in t around 0 92.4%
if -7.0000000000000002e-84 < ew < 1.8000000000000001e-93Initial program 99.8%
add-sqr-sqrt68.2%
pow268.2%
associate-*l*68.2%
cos-atan90.6%
un-div-inv90.6%
hypot-1-def90.6%
Applied egg-rr90.6%
Taylor expanded in ew around 0 93.7%
associate-*r*93.7%
*-commutative93.7%
associate-/r*93.7%
Simplified93.7%
Final simplification92.9%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -0.37) (not (<= t 0.0032))) (fabs (* (* eh (cos t)) (sin (atan (/ (/ eh (tan t)) ew))))) (fabs (+ (* ew t) (* eh (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.37) || !(t <= 0.0032)) {
tmp = fabs(((eh * cos(t)) * sin(atan(((eh / tan(t)) / ew)))));
} else {
tmp = fabs(((ew * t) + (eh * sin(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 <= (-0.37d0)) .or. (.not. (t <= 0.0032d0))) then
tmp = abs(((eh * cos(t)) * sin(atan(((eh / tan(t)) / ew)))))
else
tmp = abs(((ew * t) + (eh * sin(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 <= -0.37) || !(t <= 0.0032)) {
tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / Math.tan(t)) / ew)))));
} else {
tmp = Math.abs(((ew * t) + (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -0.37) or not (t <= 0.0032): tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan(((eh / math.tan(t)) / ew))))) else: tmp = math.fabs(((ew * t) + (eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -0.37) || !(t <= 0.0032)) tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / tan(t)) / ew))))); else tmp = abs(Float64(Float64(ew * t) + Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -0.37) || ~((t <= 0.0032))) tmp = abs(((eh * cos(t)) * sin(atan(((eh / tan(t)) / ew))))); else tmp = abs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -0.37], N[Not[LessEqual[t, 0.0032]], $MachinePrecision]], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * t), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.37 \lor \neg \left(t \leq 0.0032\right):\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{\tan t}}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot t + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\end{array}
\end{array}
if t < -0.37 or 0.00320000000000000015 < t Initial program 99.6%
add-sqr-sqrt57.2%
pow257.2%
associate-*l*57.2%
cos-atan77.5%
un-div-inv77.5%
hypot-1-def73.3%
Applied egg-rr73.3%
Taylor expanded in ew around 0 58.1%
associate-*r*58.1%
*-commutative58.1%
associate-/r*58.1%
Simplified58.1%
if -0.37 < t < 0.00320000000000000015Initial program 100.0%
add-sqr-sqrt63.6%
pow263.6%
associate-*l*63.6%
cos-atan77.3%
un-div-inv77.3%
hypot-1-def75.9%
Applied egg-rr75.9%
Taylor expanded in ew around inf 63.6%
Taylor expanded in t around 0 97.9%
Final simplification79.6%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -1.65e-171) (not (<= eh 3.8e-178))) (fabs (* eh (sin (atan (/ eh (* ew (tan t))))))) (fabs (cbrt (pow (* ew (sin t)) 3.0)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -1.65e-171) || !(eh <= 3.8e-178)) {
tmp = fabs((eh * sin(atan((eh / (ew * tan(t)))))));
} else {
tmp = fabs(cbrt(pow((ew * sin(t)), 3.0)));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -1.65e-171) || !(eh <= 3.8e-178)) {
tmp = Math.abs((eh * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))));
} else {
tmp = Math.abs(Math.cbrt(Math.pow((ew * Math.sin(t)), 3.0)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((eh <= -1.65e-171) || !(eh <= 3.8e-178)) tmp = abs(Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t))))))); else tmp = abs(cbrt((Float64(ew * sin(t)) ^ 3.0))); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -1.65e-171], N[Not[LessEqual[eh, 3.8e-178]], $MachinePrecision]], N[Abs[N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[Power[N[Power[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1.65 \cdot 10^{-171} \lor \neg \left(eh \leq 3.8 \cdot 10^{-178}\right):\\
\;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt[3]{{\left(ew \cdot \sin t\right)}^{3}}\right|\\
\end{array}
\end{array}
if eh < -1.6500000000000001e-171 or 3.80000000000000015e-178 < eh Initial program 99.8%
add-sqr-sqrt60.8%
pow260.8%
associate-*l*60.8%
cos-atan81.4%
un-div-inv81.4%
hypot-1-def78.1%
Applied egg-rr78.1%
Taylor expanded in t around 0 48.3%
if -1.6500000000000001e-171 < eh < 3.80000000000000015e-178Initial program 99.7%
add-sqr-sqrt60.0%
pow260.0%
associate-*l*60.0%
cos-atan60.0%
un-div-inv60.0%
hypot-1-def60.0%
Applied egg-rr60.0%
Taylor expanded in ew around inf 60.0%
add-cbrt-cube30.1%
pow330.1%
+-commutative30.1%
fma-define30.1%
unpow230.1%
add-sqr-sqrt50.2%
Applied egg-rr50.2%
Taylor expanded in eh around 0 32.3%
cube-prod50.2%
Simplified50.2%
Final simplification48.6%
(FPCore (eh ew t) :precision binary64 (if (<= t 1.05e-6) (fabs (+ (* ew t) (* eh (sin (atan (/ eh (* ew (tan t)))))))) (fabs (cbrt (pow (* ew (sin t)) 3.0)))))
double code(double eh, double ew, double t) {
double tmp;
if (t <= 1.05e-6) {
tmp = fabs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t))))))));
} else {
tmp = fabs(cbrt(pow((ew * sin(t)), 3.0)));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double tmp;
if (t <= 1.05e-6) {
tmp = Math.abs(((ew * t) + (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
} else {
tmp = Math.abs(Math.cbrt(Math.pow((ew * Math.sin(t)), 3.0)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (t <= 1.05e-6) tmp = abs(Float64(Float64(ew * t) + Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); else tmp = abs(cbrt((Float64(ew * sin(t)) ^ 3.0))); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[t, 1.05e-6], N[Abs[N[(N[(ew * t), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[Power[N[Power[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.05 \cdot 10^{-6}:\\
\;\;\;\;\left|ew \cdot t + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt[3]{{\left(ew \cdot \sin t\right)}^{3}}\right|\\
\end{array}
\end{array}
if t < 1.0499999999999999e-6Initial program 99.9%
add-sqr-sqrt59.9%
pow259.9%
associate-*l*59.9%
cos-atan78.0%
un-div-inv78.0%
hypot-1-def75.4%
Applied egg-rr75.4%
Taylor expanded in ew around inf 59.4%
Taylor expanded in t around 0 72.7%
if 1.0499999999999999e-6 < t Initial program 99.5%
add-sqr-sqrt63.1%
pow263.1%
associate-*l*63.1%
cos-atan75.7%
un-div-inv75.7%
hypot-1-def72.6%
Applied egg-rr72.6%
Taylor expanded in ew around inf 63.1%
add-cbrt-cube30.0%
pow330.0%
+-commutative30.0%
fma-define30.0%
unpow230.0%
add-sqr-sqrt41.3%
Applied egg-rr41.3%
Taylor expanded in eh around 0 25.2%
cube-prod25.2%
Simplified25.2%
Final simplification61.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -9.4e-20) (not (<= eh 7.4e-178))) (fabs (* eh (sin (atan (/ (/ eh t) ew))))) (fabs (cbrt (pow (* ew (sin t)) 3.0)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -9.4e-20) || !(eh <= 7.4e-178)) {
tmp = fabs((eh * sin(atan(((eh / t) / ew)))));
} else {
tmp = fabs(cbrt(pow((ew * sin(t)), 3.0)));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -9.4e-20) || !(eh <= 7.4e-178)) {
tmp = Math.abs((eh * Math.sin(Math.atan(((eh / t) / ew)))));
} else {
tmp = Math.abs(Math.cbrt(Math.pow((ew * Math.sin(t)), 3.0)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((eh <= -9.4e-20) || !(eh <= 7.4e-178)) tmp = abs(Float64(eh * sin(atan(Float64(Float64(eh / t) / ew))))); else tmp = abs(cbrt((Float64(ew * sin(t)) ^ 3.0))); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -9.4e-20], N[Not[LessEqual[eh, 7.4e-178]], $MachinePrecision]], N[Abs[N[(eh * N[Sin[N[ArcTan[N[(N[(eh / t), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[Power[N[Power[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -9.4 \cdot 10^{-20} \lor \neg \left(eh \leq 7.4 \cdot 10^{-178}\right):\\
\;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sqrt[3]{{\left(ew \cdot \sin t\right)}^{3}}\right|\\
\end{array}
\end{array}
if eh < -9.4000000000000003e-20 or 7.40000000000000008e-178 < eh Initial program 99.8%
add-sqr-sqrt59.6%
pow259.6%
associate-*l*59.6%
cos-atan84.0%
un-div-inv84.0%
hypot-1-def80.0%
Applied egg-rr80.0%
Taylor expanded in t around 0 51.1%
*-commutative51.1%
associate-/r*51.1%
Simplified51.1%
Taylor expanded in t around 0 50.1%
if -9.4000000000000003e-20 < eh < 7.40000000000000008e-178Initial program 99.7%
add-sqr-sqrt62.7%
pow262.7%
associate-*l*62.7%
cos-atan63.9%
un-div-inv63.9%
hypot-1-def63.9%
Applied egg-rr63.9%
Taylor expanded in ew around inf 62.0%
add-cbrt-cube33.4%
pow333.4%
+-commutative33.4%
fma-define33.4%
unpow233.4%
add-sqr-sqrt53.4%
Applied egg-rr53.4%
Taylor expanded in eh around 0 29.2%
cube-prod42.9%
Simplified42.9%
Final simplification47.8%
(FPCore (eh ew t) :precision binary64 (fabs (* eh (sin (atan (/ (/ eh t) ew))))))
double code(double eh, double ew, double t) {
return fabs((eh * sin(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((eh * sin(atan(((eh / t) / ew)))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((eh * Math.sin(Math.atan(((eh / t) / ew)))));
}
def code(eh, ew, t): return math.fabs((eh * math.sin(math.atan(((eh / t) / ew)))))
function code(eh, ew, t) return abs(Float64(eh * sin(atan(Float64(Float64(eh / t) / ew))))) end
function tmp = code(eh, ew, t) tmp = abs((eh * sin(atan(((eh / t) / ew))))); end
code[eh_, ew_, t_] := N[Abs[N[(eh * N[Sin[N[ArcTan[N[(N[(eh / t), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right|
\end{array}
Initial program 99.8%
add-sqr-sqrt60.7%
pow260.7%
associate-*l*60.7%
cos-atan77.4%
un-div-inv77.4%
hypot-1-def74.7%
Applied egg-rr74.7%
Taylor expanded in t around 0 42.2%
*-commutative42.2%
associate-/r*42.2%
Simplified42.2%
Taylor expanded in t around 0 41.0%
(FPCore (eh ew t) :precision binary64 (fabs (* eh (sin (atan (/ eh (* ew t)))))))
double code(double eh, double ew, double t) {
return fabs((eh * 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((eh * sin(atan((eh / (ew * t))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((eh * Math.sin(Math.atan((eh / (ew * t))))));
}
def code(eh, ew, t): return math.fabs((eh * math.sin(math.atan((eh / (ew * t))))))
function code(eh, ew, t) return abs(Float64(eh * sin(atan(Float64(eh / Float64(ew * t)))))) end
function tmp = code(eh, ew, t) tmp = abs((eh * sin(atan((eh / (ew * t)))))); end
code[eh_, ew_, t_] := N[Abs[N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|
\end{array}
Initial program 99.8%
add-sqr-sqrt60.7%
pow260.7%
associate-*l*60.7%
cos-atan77.4%
un-div-inv77.4%
hypot-1-def74.7%
Applied egg-rr74.7%
Taylor expanded in t around 0 42.2%
*-commutative42.2%
associate-/r*42.2%
Simplified42.2%
Taylor expanded in t around 0 40.9%
herbie shell --seed 2024141
(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))))))))