
(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 (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(eh / Float64(ew * tan(t)))) return abs(fma(Float64(ew * 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[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $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{eh}{ew \cdot \tan t}\right)\\
\left|\mathsf{fma}\left(ew \cdot \sin t, \cos t_1, eh \cdot \left(\cos t \cdot \sin t_1\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
fma-def99.9%
associate-/l/99.9%
associate-*l*99.9%
associate-/l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* 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(((ew * (sin(t) / hypot(1.0, (eh / (ew * tan(t)))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * (Math.sin(t) / Math.hypot(1.0, (eh / (ew * Math.tan(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) / math.hypot(1.0, (eh / (ew * math.tan(t)))))) + ((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * Float64(sin(t) / hypot(1.0, Float64(eh / Float64(ew * tan(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) / hypot(1.0, (eh / (ew * tan(t)))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(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]), $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 \frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)} + \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%
expm1-log1p-u81.4%
expm1-udef68.7%
associate-/l/68.7%
cos-atan71.8%
un-div-inv71.8%
hypot-1-def71.8%
associate-/l/71.8%
Applied egg-rr71.8%
expm1-def84.5%
expm1-log1p99.8%
*-commutative99.8%
associate-*l/99.8%
*-commutative99.8%
associate-/l/99.8%
Simplified99.8%
Final simplification99.8%
(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.4%
Final simplification99.4%
(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%
expm1-log1p-u81.4%
expm1-udef68.7%
associate-/l/68.7%
cos-atan71.8%
un-div-inv71.8%
hypot-1-def71.8%
associate-/l/71.8%
Applied egg-rr71.8%
expm1-def84.5%
expm1-log1p99.8%
*-commutative99.8%
associate-*l/99.8%
*-commutative99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around inf 98.2%
Final simplification98.2%
(FPCore (eh ew t)
:precision binary64
(if (or (<= t -0.00092) (not (<= t 5.9e+19)))
(fabs
(+
(* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t)))))
(* t (/ (* ew ew) (/ eh t)))))
(fabs
(+
(* (* ew t) (/ 1.0 (hypot 1.0 (/ eh (* ew (tan t))))))
(* eh (sin (atan (/ eh (* ew t)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.00092) || !(t <= 5.9e+19)) {
tmp = fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (t * ((ew * ew) / (eh / t)))));
} else {
tmp = fabs((((ew * t) * (1.0 / hypot(1.0, (eh / (ew * tan(t)))))) + (eh * sin(atan((eh / (ew * t)))))));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.00092) || !(t <= 5.9e+19)) {
tmp = Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + (t * ((ew * ew) / (eh / t)))));
} else {
tmp = Math.abs((((ew * t) * (1.0 / Math.hypot(1.0, (eh / (ew * Math.tan(t)))))) + (eh * Math.sin(Math.atan((eh / (ew * t)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -0.00092) or not (t <= 5.9e+19): tmp = math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + (t * ((ew * ew) / (eh / t))))) else: tmp = math.fabs((((ew * t) * (1.0 / math.hypot(1.0, (eh / (ew * math.tan(t)))))) + (eh * math.sin(math.atan((eh / (ew * t))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -0.00092) || !(t <= 5.9e+19)) tmp = abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(t * Float64(Float64(ew * ew) / Float64(eh / t))))); else tmp = abs(Float64(Float64(Float64(ew * t) * Float64(1.0 / hypot(1.0, Float64(eh / Float64(ew * tan(t)))))) + Float64(eh * sin(atan(Float64(eh / Float64(ew * t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -0.00092) || ~((t <= 5.9e+19))) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (t * ((ew * ew) / (eh / t))))); else tmp = abs((((ew * t) * (1.0 / hypot(1.0, (eh / (ew * tan(t)))))) + (eh * sin(atan((eh / (ew * t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -0.00092], N[Not[LessEqual[t, 5.9e+19]], $MachinePrecision]], 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[(t * N[(N[(ew * ew), $MachinePrecision] / N[(eh / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(ew * t), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.00092 \lor \neg \left(t \leq 5.9 \cdot 10^{+19}\right):\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + t \cdot \frac{ew \cdot ew}{\frac{eh}{t}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(ew \cdot t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)} + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|\\
\end{array}
\end{array}
if t < -9.2000000000000003e-4 or 5.9e19 < t Initial program 99.7%
expm1-log1p-u76.1%
expm1-udef65.8%
associate-/l/65.8%
cos-atan69.8%
un-div-inv69.8%
hypot-1-def69.8%
associate-/l/69.8%
Applied egg-rr69.8%
expm1-def80.1%
expm1-log1p99.7%
*-commutative99.7%
associate-*l/99.7%
*-commutative99.7%
associate-/l/99.7%
Simplified99.7%
associate-*r/99.7%
associate-/l/99.7%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in t around 0 26.4%
unpow226.4%
associate-/r*26.0%
unpow226.0%
Simplified26.0%
clear-num26.0%
associate-/r*32.9%
associate-/r/42.8%
Applied egg-rr42.8%
if -9.2000000000000003e-4 < t < 5.9e19Initial program 100.0%
Taylor expanded in t around 0 98.9%
Taylor expanded in t around 0 97.8%
Taylor expanded in t around 0 97.8%
associate-/l/97.8%
cos-atan97.8%
hypot-1-def97.8%
associate-/l/97.8%
Applied egg-rr97.8%
associate-/l/97.8%
Simplified97.8%
Final simplification76.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ eh (* ew t)))))
(if (or (<= t -0.00035) (not (<= t 5.9e+19)))
(fabs
(+
(* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t)))))
(* t (/ (* ew ew) (/ eh t)))))
(fabs (+ (* eh (sin t_1)) (* (* ew t) (cos t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * t)));
double tmp;
if ((t <= -0.00035) || !(t <= 5.9e+19)) {
tmp = fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (t * ((ew * ew) / (eh / t)))));
} else {
tmp = fabs(((eh * sin(t_1)) + ((ew * t) * cos(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 = atan((eh / (ew * t)))
if ((t <= (-0.00035d0)) .or. (.not. (t <= 5.9d+19))) then
tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (t * ((ew * ew) / (eh / t)))))
else
tmp = abs(((eh * sin(t_1)) + ((ew * t) * cos(t_1))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((eh / (ew * t)));
double tmp;
if ((t <= -0.00035) || !(t <= 5.9e+19)) {
tmp = Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + (t * ((ew * ew) / (eh / t)))));
} else {
tmp = Math.abs(((eh * Math.sin(t_1)) + ((ew * t) * Math.cos(t_1))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan((eh / (ew * t))) tmp = 0 if (t <= -0.00035) or not (t <= 5.9e+19): tmp = math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + (t * ((ew * ew) / (eh / t))))) else: tmp = math.fabs(((eh * math.sin(t_1)) + ((ew * t) * math.cos(t_1)))) return tmp
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * t))) tmp = 0.0 if ((t <= -0.00035) || !(t <= 5.9e+19)) tmp = abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(t * Float64(Float64(ew * ew) / Float64(eh / t))))); else tmp = abs(Float64(Float64(eh * sin(t_1)) + Float64(Float64(ew * t) * cos(t_1)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan((eh / (ew * t))); tmp = 0.0; if ((t <= -0.00035) || ~((t <= 5.9e+19))) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (t * ((ew * ew) / (eh / t))))); else tmp = abs(((eh * sin(t_1)) + ((ew * t) * cos(t_1)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t, -0.00035], N[Not[LessEqual[t, 5.9e+19]], $MachinePrecision]], 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[(t * N[(N[(ew * ew), $MachinePrecision] / N[(eh / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * t), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\\
\mathbf{if}\;t \leq -0.00035 \lor \neg \left(t \leq 5.9 \cdot 10^{+19}\right):\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + t \cdot \frac{ew \cdot ew}{\frac{eh}{t}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \sin t_1 + \left(ew \cdot t\right) \cdot \cos t_1\right|\\
\end{array}
\end{array}
if t < -3.49999999999999996e-4 or 5.9e19 < t Initial program 99.7%
expm1-log1p-u76.1%
expm1-udef65.8%
associate-/l/65.8%
cos-atan69.8%
un-div-inv69.8%
hypot-1-def69.8%
associate-/l/69.8%
Applied egg-rr69.8%
expm1-def80.1%
expm1-log1p99.7%
*-commutative99.7%
associate-*l/99.7%
*-commutative99.7%
associate-/l/99.7%
Simplified99.7%
associate-*r/99.7%
associate-/l/99.7%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in t around 0 26.4%
unpow226.4%
associate-/r*26.0%
unpow226.0%
Simplified26.0%
clear-num26.0%
associate-/r*32.9%
associate-/r/42.8%
Applied egg-rr42.8%
if -3.49999999999999996e-4 < t < 5.9e19Initial program 100.0%
Taylor expanded in t around 0 98.9%
Taylor expanded in t around 0 97.8%
Taylor expanded in t around 0 97.8%
Taylor expanded in t around 0 97.8%
Final simplification76.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ eh (* ew t)))) (t_2 (sin t_1)))
(if (or (<= t -0.00055) (not (<= t 1600000000.0)))
(fabs (+ (* t (* (* ew t) (/ ew eh))) (* (* eh (cos t)) t_2)))
(fabs (+ (* eh t_2) (* (* ew t) (cos t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * t)));
double t_2 = sin(t_1);
double tmp;
if ((t <= -0.00055) || !(t <= 1600000000.0)) {
tmp = fabs(((t * ((ew * t) * (ew / eh))) + ((eh * cos(t)) * t_2)));
} else {
tmp = fabs(((eh * t_2) + ((ew * t) * cos(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) :: t_2
real(8) :: tmp
t_1 = atan((eh / (ew * t)))
t_2 = sin(t_1)
if ((t <= (-0.00055d0)) .or. (.not. (t <= 1600000000.0d0))) then
tmp = abs(((t * ((ew * t) * (ew / eh))) + ((eh * cos(t)) * t_2)))
else
tmp = abs(((eh * t_2) + ((ew * t) * cos(t_1))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((eh / (ew * t)));
double t_2 = Math.sin(t_1);
double tmp;
if ((t <= -0.00055) || !(t <= 1600000000.0)) {
tmp = Math.abs(((t * ((ew * t) * (ew / eh))) + ((eh * Math.cos(t)) * t_2)));
} else {
tmp = Math.abs(((eh * t_2) + ((ew * t) * Math.cos(t_1))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan((eh / (ew * t))) t_2 = math.sin(t_1) tmp = 0 if (t <= -0.00055) or not (t <= 1600000000.0): tmp = math.fabs(((t * ((ew * t) * (ew / eh))) + ((eh * math.cos(t)) * t_2))) else: tmp = math.fabs(((eh * t_2) + ((ew * t) * math.cos(t_1)))) return tmp
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * t))) t_2 = sin(t_1) tmp = 0.0 if ((t <= -0.00055) || !(t <= 1600000000.0)) tmp = abs(Float64(Float64(t * Float64(Float64(ew * t) * Float64(ew / eh))) + Float64(Float64(eh * cos(t)) * t_2))); else tmp = abs(Float64(Float64(eh * t_2) + Float64(Float64(ew * t) * cos(t_1)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan((eh / (ew * t))); t_2 = sin(t_1); tmp = 0.0; if ((t <= -0.00055) || ~((t <= 1600000000.0))) tmp = abs(((t * ((ew * t) * (ew / eh))) + ((eh * cos(t)) * t_2))); else tmp = abs(((eh * t_2) + ((ew * t) * cos(t_1)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[t$95$1], $MachinePrecision]}, If[Or[LessEqual[t, -0.00055], N[Not[LessEqual[t, 1600000000.0]], $MachinePrecision]], N[Abs[N[(N[(t * N[(N[(ew * t), $MachinePrecision] * N[(ew / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * t$95$2), $MachinePrecision] + N[(N[(ew * t), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\\
t_2 := \sin t_1\\
\mathbf{if}\;t \leq -0.00055 \lor \neg \left(t \leq 1600000000\right):\\
\;\;\;\;\left|t \cdot \left(\left(ew \cdot t\right) \cdot \frac{ew}{eh}\right) + \left(eh \cdot \cos t\right) \cdot t_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot t_2 + \left(ew \cdot t\right) \cdot \cos t_1\right|\\
\end{array}
\end{array}
if t < -5.50000000000000033e-4 or 1.6e9 < t Initial program 99.7%
expm1-log1p-u75.4%
expm1-udef65.2%
associate-/l/65.2%
cos-atan69.1%
un-div-inv69.1%
hypot-1-def69.1%
associate-/l/69.1%
Applied egg-rr69.1%
expm1-def79.3%
expm1-log1p99.7%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in t around 0 25.3%
*-commutative25.3%
unpow225.3%
Simplified25.3%
Taylor expanded in t around 0 25.3%
associate-/r/24.7%
associate-*r*31.7%
*-commutative31.7%
associate-*r*39.0%
*-commutative39.0%
Applied egg-rr39.0%
if -5.50000000000000033e-4 < t < 1.6e9Initial program 100.0%
Taylor expanded in t around 0 99.5%
Taylor expanded in t around 0 98.3%
Taylor expanded in t around 0 98.3%
Taylor expanded in t around 0 98.3%
Final simplification74.9%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ eh (* ew t))))) (/ ew (* (/ 1.0 t) (/ (/ eh ew) t))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan((eh / (ew * t))))) + (ew / ((1.0 / t) * ((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 * t))))) + (ew / ((1.0d0 / t) * ((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 * t))))) + (ew / ((1.0 / t) * ((eh / ew) / t)))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan((eh / (ew * t))))) + (ew / ((1.0 / t) * ((eh / ew) / t)))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * t))))) + Float64(ew / Float64(Float64(1.0 / t) * Float64(Float64(eh / ew) / t))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan((eh / (ew * t))))) + (ew / ((1.0 / t) * ((eh / ew) / t))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(ew / N[(N[(1.0 / t), $MachinePrecision] * N[(N[(eh / ew), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + \frac{ew}{\frac{1}{t} \cdot \frac{\frac{eh}{ew}}{t}}\right|
\end{array}
Initial program 99.8%
expm1-log1p-u81.4%
expm1-udef68.7%
associate-/l/68.7%
cos-atan71.8%
un-div-inv71.8%
hypot-1-def71.8%
associate-/l/71.8%
Applied egg-rr71.8%
expm1-def84.5%
expm1-log1p99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 48.3%
*-commutative48.3%
unpow248.3%
Simplified48.3%
Taylor expanded in t around 0 48.3%
associate-/r*49.0%
*-un-lft-identity49.0%
times-frac53.6%
Applied egg-rr53.6%
Final simplification53.6%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ eh (* ew t))))) (/ ew (* (/ eh t) (/ 1.0 (* ew t)))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan((eh / (ew * t))))) + (ew / ((eh / t) * (1.0 / (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 * t))))) + (ew / ((eh / t) * (1.0d0 / (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 * t))))) + (ew / ((eh / t) * (1.0 / (ew * t))))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan((eh / (ew * t))))) + (ew / ((eh / t) * (1.0 / (ew * t))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * t))))) + Float64(ew / Float64(Float64(eh / t) * Float64(1.0 / Float64(ew * t)))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan((eh / (ew * t))))) + (ew / ((eh / t) * (1.0 / (ew * t)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(ew / N[(N[(eh / t), $MachinePrecision] * N[(1.0 / N[(ew * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + \frac{ew}{\frac{eh}{t} \cdot \frac{1}{ew \cdot t}}\right|
\end{array}
Initial program 99.8%
expm1-log1p-u81.4%
expm1-udef68.7%
associate-/l/68.7%
cos-atan71.8%
un-div-inv71.8%
hypot-1-def71.8%
associate-/l/71.8%
Applied egg-rr71.8%
expm1-def84.5%
expm1-log1p99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 48.3%
*-commutative48.3%
unpow248.3%
Simplified48.3%
Taylor expanded in t around 0 48.3%
*-un-lft-identity48.3%
associate-*r*50.9%
*-commutative50.9%
times-frac53.7%
*-commutative53.7%
Applied egg-rr53.7%
Final simplification53.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ eh (* ew t))))) (* ew (/ (* ew (* t t)) eh)))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan((eh / (ew * t))))) + (ew * ((ew * (t * t)) / 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 * cos(t)) * sin(atan((eh / (ew * t))))) + (ew * ((ew * (t * t)) / eh))))
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 * t))))) + (ew * ((ew * (t * t)) / eh))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan((eh / (ew * t))))) + (ew * ((ew * (t * t)) / eh))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * t))))) + Float64(ew * Float64(Float64(ew * Float64(t * t)) / eh)))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan((eh / (ew * t))))) + (ew * ((ew * (t * t)) / eh)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(ew * N[(N[(ew * N[(t * t), $MachinePrecision]), $MachinePrecision] / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + ew \cdot \frac{ew \cdot \left(t \cdot t\right)}{eh}\right|
\end{array}
Initial program 99.8%
expm1-log1p-u81.4%
expm1-udef68.7%
associate-/l/68.7%
cos-atan71.8%
un-div-inv71.8%
hypot-1-def71.8%
associate-/l/71.8%
Applied egg-rr71.8%
expm1-def84.5%
expm1-log1p99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 48.3%
*-commutative48.3%
unpow248.3%
Simplified48.3%
Taylor expanded in t around 0 48.3%
div-inv48.3%
clear-num48.3%
Applied egg-rr48.3%
Final simplification48.3%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* t (* (* ew t) (/ ew eh))) (* (* eh (cos t)) (sin (atan (/ eh (* ew t))))))))
double code(double eh, double ew, double t) {
return fabs(((t * ((ew * t) * (ew / eh))) + ((eh * cos(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(((t * ((ew * t) * (ew / eh))) + ((eh * cos(t)) * sin(atan((eh / (ew * t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((t * ((ew * t) * (ew / eh))) + ((eh * Math.cos(t)) * Math.sin(Math.atan((eh / (ew * t)))))));
}
def code(eh, ew, t): return math.fabs(((t * ((ew * t) * (ew / eh))) + ((eh * math.cos(t)) * math.sin(math.atan((eh / (ew * t)))))))
function code(eh, ew, t) return abs(Float64(Float64(t * Float64(Float64(ew * t) * Float64(ew / eh))) + Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * t))))))) end
function tmp = code(eh, ew, t) tmp = abs(((t * ((ew * t) * (ew / eh))) + ((eh * cos(t)) * sin(atan((eh / (ew * t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(t * N[(N[(ew * t), $MachinePrecision] * N[(ew / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|t \cdot \left(\left(ew \cdot t\right) \cdot \frac{ew}{eh}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|
\end{array}
Initial program 99.8%
expm1-log1p-u81.4%
expm1-udef68.7%
associate-/l/68.7%
cos-atan71.8%
un-div-inv71.8%
hypot-1-def71.8%
associate-/l/71.8%
Applied egg-rr71.8%
expm1-def84.5%
expm1-log1p99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 48.3%
*-commutative48.3%
unpow248.3%
Simplified48.3%
Taylor expanded in t around 0 48.3%
associate-/r/47.9%
associate-*r*50.8%
*-commutative50.8%
associate-*r*53.6%
*-commutative53.6%
Applied egg-rr53.6%
Final simplification53.6%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh (sin (atan (/ eh (* ew t))))) (/ ew (/ eh (* ew (* t t)))))))
double code(double eh, double ew, double t) {
return fabs(((eh * sin(atan((eh / (ew * t))))) + (ew / (eh / (ew * (t * 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))))) + (ew / (eh / (ew * (t * t))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * Math.sin(Math.atan((eh / (ew * t))))) + (ew / (eh / (ew * (t * t))))));
}
def code(eh, ew, t): return math.fabs(((eh * math.sin(math.atan((eh / (ew * t))))) + (ew / (eh / (ew * (t * t))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * sin(atan(Float64(eh / Float64(ew * t))))) + Float64(ew / Float64(eh / Float64(ew * Float64(t * t)))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * sin(atan((eh / (ew * t))))) + (ew / (eh / (ew * (t * t)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(ew / N[(eh / N[(ew * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + \frac{ew}{\frac{eh}{ew \cdot \left(t \cdot t\right)}}\right|
\end{array}
Initial program 99.8%
expm1-log1p-u81.4%
expm1-udef68.7%
associate-/l/68.7%
cos-atan71.8%
un-div-inv71.8%
hypot-1-def71.8%
associate-/l/71.8%
Applied egg-rr71.8%
expm1-def84.5%
expm1-log1p99.8%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 48.3%
*-commutative48.3%
unpow248.3%
Simplified48.3%
Taylor expanded in t around 0 48.3%
Taylor expanded in t around 0 41.9%
Final simplification41.9%
herbie shell --seed 2023238
(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))))))))