
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (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(Float64(eh / ew) / tan(t)))), Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t))))))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + 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]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-udef87.6%
cos-atan87.6%
un-div-inv87.6%
hypot-1-def87.6%
Applied egg-rr87.6%
expm1-def99.7%
expm1-log1p99.8%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(+
(* (* ew (sin t)) (/ 1.0 (hypot 1.0 t_1)))
(* (* eh (cos t)) (sin (atan t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs((((ew * sin(t)) * (1.0 / hypot(1.0, t_1))) + ((eh * cos(t)) * sin(atan(t_1)))));
}
public static double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / Math.tan(t);
return Math.abs((((ew * Math.sin(t)) * (1.0 / Math.hypot(1.0, t_1))) + ((eh * Math.cos(t)) * Math.sin(Math.atan(t_1)))));
}
def code(eh, ew, t): t_1 = (eh / ew) / math.tan(t) return math.fabs((((ew * math.sin(t)) * (1.0 / math.hypot(1.0, t_1))) + ((eh * math.cos(t)) * math.sin(math.atan(t_1)))))
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(Float64(Float64(Float64(ew * sin(t)) * Float64(1.0 / hypot(1.0, t_1))) + Float64(Float64(eh * cos(t)) * sin(atan(t_1))))) end
function tmp = code(eh, ew, t) t_1 = (eh / ew) / tan(t); tmp = abs((((ew * sin(t)) * (1.0 / hypot(1.0, t_1))) + ((eh * cos(t)) * sin(atan(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[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\left(ew \cdot \sin t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, t\_1\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t\_1\right|
\end{array}
\end{array}
Initial program 99.8%
associate-/r*99.8%
cos-atan99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
associate-/r*99.8%
Simplified99.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%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
add-log-exp87.6%
cos-atan87.6%
un-div-inv87.6%
hypot-1-def87.6%
Applied egg-rr87.6%
fma-udef87.6%
rem-log-exp99.8%
associate-*r/99.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 (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 98.9%
Final simplification98.9%
(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(eh / Float64(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[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $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{eh}{ew \cdot \tan t}\right)\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-udef87.6%
cos-atan87.6%
un-div-inv87.6%
hypot-1-def87.6%
Applied egg-rr87.6%
expm1-def99.7%
expm1-log1p99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in eh around 0 98.2%
Final simplification98.2%
(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%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-udef87.6%
cos-atan87.6%
un-div-inv87.6%
hypot-1-def87.6%
Applied egg-rr87.6%
expm1-def99.7%
expm1-log1p99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in eh around 0 98.2%
fma-udef98.2%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (sin (atan (/ (/ eh ew) (tan t))))))
(if (or (<= ew -1.9e+17) (not (<= ew 44000000000000.0)))
(fabs (+ (/ ew (/ 1.0 (sin t))) (* eh t_1)))
(fabs (* (* eh (cos t)) t_1)))))
double code(double eh, double ew, double t) {
double t_1 = sin(atan(((eh / ew) / tan(t))));
double tmp;
if ((ew <= -1.9e+17) || !(ew <= 44000000000000.0)) {
tmp = fabs(((ew / (1.0 / sin(t))) + (eh * t_1)));
} else {
tmp = fabs(((eh * cos(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 = sin(atan(((eh / ew) / tan(t))))
if ((ew <= (-1.9d+17)) .or. (.not. (ew <= 44000000000000.0d0))) then
tmp = abs(((ew / (1.0d0 / sin(t))) + (eh * t_1)))
else
tmp = abs(((eh * cos(t)) * t_1))
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 <= -1.9e+17) || !(ew <= 44000000000000.0)) {
tmp = Math.abs(((ew / (1.0 / Math.sin(t))) + (eh * t_1)));
} else {
tmp = Math.abs(((eh * Math.cos(t)) * t_1));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.sin(math.atan(((eh / ew) / math.tan(t)))) tmp = 0 if (ew <= -1.9e+17) or not (ew <= 44000000000000.0): tmp = math.fabs(((ew / (1.0 / math.sin(t))) + (eh * t_1))) else: tmp = math.fabs(((eh * math.cos(t)) * t_1)) return tmp
function code(eh, ew, t) t_1 = sin(atan(Float64(Float64(eh / ew) / tan(t)))) tmp = 0.0 if ((ew <= -1.9e+17) || !(ew <= 44000000000000.0)) tmp = abs(Float64(Float64(ew / Float64(1.0 / sin(t))) + Float64(eh * t_1))); else tmp = abs(Float64(Float64(eh * cos(t)) * t_1)); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = sin(atan(((eh / ew) / tan(t)))); tmp = 0.0; if ((ew <= -1.9e+17) || ~((ew <= 44000000000000.0))) tmp = abs(((ew / (1.0 / sin(t))) + (eh * t_1))); else tmp = abs(((eh * cos(t)) * t_1)); 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, -1.9e+17], N[Not[LessEqual[ew, 44000000000000.0]], $MachinePrecision]], N[Abs[N[(N[(ew / N[(1.0 / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eh * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * t$95$1), $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 -1.9 \cdot 10^{+17} \lor \neg \left(ew \leq 44000000000000\right):\\
\;\;\;\;\left|\frac{ew}{\frac{1}{\sin t}} + eh \cdot t\_1\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot t\_1\right|\\
\end{array}
\end{array}
if ew < -1.9e17 or 4.4e13 < ew Initial program 99.8%
Taylor expanded in t around 0 87.1%
expm1-log1p-u50.8%
expm1-udef41.9%
cos-atan45.2%
hypot-1-def45.2%
associate-/r*45.2%
un-div-inv45.2%
Applied egg-rr45.2%
expm1-def54.0%
expm1-log1p87.1%
associate-/l*86.9%
associate-/r*86.9%
Simplified86.9%
Taylor expanded in eh around 0 85.6%
if -1.9e17 < ew < 4.4e13Initial program 99.8%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-udef96.0%
cos-atan96.0%
un-div-inv96.0%
hypot-1-def96.0%
Applied egg-rr96.0%
expm1-def99.8%
expm1-log1p99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in eh around 0 98.6%
Taylor expanded in ew around 0 87.2%
associate-*r*87.2%
associate-/r*87.2%
Simplified87.2%
Final simplification86.5%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.5e+18) (not (<= ew 8e+17))) (fabs (* ew (sin t))) (fabs (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.5e+18) || !(ew <= 8e+17)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs(((eh * cos(t)) * 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 <= (-1.5d+18)) .or. (.not. (ew <= 8d+17))) then
tmp = abs((ew * sin(t)))
else
tmp = abs(((eh * cos(t)) * 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 <= -1.5e+18) || !(ew <= 8e+17)) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.5e+18) or not (ew <= 8e+17): tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.5e+18) || !(ew <= 8e+17)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.5e+18) || ~((ew <= 8e+17))) tmp = abs((ew * sin(t))); else tmp = abs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.5e+18], N[Not[LessEqual[ew, 8e+17]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.5 \cdot 10^{+18} \lor \neg \left(ew \leq 8 \cdot 10^{+17}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\end{array}
\end{array}
if ew < -1.5e18 or 8e17 < ew Initial program 99.8%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
expm1-log1p-u99.6%
expm1-udef76.6%
cos-atan76.6%
un-div-inv76.6%
hypot-1-def76.6%
Applied egg-rr76.6%
expm1-def99.6%
expm1-log1p99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in eh around 0 97.7%
Taylor expanded in ew around inf 68.4%
if -1.5e18 < ew < 8e17Initial program 99.8%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-udef96.0%
cos-atan96.0%
un-div-inv96.0%
hypot-1-def96.0%
Applied egg-rr96.0%
expm1-def99.8%
expm1-log1p99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in eh around 0 98.6%
Taylor expanded in ew around 0 87.2%
associate-*r*87.2%
associate-/r*87.2%
Simplified87.2%
Final simplification79.0%
(FPCore (eh ew t)
:precision binary64
(if (<= t -9.5e-6)
(fabs (* ew (sin t)))
(if (<= t 760000.0)
(fabs (+ (* ew t) (* eh (sin (atan (/ eh (* ew (tan t))))))))
(fabs (* ew (sqrt (pow (sin t) 2.0)))))))
double code(double eh, double ew, double t) {
double tmp;
if (t <= -9.5e-6) {
tmp = fabs((ew * sin(t)));
} else if (t <= 760000.0) {
tmp = fabs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t))))))));
} else {
tmp = fabs((ew * sqrt(pow(sin(t), 2.0))));
}
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 <= (-9.5d-6)) then
tmp = abs((ew * sin(t)))
else if (t <= 760000.0d0) then
tmp = abs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t))))))))
else
tmp = abs((ew * sqrt((sin(t) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (t <= -9.5e-6) {
tmp = Math.abs((ew * Math.sin(t)));
} else if (t <= 760000.0) {
tmp = Math.abs(((ew * t) + (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
} else {
tmp = Math.abs((ew * Math.sqrt(Math.pow(Math.sin(t), 2.0))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if t <= -9.5e-6: tmp = math.fabs((ew * math.sin(t))) elif t <= 760000.0: tmp = math.fabs(((ew * t) + (eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))) else: tmp = math.fabs((ew * math.sqrt(math.pow(math.sin(t), 2.0)))) return tmp
function code(eh, ew, t) tmp = 0.0 if (t <= -9.5e-6) tmp = abs(Float64(ew * sin(t))); elseif (t <= 760000.0) tmp = abs(Float64(Float64(ew * t) + Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); else tmp = abs(Float64(ew * sqrt((sin(t) ^ 2.0)))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (t <= -9.5e-6) tmp = abs((ew * sin(t))); elseif (t <= 760000.0) tmp = abs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t)))))))); else tmp = abs((ew * sqrt((sin(t) ^ 2.0)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[t, -9.5e-6], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 760000.0], 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[(ew * N[Sqrt[N[Power[N[Sin[t], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.5 \cdot 10^{-6}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{elif}\;t \leq 760000:\\
\;\;\;\;\left|ew \cdot t + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sqrt{{\sin t}^{2}}\right|\\
\end{array}
\end{array}
if t < -9.5000000000000005e-6Initial program 99.6%
associate-*l*99.6%
fma-def99.6%
associate-/r*99.6%
associate-*l*99.6%
associate-/r*99.6%
Simplified99.6%
expm1-log1p-u99.4%
expm1-udef99.0%
cos-atan99.0%
un-div-inv99.0%
hypot-1-def99.0%
Applied egg-rr99.0%
expm1-def99.4%
expm1-log1p99.6%
associate-/r*99.6%
Simplified99.6%
Taylor expanded in eh around 0 96.7%
Taylor expanded in ew around inf 47.3%
if -9.5000000000000005e-6 < t < 7.6e5Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
associate-/r*100.0%
associate-*l*100.0%
associate-/r*100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef73.3%
cos-atan73.3%
un-div-inv73.3%
hypot-1-def73.3%
Applied egg-rr73.3%
expm1-def100.0%
expm1-log1p100.0%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in eh around 0 98.4%
Taylor expanded in t around 0 96.5%
if 7.6e5 < t Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
expm1-log1p-u99.6%
expm1-udef99.3%
cos-atan99.3%
un-div-inv99.3%
hypot-1-def99.3%
Applied egg-rr99.3%
expm1-def99.6%
expm1-log1p99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in eh around 0 99.4%
Taylor expanded in ew around inf 43.8%
add-sqr-sqrt20.4%
sqrt-unprod43.8%
pow243.8%
Applied egg-rr43.8%
Final simplification68.4%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (sin t))))
double code(double eh, double ew, double t) {
return fabs((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((ew * sin(t)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.sin(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.sin(t)))
function code(eh, ew, t) return abs(Float64(ew * sin(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * sin(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \sin t\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-udef87.6%
cos-atan87.6%
un-div-inv87.6%
hypot-1-def87.6%
Applied egg-rr87.6%
expm1-def99.7%
expm1-log1p99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in eh around 0 98.2%
Taylor expanded in ew around inf 39.3%
Final simplification39.3%
(FPCore (eh ew t) :precision binary64 (fabs (* ew t)))
double code(double eh, double ew, double t) {
return fabs((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((ew * t))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * t));
}
def code(eh, ew, t): return math.fabs((ew * t))
function code(eh, ew, t) return abs(Float64(ew * t)) end
function tmp = code(eh, ew, t) tmp = abs((ew * t)); end
code[eh_, ew_, t_] := N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot t\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-def99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-udef87.6%
cos-atan87.6%
un-div-inv87.6%
hypot-1-def87.6%
Applied egg-rr87.6%
expm1-def99.7%
expm1-log1p99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in eh around 0 98.2%
Taylor expanded in ew around inf 39.3%
Taylor expanded in t around 0 17.8%
Final simplification17.8%
herbie shell --seed 2024031
(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))))))))