
(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 13 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 (fma 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(fma(ew, (sin(t) * cos(t_1)), (eh * (cos(t) * sin(t_1)))));
}
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(fma(ew, Float64(sin(t) * cos(t_1)), Float64(eh * Float64(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[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\mathsf{fma}\left(ew, \sin t \cdot \cos t_1, eh \cdot \left(\cos t \cdot \sin t_1\right)\right)\right|
\end{array}
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (/ (sin t) (hypot 1.0 (/ eh (* ew (tan t))))) (* eh (* (cos t) (sin (atan (/ (/ eh ew) (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, (sin(t) / hypot(1.0, (eh / (ew * tan(t))))), (eh * (cos(t) * sin(atan(((eh / ew) / tan(t))))))));
}
function code(eh, ew, t) return abs(fma(ew, Float64(sin(t) / hypot(1.0, Float64(eh / Float64(ew * tan(t))))), Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Cos[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|\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef88.2%
cos-atan88.2%
un-div-inv88.2%
hypot-1-def88.2%
associate-/l/88.2%
*-commutative88.2%
Applied egg-rr88.2%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* ew (sin t)) (/ 1.0 (hypot 1.0 (/ eh (* ew (tan t)))))) (* (sin (atan (/ (/ eh ew) (tan t)))) (* eh (cos t))))))
double code(double eh, double ew, double t) {
return fabs((((ew * sin(t)) * (1.0 / hypot(1.0, (eh / (ew * tan(t)))))) + (sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t)))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.sin(t)) * (1.0 / Math.hypot(1.0, (eh / (ew * Math.tan(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)) * (1.0 / math.hypot(1.0, (eh / (ew * math.tan(t)))))) + (math.sin(math.atan(((eh / ew) / math.tan(t)))) * (eh * math.cos(t)))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * sin(t)) * Float64(1.0 / hypot(1.0, Float64(eh / Float64(ew * tan(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)) * (1.0 / hypot(1.0, (eh / (ew * tan(t)))))) + (sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t))))); end
code[eh_, ew_, t_] := N[Abs[N[(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]), $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|\left(ew \cdot \sin t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)} + \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right)\right|
\end{array}
Initial program 99.7%
cos-atan99.7%
hypot-1-def99.7%
associate-/l/99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (/ (sin t) (hypot 1.0 (/ eh (* ew t)))) (* eh (* (cos t) (sin (atan (/ (/ eh ew) (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, (sin(t) / hypot(1.0, (eh / (ew * t)))), (eh * (cos(t) * sin(atan(((eh / ew) / tan(t))))))));
}
function code(eh, ew, t) return abs(fma(ew, Float64(sin(t) / hypot(1.0, Float64(eh / Float64(ew * t)))), Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Cos[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|\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot t}\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef88.2%
cos-atan88.2%
un-div-inv88.2%
hypot-1-def88.2%
associate-/l/88.2%
*-commutative88.2%
Applied egg-rr88.2%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in t around 0 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (sin t) (* eh (* (cos t) (sin (atan (/ (/ eh ew) (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, sin(t), (eh * (cos(t) * sin(atan(((eh / ew) / tan(t))))))));
}
function code(eh, ew, t) return abs(fma(ew, sin(t), Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Sin[t], $MachinePrecision] + N[(eh * N[(N[Cos[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|\mathsf{fma}\left(ew, \sin t, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef88.2%
cos-atan88.2%
un-div-inv88.2%
hypot-1-def88.2%
associate-/l/88.2%
*-commutative88.2%
Applied egg-rr88.2%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in eh around 0 97.8%
Final simplification97.8%
(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.7%
cos-atan99.7%
hypot-1-def99.7%
associate-/l/99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in eh around 0 97.8%
Final simplification97.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (cos t))))
(if (or (<= ew -1.16e-207) (not (<= ew 2.3e-144)))
(fabs (+ (* ew (sin t)) (* t_1 (sin (atan (/ eh (* ew t)))))))
(fabs (* (sin (atan (/ (/ eh ew) (tan t)))) t_1)))))
double code(double eh, double ew, double t) {
double t_1 = eh * cos(t);
double tmp;
if ((ew <= -1.16e-207) || !(ew <= 2.3e-144)) {
tmp = fabs(((ew * sin(t)) + (t_1 * sin(atan((eh / (ew * t)))))));
} else {
tmp = fabs((sin(atan(((eh / ew) / tan(t)))) * t_1));
}
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) :: t_1
real(8) :: tmp
t_1 = eh * cos(t)
if ((ew <= (-1.16d-207)) .or. (.not. (ew <= 2.3d-144))) then
tmp = abs(((ew * sin(t)) + (t_1 * sin(atan((eh / (ew * t)))))))
else
tmp = abs((sin(atan(((eh / ew) / tan(t)))) * t_1))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = eh * Math.cos(t);
double tmp;
if ((ew <= -1.16e-207) || !(ew <= 2.3e-144)) {
tmp = Math.abs(((ew * Math.sin(t)) + (t_1 * Math.sin(Math.atan((eh / (ew * t)))))));
} else {
tmp = Math.abs((Math.sin(Math.atan(((eh / ew) / Math.tan(t)))) * t_1));
}
return tmp;
}
def code(eh, ew, t): t_1 = eh * math.cos(t) tmp = 0 if (ew <= -1.16e-207) or not (ew <= 2.3e-144): tmp = math.fabs(((ew * math.sin(t)) + (t_1 * math.sin(math.atan((eh / (ew * t))))))) else: tmp = math.fabs((math.sin(math.atan(((eh / ew) / math.tan(t)))) * t_1)) return tmp
function code(eh, ew, t) t_1 = Float64(eh * cos(t)) tmp = 0.0 if ((ew <= -1.16e-207) || !(ew <= 2.3e-144)) tmp = abs(Float64(Float64(ew * sin(t)) + Float64(t_1 * sin(atan(Float64(eh / Float64(ew * t))))))); else tmp = abs(Float64(sin(atan(Float64(Float64(eh / ew) / tan(t)))) * t_1)); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh * cos(t); tmp = 0.0; if ((ew <= -1.16e-207) || ~((ew <= 2.3e-144))) tmp = abs(((ew * sin(t)) + (t_1 * sin(atan((eh / (ew * t))))))); else tmp = abs((sin(atan(((eh / ew) / tan(t)))) * t_1)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[ew, -1.16e-207], N[Not[LessEqual[ew, 2.3e-144]], $MachinePrecision]], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \cos t\\
\mathbf{if}\;ew \leq -1.16 \cdot 10^{-207} \lor \neg \left(ew \leq 2.3 \cdot 10^{-144}\right):\\
\;\;\;\;\left|ew \cdot \sin t + t_1 \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot t_1\right|\\
\end{array}
\end{array}
if ew < -1.16e-207 or 2.3e-144 < ew Initial program 99.8%
cos-atan99.8%
hypot-1-def99.8%
associate-/l/99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in eh around 0 97.5%
Taylor expanded in t around 0 88.9%
if -1.16e-207 < ew < 2.3e-144Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef99.7%
cos-atan99.7%
un-div-inv99.7%
hypot-1-def99.7%
associate-/l/99.7%
*-commutative99.7%
Applied egg-rr99.7%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in t around 0 69.8%
associate-/l*68.3%
unpow268.3%
Simplified68.3%
Taylor expanded in ew around 0 98.1%
associate-*r*98.1%
associate-/r*98.1%
Simplified98.1%
Final simplification91.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (sin (atan (/ (/ eh ew) (tan t))))))
(if (or (<= ew -4.2e-144) (not (<= ew 2.7e-146)))
(fabs (+ (* ew (sin t)) (* eh t_1)))
(fabs (* t_1 (* eh (cos t)))))))
double code(double eh, double ew, double t) {
double t_1 = sin(atan(((eh / ew) / tan(t))));
double tmp;
if ((ew <= -4.2e-144) || !(ew <= 2.7e-146)) {
tmp = fabs(((ew * sin(t)) + (eh * t_1)));
} else {
tmp = fabs((t_1 * (eh * cos(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) :: t_1
real(8) :: tmp
t_1 = sin(atan(((eh / ew) / tan(t))))
if ((ew <= (-4.2d-144)) .or. (.not. (ew <= 2.7d-146))) then
tmp = abs(((ew * sin(t)) + (eh * t_1)))
else
tmp = abs((t_1 * (eh * cos(t))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.sin(Math.atan(((eh / ew) / Math.tan(t))));
double tmp;
if ((ew <= -4.2e-144) || !(ew <= 2.7e-146)) {
tmp = Math.abs(((ew * Math.sin(t)) + (eh * t_1)));
} else {
tmp = Math.abs((t_1 * (eh * Math.cos(t))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.sin(math.atan(((eh / ew) / math.tan(t)))) tmp = 0 if (ew <= -4.2e-144) or not (ew <= 2.7e-146): tmp = math.fabs(((ew * math.sin(t)) + (eh * t_1))) else: tmp = math.fabs((t_1 * (eh * math.cos(t)))) return tmp
function code(eh, ew, t) t_1 = sin(atan(Float64(Float64(eh / ew) / tan(t)))) tmp = 0.0 if ((ew <= -4.2e-144) || !(ew <= 2.7e-146)) tmp = abs(Float64(Float64(ew * sin(t)) + Float64(eh * t_1))); else tmp = abs(Float64(t_1 * Float64(eh * cos(t)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = sin(atan(((eh / ew) / tan(t)))); tmp = 0.0; if ((ew <= -4.2e-144) || ~((ew <= 2.7e-146))) tmp = abs(((ew * sin(t)) + (eh * t_1))); else tmp = abs((t_1 * (eh * cos(t)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[ew, -4.2e-144], N[Not[LessEqual[ew, 2.7e-146]], $MachinePrecision]], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(eh * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$1 * N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\mathbf{if}\;ew \leq -4.2 \cdot 10^{-144} \lor \neg \left(ew \leq 2.7 \cdot 10^{-146}\right):\\
\;\;\;\;\left|ew \cdot \sin t + eh \cdot t_1\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t_1 \cdot \left(eh \cdot \cos t\right)\right|\\
\end{array}
\end{array}
if ew < -4.2000000000000002e-144 or 2.69999999999999995e-146 < ew Initial program 99.8%
Taylor expanded in t around 0 85.7%
add-sqr-sqrt50.3%
pow250.3%
Applied egg-rr56.8%
unpow256.8%
add-sqr-sqrt85.6%
clear-num85.5%
associate-/r*85.5%
Applied egg-rr85.5%
Taylor expanded in eh around 0 84.8%
if -4.2000000000000002e-144 < ew < 2.69999999999999995e-146Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.6%
expm1-udef99.6%
cos-atan99.6%
un-div-inv99.6%
hypot-1-def99.6%
associate-/l/99.6%
*-commutative99.6%
Applied egg-rr99.6%
expm1-def99.6%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in t around 0 70.3%
associate-/l*69.0%
unpow269.0%
Simplified69.0%
Taylor expanded in ew around 0 95.9%
associate-*r*95.9%
associate-/r*95.9%
Simplified95.9%
Final simplification88.2%
(FPCore (eh ew t) :precision binary64 (fabs (* (sin (atan (/ (/ eh ew) (tan t)))) (* eh (cos t)))))
double code(double eh, double ew, double t) {
return fabs((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((sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t))))
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))));
}
def code(eh, ew, t): return math.fabs((math.sin(math.atan(((eh / ew) / math.tan(t)))) * (eh * math.cos(t))))
function code(eh, ew, t) return abs(Float64(sin(atan(Float64(Float64(eh / ew) / tan(t)))) * Float64(eh * cos(t)))) end
function tmp = code(eh, ew, t) tmp = abs((sin(atan(((eh / ew) / tan(t)))) * (eh * cos(t)))); end
code[eh_, ew_, t_] := N[Abs[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]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right)\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef88.2%
cos-atan88.2%
un-div-inv88.2%
hypot-1-def88.2%
associate-/l/88.2%
*-commutative88.2%
Applied egg-rr88.2%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in t around 0 48.4%
associate-/l*48.0%
unpow248.0%
Simplified48.0%
Taylor expanded in ew around 0 63.6%
associate-*r*63.6%
associate-/r*63.6%
Simplified63.6%
Final simplification63.6%
(FPCore (eh ew t) :precision binary64 (fabs (* eh (sin (atan (/ eh (* ew (tan t))))))))
double code(double eh, double ew, double t) {
return fabs((eh * 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((eh * sin(atan((eh / (ew * tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((eh * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs((eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs((eh * sin(atan((eh / (ew * tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef88.2%
cos-atan88.2%
un-div-inv88.2%
hypot-1-def88.2%
associate-/l/88.2%
*-commutative88.2%
Applied egg-rr88.2%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in t around 0 48.4%
associate-/l*48.0%
unpow248.0%
Simplified48.0%
Taylor expanded in t around 0 41.2%
Final simplification41.2%
(FPCore (eh ew t) :precision binary64 (* (* ew ew) (/ (* t t) (fabs eh))))
double code(double eh, double ew, double t) {
return (ew * ew) * ((t * t) / 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 = (ew * ew) * ((t * t) / abs(eh))
end function
public static double code(double eh, double ew, double t) {
return (ew * ew) * ((t * t) / Math.abs(eh));
}
def code(eh, ew, t): return (ew * ew) * ((t * t) / math.fabs(eh))
function code(eh, ew, t) return Float64(Float64(ew * ew) * Float64(Float64(t * t) / abs(eh))) end
function tmp = code(eh, ew, t) tmp = (ew * ew) * ((t * t) / abs(eh)); end
code[eh_, ew_, t_] := N[(N[(ew * ew), $MachinePrecision] * N[(N[(t * t), $MachinePrecision] / N[Abs[eh], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(ew \cdot ew\right) \cdot \frac{t \cdot t}{\left|eh\right|}
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef88.2%
cos-atan88.2%
un-div-inv88.2%
hypot-1-def88.2%
associate-/l/88.2%
*-commutative88.2%
Applied egg-rr88.2%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in t around 0 48.4%
associate-/l*48.0%
unpow248.0%
Simplified48.0%
Taylor expanded in ew around inf 4.0%
associate-/l*3.9%
unpow23.9%
unpow23.9%
Simplified3.9%
div-inv3.9%
clear-num3.9%
Applied egg-rr3.9%
Final simplification3.9%
(FPCore (eh ew t) :precision binary64 (fabs (* (* t t) (/ ew (/ eh ew)))))
double code(double eh, double ew, double t) {
return fabs(((t * t) * (ew / (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(((t * t) * (ew / (eh / ew))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((t * t) * (ew / (eh / ew))));
}
def code(eh, ew, t): return math.fabs(((t * t) * (ew / (eh / ew))))
function code(eh, ew, t) return abs(Float64(Float64(t * t) * Float64(ew / Float64(eh / ew)))) end
function tmp = code(eh, ew, t) tmp = abs(((t * t) * (ew / (eh / ew)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(t * t), $MachinePrecision] * N[(ew / N[(eh / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(t \cdot t\right) \cdot \frac{ew}{\frac{eh}{ew}}\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef88.2%
cos-atan88.2%
un-div-inv88.2%
hypot-1-def88.2%
associate-/l/88.2%
*-commutative88.2%
Applied egg-rr88.2%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in t around 0 48.4%
associate-/l*48.0%
unpow248.0%
Simplified48.0%
Taylor expanded in ew around inf 4.0%
associate-/l*3.9%
unpow23.9%
unpow23.9%
Simplified3.9%
Taylor expanded in ew around 0 4.0%
*-commutative4.0%
associate-*r/3.9%
unpow23.9%
unpow23.9%
associate-/l*4.0%
Simplified4.0%
Final simplification4.0%
(FPCore (eh ew t) :precision binary64 (fabs (* t (* t (/ (* ew ew) eh)))))
double code(double eh, double ew, double t) {
return fabs((t * (t * ((ew * ew) / 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((t * (t * ((ew * ew) / eh))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((t * (t * ((ew * ew) / eh))));
}
def code(eh, ew, t): return math.fabs((t * (t * ((ew * ew) / eh))))
function code(eh, ew, t) return abs(Float64(t * Float64(t * Float64(Float64(ew * ew) / eh)))) end
function tmp = code(eh, ew, t) tmp = abs((t * (t * ((ew * ew) / eh)))); end
code[eh_, ew_, t_] := N[Abs[N[(t * N[(t * N[(N[(ew * ew), $MachinePrecision] / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|t \cdot \left(t \cdot \frac{ew \cdot ew}{eh}\right)\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-*l*99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef88.2%
cos-atan88.2%
un-div-inv88.2%
hypot-1-def88.2%
associate-/l/88.2%
*-commutative88.2%
Applied egg-rr88.2%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in t around 0 48.4%
associate-/l*48.0%
unpow248.0%
Simplified48.0%
Taylor expanded in ew around inf 4.0%
associate-/l*3.9%
unpow23.9%
unpow23.9%
Simplified3.9%
associate-/r/3.9%
associate-*r*4.5%
Applied egg-rr4.5%
Final simplification4.5%
herbie shell --seed 2023283
(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))))))))