
(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 (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-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/r*99.8%
Applied egg-rr99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(+
(/ (* ew (sin t)) (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)) / 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)) / 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)) / 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)) / 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)) / 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[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $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|\frac{ew \cdot \sin t}{\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%
un-div-inv99.8%
hypot-1-def99.8%
associate-/r*99.8%
Applied egg-rr99.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (/ ew (/ (hypot 1.0 (/ eh (* ew (tan t)))) (sin t))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (ew / (hypot(1.0, (eh / (ew * tan(t)))) / sin(t)))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + (ew / (Math.hypot(1.0, (eh / (ew * Math.tan(t)))) / Math.sin(t)))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + (ew / (math.hypot(1.0, (eh / (ew * math.tan(t)))) / math.sin(t)))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(ew / Float64(hypot(1.0, Float64(eh / Float64(ew * tan(t)))) / sin(t))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (ew / (hypot(1.0, (eh / (ew * tan(t)))) / sin(t))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(ew / N[(N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \frac{ew}{\frac{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}{\sin t}}\right|
\end{array}
Initial program 99.8%
associate-/r*99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/r*99.8%
Applied egg-rr99.8%
associate-/l*99.8%
associate-/r*99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-commutative99.8%
associate-*r/99.8%
*-commutative99.8%
associate-/r/99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (* (* ew (sin t)) (cos (atan (/ eh (* ew t))))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + ((ew * Math.sin(t)) * Math.cos(Math.atan((eh / (ew * t)))))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + ((ew * math.sin(t)) * math.cos(math.atan((eh / (ew * t)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(eh / Float64(ew * t))))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 99.1%
Final simplification99.1%
(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-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in eh around 0 98.9%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -7.4e-90) (not (<= eh 19000.0))) (fabs (* (cos t) (* eh (sin (atan (/ eh (* ew (tan t)))))))) (fabs (* ew (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -7.4e-90) || !(eh <= 19000.0)) {
tmp = fabs((cos(t) * (eh * sin(atan((eh / (ew * tan(t))))))));
} else {
tmp = fabs((ew * sin(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 ((eh <= (-7.4d-90)) .or. (.not. (eh <= 19000.0d0))) then
tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(t))))))))
else
tmp = abs((ew * sin(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -7.4e-90) || !(eh <= 19000.0)) {
tmp = Math.abs((Math.cos(t) * (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
} else {
tmp = Math.abs((ew * Math.sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -7.4e-90) or not (eh <= 19000.0): tmp = math.fabs((math.cos(t) * (eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))) else: tmp = math.fabs((ew * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -7.4e-90) || !(eh <= 19000.0)) tmp = abs(Float64(cos(t) * Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); else tmp = abs(Float64(ew * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -7.4e-90) || ~((eh <= 19000.0))) tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(t)))))))); else tmp = abs((ew * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -7.4e-90], N[Not[LessEqual[eh, 19000.0]], $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], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -7.4 \cdot 10^{-90} \lor \neg \left(eh \leq 19000\right):\\
\;\;\;\;\left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if eh < -7.40000000000000035e-90 or 19000 < eh Initial program 99.8%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in ew around 0 82.2%
*-commutative82.2%
associate-*r*82.2%
*-commutative82.2%
Simplified82.2%
if -7.40000000000000035e-90 < eh < 19000Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 77.4%
Final simplification80.2%
(FPCore (eh ew t)
:precision binary64
(if (<= eh -1.8e-100)
(fabs (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))
(if (<= eh 8.2)
(fabs (* ew (sin t)))
(fabs (* (cos t) (* eh (sin (atan (/ eh (* ew (tan t)))))))))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1.8e-100) {
tmp = fabs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))));
} else if (eh <= 8.2) {
tmp = fabs((ew * sin(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 (eh <= (-1.8d-100)) then
tmp = abs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))
else if (eh <= 8.2d0) then
tmp = abs((ew * sin(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 (eh <= -1.8e-100) {
tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))));
} else if (eh <= 8.2) {
tmp = Math.abs((ew * Math.sin(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 eh <= -1.8e-100: tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))) elif eh <= 8.2: tmp = math.fabs((ew * math.sin(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 (eh <= -1.8e-100) tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))); elseif (eh <= 8.2) tmp = abs(Float64(ew * sin(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 (eh <= -1.8e-100) tmp = abs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))); elseif (eh <= 8.2) tmp = abs((ew * sin(t))); else tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(t)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -1.8e-100], 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], If[LessEqual[eh, 8.2], N[Abs[N[(ew * N[Sin[t], $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}\;eh \leq -1.8 \cdot 10^{-100}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{elif}\;eh \leq 8.2:\\
\;\;\;\;\left|ew \cdot \sin t\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 eh < -1.7999999999999999e-100Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
cos-atan99.9%
un-div-inv99.9%
hypot-1-def99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in ew around 0 80.6%
associate-*r*80.6%
*-commutative80.6%
associate-/r*80.6%
Simplified80.6%
if -1.7999999999999999e-100 < eh < 8.1999999999999993Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 77.4%
if 8.1999999999999993 < eh Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in ew around 0 83.8%
*-commutative83.8%
associate-*r*83.8%
*-commutative83.8%
Simplified83.8%
Final simplification80.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -5.3e-61) (not (<= t 5e-103))) (fabs (* ew (sin t))) (fabs eh)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -5.3e-61) || !(t <= 5e-103)) {
tmp = fabs((ew * sin(t)));
} 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 <= (-5.3d-61)) .or. (.not. (t <= 5d-103))) then
tmp = abs((ew * sin(t)))
else
tmp = abs(eh)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -5.3e-61) || !(t <= 5e-103)) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = Math.abs(eh);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -5.3e-61) or not (t <= 5e-103): tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs(eh) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -5.3e-61) || !(t <= 5e-103)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(eh); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -5.3e-61) || ~((t <= 5e-103))) tmp = abs((ew * sin(t))); else tmp = abs(eh); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -5.3e-61], N[Not[LessEqual[t, 5e-103]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.3 \cdot 10^{-61} \lor \neg \left(t \leq 5 \cdot 10^{-103}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\
\end{array}
\end{array}
if t < -5.3e-61 or 4.99999999999999966e-103 < t Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
cos-atan99.7%
un-div-inv99.8%
hypot-1-def99.8%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 55.0%
if -5.3e-61 < t < 4.99999999999999966e-103Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
associate-/r*100.0%
associate-*l*100.0%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in t around 0 78.0%
sin-atan12.8%
div-inv11.7%
hypot-1-def24.0%
*-un-lft-identity24.0%
associate-/r*24.1%
times-frac24.4%
associate-/r*24.3%
Applied egg-rr24.3%
/-rgt-identity24.3%
associate-/l/25.5%
associate-/r*25.6%
Simplified25.6%
Taylor expanded in eh around inf 78.2%
Final simplification62.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (sin t))))
(if (<= t -1.05e-49)
t_1
(if (<= t 2.3e-101) (fabs eh) (if (<= t 1.72) (fabs (* ew t)) t_1)))))
double code(double eh, double ew, double t) {
double t_1 = ew * sin(t);
double tmp;
if (t <= -1.05e-49) {
tmp = t_1;
} else if (t <= 2.3e-101) {
tmp = fabs(eh);
} else if (t <= 1.72) {
tmp = fabs((ew * t));
} else {
tmp = 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 = ew * sin(t)
if (t <= (-1.05d-49)) then
tmp = t_1
else if (t <= 2.3d-101) then
tmp = abs(eh)
else if (t <= 1.72d0) then
tmp = abs((ew * t))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.sin(t);
double tmp;
if (t <= -1.05e-49) {
tmp = t_1;
} else if (t <= 2.3e-101) {
tmp = Math.abs(eh);
} else if (t <= 1.72) {
tmp = Math.abs((ew * t));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.sin(t) tmp = 0 if t <= -1.05e-49: tmp = t_1 elif t <= 2.3e-101: tmp = math.fabs(eh) elif t <= 1.72: tmp = math.fabs((ew * t)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = Float64(ew * sin(t)) tmp = 0.0 if (t <= -1.05e-49) tmp = t_1; elseif (t <= 2.3e-101) tmp = abs(eh); elseif (t <= 1.72) tmp = abs(Float64(ew * t)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * sin(t); tmp = 0.0; if (t <= -1.05e-49) tmp = t_1; elseif (t <= 2.3e-101) tmp = abs(eh); elseif (t <= 1.72) tmp = abs((ew * t)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.05e-49], t$95$1, If[LessEqual[t, 2.3e-101], N[Abs[eh], $MachinePrecision], If[LessEqual[t, 1.72], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \sin t\\
\mathbf{if}\;t \leq -1.05 \cdot 10^{-49}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.3 \cdot 10^{-101}:\\
\;\;\;\;\left|eh\right|\\
\mathbf{elif}\;t \leq 1.72:\\
\;\;\;\;\left|ew \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.0499999999999999e-49 or 1.71999999999999997 < t Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
cos-atan99.7%
un-div-inv99.7%
hypot-1-def99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Taylor expanded in ew around inf 53.1%
add-sqr-sqrt33.7%
fabs-sqr33.7%
add-sqr-sqrt34.4%
*-commutative34.4%
Applied egg-rr34.4%
if -1.0499999999999999e-49 < t < 2.2999999999999999e-101Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
associate-/r*100.0%
associate-*l*100.0%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in t around 0 77.2%
sin-atan12.7%
div-inv11.6%
hypot-1-def23.8%
*-un-lft-identity23.8%
associate-/r*23.8%
times-frac24.2%
associate-/r*24.1%
Applied egg-rr24.1%
/-rgt-identity24.1%
associate-/l/25.3%
associate-/r*25.3%
Simplified25.3%
Taylor expanded in eh around inf 77.4%
if 2.2999999999999999e-101 < t < 1.71999999999999997Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
associate-/r*100.0%
associate-*l*100.0%
associate-/r*100.0%
Simplified100.0%
cos-atan100.0%
un-div-inv100.0%
hypot-1-def100.0%
associate-/r*100.0%
Applied egg-rr100.0%
Taylor expanded in ew around inf 68.0%
Taylor expanded in t around 0 68.0%
Final simplification51.6%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.65e+97) (not (<= ew 1.75e+107))) (fabs (* ew t)) (fabs eh)))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.65e+97) || !(ew <= 1.75e+107)) {
tmp = fabs((ew * t));
} 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 ((ew <= (-1.65d+97)) .or. (.not. (ew <= 1.75d+107))) then
tmp = abs((ew * t))
else
tmp = abs(eh)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.65e+97) || !(ew <= 1.75e+107)) {
tmp = Math.abs((ew * t));
} else {
tmp = Math.abs(eh);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.65e+97) or not (ew <= 1.75e+107): tmp = math.fabs((ew * t)) else: tmp = math.fabs(eh) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.65e+97) || !(ew <= 1.75e+107)) tmp = abs(Float64(ew * t)); else tmp = abs(eh); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.65e+97) || ~((ew <= 1.75e+107))) tmp = abs((ew * t)); else tmp = abs(eh); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.65e+97], N[Not[LessEqual[ew, 1.75e+107]], $MachinePrecision]], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.65 \cdot 10^{+97} \lor \neg \left(ew \leq 1.75 \cdot 10^{+107}\right):\\
\;\;\;\;\left|ew \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\
\end{array}
\end{array}
if ew < -1.6500000000000001e97 or 1.7499999999999999e107 < ew Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
cos-atan99.9%
un-div-inv99.9%
hypot-1-def99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in ew around inf 82.8%
Taylor expanded in t around 0 38.3%
if -1.6500000000000001e97 < ew < 1.7499999999999999e107Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in t around 0 47.4%
sin-atan8.8%
div-inv8.2%
hypot-1-def17.4%
*-un-lft-identity17.4%
associate-/r*17.4%
times-frac17.9%
associate-/r*17.8%
Applied egg-rr17.8%
/-rgt-identity17.8%
associate-/l/18.4%
associate-/r*18.5%
Simplified18.5%
Taylor expanded in eh around inf 47.7%
Final simplification44.6%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -5e-244) (not (<= eh 1.3e-252))) (fabs eh) (* ew t)))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -5e-244) || !(eh <= 1.3e-252)) {
tmp = fabs(eh);
} else {
tmp = ew * 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 ((eh <= (-5d-244)) .or. (.not. (eh <= 1.3d-252))) then
tmp = abs(eh)
else
tmp = ew * t
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -5e-244) || !(eh <= 1.3e-252)) {
tmp = Math.abs(eh);
} else {
tmp = ew * t;
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -5e-244) or not (eh <= 1.3e-252): tmp = math.fabs(eh) else: tmp = ew * t return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -5e-244) || !(eh <= 1.3e-252)) tmp = abs(eh); else tmp = Float64(ew * t); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -5e-244) || ~((eh <= 1.3e-252))) tmp = abs(eh); else tmp = ew * t; end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -5e-244], N[Not[LessEqual[eh, 1.3e-252]], $MachinePrecision]], N[Abs[eh], $MachinePrecision], N[(ew * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -5 \cdot 10^{-244} \lor \neg \left(eh \leq 1.3 \cdot 10^{-252}\right):\\
\;\;\;\;\left|eh\right|\\
\mathbf{else}:\\
\;\;\;\;ew \cdot t\\
\end{array}
\end{array}
if eh < -4.99999999999999998e-244 or 1.3e-252 < eh Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in t around 0 40.3%
sin-atan8.4%
div-inv8.4%
hypot-1-def16.6%
*-un-lft-identity16.6%
associate-/r*16.7%
times-frac17.0%
associate-/r*17.0%
Applied egg-rr17.0%
/-rgt-identity17.0%
associate-/l/17.0%
associate-/r*17.0%
Simplified17.0%
Taylor expanded in eh around inf 40.8%
if -4.99999999999999998e-244 < eh < 1.3e-252Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
cos-atan99.8%
un-div-inv99.9%
hypot-1-def99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in ew around inf 92.9%
Taylor expanded in t around 0 48.7%
add-sqr-sqrt37.5%
fabs-sqr37.5%
add-sqr-sqrt38.7%
*-commutative38.7%
Applied egg-rr38.7%
Final simplification40.6%
(FPCore (eh ew t) :precision binary64 (* ew t))
double code(double eh, double ew, double t) {
return 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 = ew * t
end function
public static double code(double eh, double ew, double t) {
return ew * t;
}
def code(eh, ew, t): return ew * t
function code(eh, ew, t) return Float64(ew * t) end
function tmp = code(eh, ew, t) tmp = ew * t; end
code[eh_, ew_, t_] := N[(ew * t), $MachinePrecision]
\begin{array}{l}
\\
ew \cdot t
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 45.1%
Taylor expanded in t around 0 19.6%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt10.3%
*-commutative10.3%
Applied egg-rr10.3%
Final simplification10.3%
herbie shell --seed 2024165
(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))))))))