
(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 10 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 (+ (* eh (* (cos t) (sin t_1))) (* ew (* (cos t_1) (sin t)))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * tan(t))));
return fabs(((eh * (cos(t) * sin(t_1))) + (ew * (cos(t_1) * sin(t)))));
}
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(((eh * (cos(t) * sin(t_1))) + (ew * (cos(t_1) * sin(t)))))
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(((eh * (Math.cos(t) * Math.sin(t_1))) + (ew * (Math.cos(t_1) * Math.sin(t)))));
}
def code(eh, ew, t): t_1 = math.atan((eh / (ew * math.tan(t)))) return math.fabs(((eh * (math.cos(t) * math.sin(t_1))) + (ew * (math.cos(t_1) * math.sin(t)))))
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * tan(t)))) return abs(Float64(Float64(eh * Float64(cos(t) * sin(t_1))) + Float64(ew * Float64(cos(t_1) * sin(t))))) end
function tmp = code(eh, ew, t) t_1 = atan((eh / (ew * tan(t)))); tmp = abs(((eh * (cos(t) * sin(t_1))) + (ew * (cos(t_1) * sin(t))))); 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[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(ew * N[(N[Cos[t$95$1], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\left|eh \cdot \left(\cos t \cdot \sin t\_1\right) + ew \cdot \left(\cos t\_1 \cdot \sin t\right)\right|
\end{array}
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (sin t)))
(t_2 (atan (/ (/ eh ew) (tan t))))
(t_3 (sin t_2)))
(if (<= (+ (* (* eh (cos t)) t_3) (* t_1 (cos t_2))) -1e-295)
(fabs (* (cos t) (* eh (sin (atan (/ eh (* ew (tan t))))))))
(+ t_1 (* (cos t) (* eh t_3))))))
double code(double eh, double ew, double t) {
double t_1 = ew * sin(t);
double t_2 = atan(((eh / ew) / tan(t)));
double t_3 = sin(t_2);
double tmp;
if ((((eh * cos(t)) * t_3) + (t_1 * cos(t_2))) <= -1e-295) {
tmp = fabs((cos(t) * (eh * sin(atan((eh / (ew * tan(t))))))));
} else {
tmp = t_1 + (cos(t) * (eh * t_3));
}
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) :: t_3
real(8) :: tmp
t_1 = ew * sin(t)
t_2 = atan(((eh / ew) / tan(t)))
t_3 = sin(t_2)
if ((((eh * cos(t)) * t_3) + (t_1 * cos(t_2))) <= (-1d-295)) then
tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(t))))))))
else
tmp = t_1 + (cos(t) * (eh * t_3))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.sin(t);
double t_2 = Math.atan(((eh / ew) / Math.tan(t)));
double t_3 = Math.sin(t_2);
double tmp;
if ((((eh * Math.cos(t)) * t_3) + (t_1 * Math.cos(t_2))) <= -1e-295) {
tmp = Math.abs((Math.cos(t) * (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
} else {
tmp = t_1 + (Math.cos(t) * (eh * t_3));
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.sin(t) t_2 = math.atan(((eh / ew) / math.tan(t))) t_3 = math.sin(t_2) tmp = 0 if (((eh * math.cos(t)) * t_3) + (t_1 * math.cos(t_2))) <= -1e-295: tmp = math.fabs((math.cos(t) * (eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))) else: tmp = t_1 + (math.cos(t) * (eh * t_3)) return tmp
function code(eh, ew, t) t_1 = Float64(ew * sin(t)) t_2 = atan(Float64(Float64(eh / ew) / tan(t))) t_3 = sin(t_2) tmp = 0.0 if (Float64(Float64(Float64(eh * cos(t)) * t_3) + Float64(t_1 * cos(t_2))) <= -1e-295) tmp = abs(Float64(cos(t) * Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); else tmp = Float64(t_1 + Float64(cos(t) * Float64(eh * t_3))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * sin(t); t_2 = atan(((eh / ew) / tan(t))); t_3 = sin(t_2); tmp = 0.0; if ((((eh * cos(t)) * t_3) + (t_1 * cos(t_2))) <= -1e-295) tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(t)))))))); else tmp = t_1 + (cos(t) * (eh * t_3)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[t$95$2], $MachinePrecision]}, If[LessEqual[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision] + N[(t$95$1 * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-295], N[Abs[N[(N[Cos[t], $MachinePrecision] * N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(t$95$1 + N[(N[Cos[t], $MachinePrecision] * N[(eh * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \sin t\\
t_2 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
t_3 := \sin t\_2\\
\mathbf{if}\;\left(eh \cdot \cos t\right) \cdot t\_3 + t\_1 \cdot \cos t\_2 \leq -1 \cdot 10^{-295}:\\
\;\;\;\;\left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \cos t \cdot \left(eh \cdot t\_3\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 (*.f64 ew (sin.f64 t)) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) < -1.00000000000000006e-295Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 66.6%
*-commutative66.6%
associate-*r*66.6%
*-commutative66.6%
Simplified66.6%
if -1.00000000000000006e-295 < (+.f64 (*.f64 (*.f64 ew (sin.f64 t)) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-sqr-sqrt99.1%
fabs-sqr99.1%
add-sqr-sqrt99.8%
fma-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 98.4%
Final simplification81.5%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t))))))) (* ew (* (sin t) (/ 1.0 (hypot 1.0 (/ (/ eh ew) (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(((eh * (cos(t) * sin(atan((eh / (ew * tan(t))))))) + (ew * (sin(t) * (1.0 / hypot(1.0, ((eh / ew) / tan(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.sin(t) * (1.0 / Math.hypot(1.0, ((eh / ew) / Math.tan(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) * (1.0 / math.hypot(1.0, ((eh / ew) / math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t))))))) + Float64(ew * Float64(sin(t) * Float64(1.0 / hypot(1.0, Float64(Float64(eh / ew) / tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * (cos(t) * sin(atan((eh / (ew * tan(t))))))) + (ew * (sin(t) * (1.0 / hypot(1.0, ((eh / ew) / tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(ew * N[(N[Sin[t], $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right) + ew \cdot \left(\sin t \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)\right|
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 99.8%
associate-/r*99.8%
cos-atan99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
Final simplification99.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(eh / Float64(ew * tan(t))) return abs(Float64(Float64(eh * Float64(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[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $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{eh}{ew \cdot \tan t}\\
\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} t\_1\right) + \frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, t\_1\right)}\right|
\end{array}
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 99.8%
associate-/r*99.8%
cos-atan99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
associate-*l/99.8%
*-un-lft-identity99.8%
associate-*r/99.8%
associate-/l/99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* ew (sin t)) (cos (atan (/ eh (* t ew))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs((((ew * sin(t)) * cos(atan((eh / (t * ew))))) + ((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)) * cos(atan((eh / (t * ew))))) + ((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)) * Math.cos(Math.atan((eh / (t * ew))))) + ((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.cos(math.atan((eh / (t * ew))))) + ((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(atan(Float64(eh / Float64(t * ew))))) + 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)) * cos(atan((eh / (t * ew))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $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|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\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%
Taylor expanded in t around 0 98.6%
Final simplification98.6%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t))))))) (* ew (sin t)))))
double code(double eh, double ew, double t) {
return fabs(((eh * (cos(t) * sin(atan((eh / (ew * tan(t))))))) + (ew * sin(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))))
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))));
}
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))))
function code(eh, ew, t) return abs(Float64(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t))))))) + Float64(ew * sin(t)))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * (cos(t) * sin(atan((eh / (ew * tan(t))))))) + (ew * sin(t)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right) + ew \cdot \sin t\right|
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 99.8%
associate-/r*99.8%
cos-atan99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 98.4%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -6e+72) (not (<= ew 6e+69))) (fabs (* (sin t) (* ew (cos (atan (/ (/ eh ew) (tan t))))))) (fabs (* (cos t) (* eh (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -6e+72) || !(ew <= 6e+69)) {
tmp = fabs((sin(t) * (ew * cos(atan(((eh / ew) / tan(t)))))));
} else {
tmp = fabs((cos(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 ((ew <= (-6d+72)) .or. (.not. (ew <= 6d+69))) then
tmp = abs((sin(t) * (ew * cos(atan(((eh / ew) / tan(t)))))))
else
tmp = abs((cos(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 ((ew <= -6e+72) || !(ew <= 6e+69)) {
tmp = Math.abs((Math.sin(t) * (ew * Math.cos(Math.atan(((eh / ew) / Math.tan(t)))))));
} else {
tmp = Math.abs((Math.cos(t) * (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -6e+72) or not (ew <= 6e+69): tmp = math.fabs((math.sin(t) * (ew * math.cos(math.atan(((eh / ew) / math.tan(t))))))) else: tmp = math.fabs((math.cos(t) * (eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -6e+72) || !(ew <= 6e+69)) tmp = abs(Float64(sin(t) * Float64(ew * cos(atan(Float64(Float64(eh / ew) / tan(t))))))); else tmp = abs(Float64(cos(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 ((ew <= -6e+72) || ~((ew <= 6e+69))) tmp = abs((sin(t) * (ew * cos(atan(((eh / ew) / tan(t))))))); else tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(t)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -6e+72], N[Not[LessEqual[ew, 6e+69]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * N[(ew * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[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}\;ew \leq -6 \cdot 10^{+72} \lor \neg \left(ew \leq 6 \cdot 10^{+69}\right):\\
\;\;\;\;\left|\sin t \cdot \left(ew \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|\\
\end{array}
\end{array}
if ew < -6.00000000000000006e72 or 5.99999999999999967e69 < ew Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around inf 99.8%
+-commutative99.8%
associate-/l*99.7%
fma-define99.7%
*-commutative99.7%
associate-/l*99.7%
associate-/r*99.7%
*-commutative99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in ew around inf 71.8%
associate-*r*71.8%
associate-/r*71.8%
*-commutative71.8%
Simplified71.8%
if -6.00000000000000006e72 < ew < 5.99999999999999967e69Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 82.8%
*-commutative82.8%
associate-*r*82.8%
*-commutative82.8%
Simplified82.8%
Final simplification79.0%
(FPCore (eh ew t) :precision binary64 (fabs (* (cos t) (* eh (sin (atan (/ eh (* ew (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs((cos(t) * (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((cos(t) * (eh * sin(atan((eh / (ew * tan(t))))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.cos(t) * (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
}
def code(eh, ew, t): return math.fabs((math.cos(t) * (eh * math.sin(math.atan((eh / (ew * math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(cos(t) * Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[Cos[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}
\\
\left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 65.1%
*-commutative65.1%
associate-*r*65.1%
*-commutative65.1%
Simplified65.1%
(FPCore (eh ew t) :precision binary64 (if (<= t -4.5e-7) (fabs (* ew (* eh (* (cos t) (/ (sin (atan (/ eh (* t ew)))) ew))))) (fabs eh)))
double code(double eh, double ew, double t) {
double tmp;
if (t <= -4.5e-7) {
tmp = fabs((ew * (eh * (cos(t) * (sin(atan((eh / (t * ew)))) / ew)))));
} else {
tmp = fabs(eh);
}
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 <= (-4.5d-7)) then
tmp = abs((ew * (eh * (cos(t) * (sin(atan((eh / (t * ew)))) / ew)))))
else
tmp = abs(eh)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (t <= -4.5e-7) {
tmp = Math.abs((ew * (eh * (Math.cos(t) * (Math.sin(Math.atan((eh / (t * ew)))) / ew)))));
} else {
tmp = Math.abs(eh);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if t <= -4.5e-7: tmp = math.fabs((ew * (eh * (math.cos(t) * (math.sin(math.atan((eh / (t * ew)))) / ew))))) else: tmp = math.fabs(eh) return tmp
function code(eh, ew, t) tmp = 0.0 if (t <= -4.5e-7) tmp = abs(Float64(ew * Float64(eh * Float64(cos(t) * Float64(sin(atan(Float64(eh / Float64(t * ew)))) / ew))))); else tmp = abs(eh); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (t <= -4.5e-7) tmp = abs((ew * (eh * (cos(t) * (sin(atan((eh / (t * ew)))) / ew))))); else tmp = abs(eh); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[t, -4.5e-7], N[Abs[N[(ew * N[(eh * N[(N[Cos[t], $MachinePrecision] * N[(N[Sin[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.5 \cdot 10^{-7}:\\
\;\;\;\;\left|ew \cdot \left(eh \cdot \left(\cos t \cdot \frac{\sin \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)}{ew}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\
\end{array}
\end{array}
if t < -4.4999999999999998e-7Initial program 99.7%
fma-define99.7%
associate-/l/99.7%
associate-*l*99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in ew around inf 86.1%
+-commutative86.1%
associate-/l*86.0%
fma-define86.0%
*-commutative86.0%
associate-/l*86.0%
associate-/r*86.0%
*-commutative86.0%
associate-/r*86.0%
Simplified86.0%
Taylor expanded in eh around inf 49.9%
associate-/l*49.6%
associate-/l*49.6%
associate-/r*49.6%
Simplified49.6%
Taylor expanded in t around 0 25.4%
if -4.4999999999999998e-7 < t Initial program 99.9%
fma-define99.9%
associate-/l/99.9%
associate-*l*99.9%
associate-/l/99.9%
Simplified99.9%
Taylor expanded in t around 0 49.9%
Taylor expanded in t around 0 48.3%
sin-atan15.4%
hypot-1-def26.9%
Applied egg-rr26.9%
associate-/l/27.0%
Simplified27.0%
Taylor expanded in eh around inf 50.3%
Final simplification43.6%
(FPCore (eh ew t) :precision binary64 (fabs eh))
double code(double eh, double ew, double t) {
return fabs(eh);
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(eh)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(eh);
}
def code(eh, ew, t): return math.fabs(eh)
function code(eh, ew, t) return abs(eh) end
function tmp = code(eh, ew, t) tmp = abs(eh); end
code[eh_, ew_, t_] := N[Abs[eh], $MachinePrecision]
\begin{array}{l}
\\
\left|eh\right|
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in t around 0 40.5%
Taylor expanded in t around 0 38.1%
sin-atan13.1%
hypot-1-def22.1%
Applied egg-rr22.1%
associate-/l/22.2%
Simplified22.2%
Taylor expanded in eh around inf 40.9%
herbie shell --seed 2024191
(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))))))))