
(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 (/ (/ 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-/l/99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l/99.8%
Applied egg-rr99.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.4%
Final simplification98.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%
associate-/l/99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l/99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 98.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.9e-44) (not (<= ew 5e-113))) (fabs (+ (* ew (sin t)) (* eh (sin (atan (/ (/ eh ew) (tan t))))))) (fabs (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.9e-44) || !(ew <= 5e-113)) {
tmp = fabs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(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.9d-44)) .or. (.not. (ew <= 5d-113))) then
tmp = abs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(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.9e-44) || !(ew <= 5e-113)) {
tmp = Math.abs(((ew * Math.sin(t)) + (eh * Math.sin(Math.atan(((eh / ew) / Math.tan(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.9e-44) or not (ew <= 5e-113): tmp = math.fabs(((ew * math.sin(t)) + (eh * math.sin(math.atan(((eh / ew) / math.tan(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.9e-44) || !(ew <= 5e-113)) tmp = abs(Float64(Float64(ew * sin(t)) + Float64(eh * sin(atan(Float64(Float64(eh / ew) / tan(t))))))); else tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.9e-44) || ~((ew <= 5e-113))) tmp = abs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(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.9e-44], N[Not[LessEqual[ew, 5e-113]], $MachinePrecision]], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.9 \cdot 10^{-44} \lor \neg \left(ew \leq 5 \cdot 10^{-113}\right):\\
\;\;\;\;\left|ew \cdot \sin t + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|\\
\end{array}
\end{array}
if ew < -1.9e-44 or 4.9999999999999997e-113 < ew Initial program 99.8%
associate-/l/99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l/99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 97.2%
Taylor expanded in t around 0 88.6%
if -1.9e-44 < ew < 4.9999999999999997e-113Initial 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 94.1%
Final simplification90.4%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -3.3e-14) (not (<= eh 1.5e-75))) (fabs (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t)))))))) (fabs (* ew (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3.3e-14) || !(eh <= 1.5e-75)) {
tmp = fabs((eh * (cos(t) * 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 <= (-3.3d-14)) .or. (.not. (eh <= 1.5d-75))) then
tmp = abs((eh * (cos(t) * 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 <= -3.3e-14) || !(eh <= 1.5e-75)) {
tmp = Math.abs((eh * (Math.cos(t) * 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 <= -3.3e-14) or not (eh <= 1.5e-75): tmp = math.fabs((eh * (math.cos(t) * 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 <= -3.3e-14) || !(eh <= 1.5e-75)) tmp = abs(Float64(eh * Float64(cos(t) * 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 <= -3.3e-14) || ~((eh <= 1.5e-75))) tmp = abs((eh * (cos(t) * 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, -3.3e-14], N[Not[LessEqual[eh, 1.5e-75]], $MachinePrecision]], N[Abs[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], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -3.3 \cdot 10^{-14} \lor \neg \left(eh \leq 1.5 \cdot 10^{-75}\right):\\
\;\;\;\;\left|eh \cdot \left(\cos t \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 < -3.2999999999999998e-14 or 1.4999999999999999e-75 < eh Initial program 99.7%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 83.0%
if -3.2999999999999998e-14 < eh < 1.4999999999999999e-75Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-sqr-sqrt45.3%
fabs-sqr45.3%
add-sqr-sqrt46.8%
expm1-log1p-u45.0%
expm1-undefine21.6%
Applied egg-rr21.6%
expm1-define45.0%
fma-define45.0%
+-commutative45.0%
fma-define45.0%
associate-/r*45.0%
associate-*r/44.9%
associate-/r*44.9%
Simplified44.9%
Applied egg-rr99.8%
Taylor expanded in ew around inf 77.8%
Final simplification80.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (sin (atan (/ eh (* ew (tan t)))))))
(if (<= eh -3.6e-14)
(fabs (* eh (* (cos t) t_1)))
(if (<= eh 4.9e-64)
(fabs (* ew (sin t)))
(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 (eh <= -3.6e-14) {
tmp = fabs((eh * (cos(t) * t_1)));
} else if (eh <= 4.9e-64) {
tmp = fabs((ew * sin(t)));
} 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 (eh <= (-3.6d-14)) then
tmp = abs((eh * (cos(t) * t_1)))
else if (eh <= 4.9d-64) then
tmp = abs((ew * sin(t)))
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 (eh <= -3.6e-14) {
tmp = Math.abs((eh * (Math.cos(t) * t_1)));
} else if (eh <= 4.9e-64) {
tmp = Math.abs((ew * Math.sin(t)));
} 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 eh <= -3.6e-14: tmp = math.fabs((eh * (math.cos(t) * t_1))) elif eh <= 4.9e-64: tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs(((eh * math.cos(t)) * t_1)) return tmp
function code(eh, ew, t) t_1 = sin(atan(Float64(eh / Float64(ew * tan(t))))) tmp = 0.0 if (eh <= -3.6e-14) tmp = abs(Float64(eh * Float64(cos(t) * t_1))); elseif (eh <= 4.9e-64) tmp = abs(Float64(ew * sin(t))); 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 (eh <= -3.6e-14) tmp = abs((eh * (cos(t) * t_1))); elseif (eh <= 4.9e-64) tmp = abs((ew * sin(t))); 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[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -3.6e-14], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 4.9e-64], N[Abs[N[(ew * N[Sin[t], $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{eh}{ew \cdot \tan t}\right)\\
\mathbf{if}\;eh \leq -3.6 \cdot 10^{-14}:\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot t\_1\right)\right|\\
\mathbf{elif}\;eh \leq 4.9 \cdot 10^{-64}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot t\_1\right|\\
\end{array}
\end{array}
if eh < -3.5999999999999998e-14Initial 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 83.5%
if -3.5999999999999998e-14 < eh < 4.9000000000000002e-64Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-sqr-sqrt45.3%
fabs-sqr45.3%
add-sqr-sqrt46.8%
expm1-log1p-u45.0%
expm1-undefine21.6%
Applied egg-rr21.6%
expm1-define45.0%
fma-define45.0%
+-commutative45.0%
fma-define45.0%
associate-/r*45.0%
associate-*r/44.9%
associate-/r*44.9%
Simplified44.9%
Applied egg-rr99.8%
Taylor expanded in ew around inf 77.8%
if 4.9000000000000002e-64 < eh Initial 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 0 82.6%
associate-*r*82.6%
*-commutative82.6%
Simplified82.6%
Final simplification80.6%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -3.9e-14) (not (<= eh 4.8e+116))) (fabs eh) (fabs (* ew (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3.9e-14) || !(eh <= 4.8e+116)) {
tmp = fabs(eh);
} 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 <= (-3.9d-14)) .or. (.not. (eh <= 4.8d+116))) then
tmp = abs(eh)
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 <= -3.9e-14) || !(eh <= 4.8e+116)) {
tmp = Math.abs(eh);
} else {
tmp = Math.abs((ew * Math.sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -3.9e-14) or not (eh <= 4.8e+116): tmp = math.fabs(eh) else: tmp = math.fabs((ew * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -3.9e-14) || !(eh <= 4.8e+116)) tmp = abs(eh); else tmp = abs(Float64(ew * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -3.9e-14) || ~((eh <= 4.8e+116))) tmp = abs(eh); else tmp = abs((ew * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -3.9e-14], N[Not[LessEqual[eh, 4.8e+116]], $MachinePrecision]], N[Abs[eh], $MachinePrecision], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -3.9 \cdot 10^{-14} \lor \neg \left(eh \leq 4.8 \cdot 10^{+116}\right):\\
\;\;\;\;\left|eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if eh < -3.8999999999999998e-14 or 4.8000000000000001e116 < eh 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 61.3%
sin-atan13.3%
hypot-1-def29.9%
clear-num29.9%
Applied egg-rr29.9%
Taylor expanded in eh around inf 61.5%
if -3.8999999999999998e-14 < eh < 4.8000000000000001e116Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-sqr-sqrt47.9%
fabs-sqr47.9%
add-sqr-sqrt49.3%
expm1-log1p-u47.1%
expm1-undefine25.9%
Applied egg-rr25.9%
expm1-define47.1%
fma-define47.1%
+-commutative47.1%
fma-define47.1%
associate-/r*47.1%
associate-*r/47.1%
associate-/r*47.1%
Simplified47.1%
Applied egg-rr99.7%
Taylor expanded in ew around inf 69.1%
Final simplification66.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -2.3e-104) (not (<= eh 1.2e-84))) (fabs eh) (fabs (* ew t))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2.3e-104) || !(eh <= 1.2e-84)) {
tmp = fabs(eh);
} else {
tmp = fabs((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 <= (-2.3d-104)) .or. (.not. (eh <= 1.2d-84))) then
tmp = abs(eh)
else
tmp = abs((ew * t))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2.3e-104) || !(eh <= 1.2e-84)) {
tmp = Math.abs(eh);
} else {
tmp = Math.abs((ew * t));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -2.3e-104) or not (eh <= 1.2e-84): tmp = math.fabs(eh) else: tmp = math.fabs((ew * t)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -2.3e-104) || !(eh <= 1.2e-84)) tmp = abs(eh); else tmp = abs(Float64(ew * t)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -2.3e-104) || ~((eh <= 1.2e-84))) tmp = abs(eh); else tmp = abs((ew * t)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -2.3e-104], N[Not[LessEqual[eh, 1.2e-84]], $MachinePrecision]], N[Abs[eh], $MachinePrecision], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -2.3 \cdot 10^{-104} \lor \neg \left(eh \leq 1.2 \cdot 10^{-84}\right):\\
\;\;\;\;\left|eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot t\right|\\
\end{array}
\end{array}
if eh < -2.2999999999999999e-104 or 1.20000000000000009e-84 < eh 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 51.0%
sin-atan12.3%
hypot-1-def27.6%
clear-num27.6%
Applied egg-rr27.6%
Taylor expanded in eh around inf 51.3%
if -2.2999999999999999e-104 < eh < 1.20000000000000009e-84Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-sqr-sqrt44.7%
fabs-sqr44.7%
add-sqr-sqrt46.4%
expm1-log1p-u44.3%
expm1-undefine23.3%
Applied egg-rr23.3%
expm1-define44.3%
fma-define44.3%
+-commutative44.3%
fma-define44.3%
associate-/r*44.3%
associate-*r/44.3%
associate-/r*44.3%
Simplified44.3%
Taylor expanded in eh around 0 23.3%
log1p-define39.3%
Simplified39.3%
Taylor expanded in t around 0 24.4%
*-commutative24.4%
Simplified24.4%
add-sqr-sqrt23.3%
sqrt-unprod37.0%
pow237.0%
Applied egg-rr37.0%
unpow237.0%
rem-sqrt-square45.4%
Simplified45.4%
Final simplification49.2%
(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 39.2%
sin-atan10.3%
hypot-1-def20.4%
clear-num20.4%
Applied egg-rr20.4%
Taylor expanded in eh around inf 39.7%
(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%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-sqr-sqrt48.1%
fabs-sqr48.1%
add-sqr-sqrt49.0%
expm1-log1p-u45.9%
expm1-undefine33.1%
Applied egg-rr33.1%
expm1-define45.9%
fma-define45.9%
+-commutative45.9%
fma-define45.9%
associate-/r*45.9%
associate-*r/45.9%
associate-/r*45.9%
Simplified45.9%
Taylor expanded in eh around 0 14.5%
log1p-define21.1%
Simplified21.1%
Taylor expanded in t around 0 12.3%
*-commutative12.3%
Simplified12.3%
Final simplification12.3%
herbie shell --seed 2024144
(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))))))))