
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin 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) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (fabs (- (* eh (* (sin t) (sin (atan (* eh (/ (tan t) (- ew))))))) (/ (* ew (cos t)) (hypot 1.0 (* eh (/ (tan t) ew)))))))
double code(double eh, double ew, double t) {
return fabs(((eh * (sin(t) * sin(atan((eh * (tan(t) / -ew)))))) - ((ew * cos(t)) / hypot(1.0, (eh * (tan(t) / ew))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * (Math.sin(t) * Math.sin(Math.atan((eh * (Math.tan(t) / -ew)))))) - ((ew * Math.cos(t)) / Math.hypot(1.0, (eh * (Math.tan(t) / ew))))));
}
def code(eh, ew, t): return math.fabs(((eh * (math.sin(t) * math.sin(math.atan((eh * (math.tan(t) / -ew)))))) - ((ew * math.cos(t)) / math.hypot(1.0, (eh * (math.tan(t) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * Float64(sin(t) * sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))))) - Float64(Float64(ew * cos(t)) / hypot(1.0, Float64(eh * Float64(tan(t) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * (sin(t) * sin(atan((eh * (tan(t) / -ew)))))) - ((ew * cos(t)) / hypot(1.0, (eh * (tan(t) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right) - \frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)}\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
add-sqr-sqrt47.6%
sqrt-unprod93.6%
sqr-neg93.6%
sqrt-unprod52.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* ew (cos t)) (cos (atan (* eh (/ (tan t) (- ew)))))) (* eh (sin t)))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) * cos(atan((eh * (tan(t) / -ew))))) - (eh * 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 * cos(t)) * cos(atan((eh * (tan(t) / -ew))))) - (eh * sin(t))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) * Math.cos(Math.atan((eh * (Math.tan(t) / -ew))))) - (eh * Math.sin(t))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) * math.cos(math.atan((eh * (math.tan(t) / -ew))))) - (eh * math.sin(t))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(atan(Float64(eh * Float64(tan(t) / Float64(-ew)))))) - Float64(eh * sin(t)))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) * cos(atan((eh * (tan(t) / -ew))))) - (eh * sin(t)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right) - eh \cdot \sin t\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan79.9%
associate-*r/77.8%
add-sqr-sqrt36.7%
sqrt-unprod68.1%
sqr-neg68.1%
sqrt-unprod40.7%
add-sqr-sqrt77.2%
hypot-1-def81.3%
add-sqr-sqrt37.4%
Applied egg-rr81.3%
associate-*r*74.5%
associate-/l*76.9%
*-commutative76.9%
associate-*l*74.0%
*-commutative74.0%
associate-*l/74.0%
associate-/l*72.5%
Simplified72.5%
Taylor expanded in ew around 0 99.0%
associate-*r*99.0%
mul-1-neg99.0%
associate-/l*99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))) (t_2 (fabs t_1)) (t_3 (* eh (sin t))))
(if (<= ew -1.5e-90)
t_2
(if (<= ew 1.95e-102)
(fabs t_3)
(if (<= ew 5.8e+68)
(- (* t_1 (cos (atan (* eh (/ (tan t) ew))))) t_3)
t_2)))))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double t_2 = fabs(t_1);
double t_3 = eh * sin(t);
double tmp;
if (ew <= -1.5e-90) {
tmp = t_2;
} else if (ew <= 1.95e-102) {
tmp = fabs(t_3);
} else if (ew <= 5.8e+68) {
tmp = (t_1 * cos(atan((eh * (tan(t) / ew))))) - t_3;
} else {
tmp = t_2;
}
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 * cos(t)
t_2 = abs(t_1)
t_3 = eh * sin(t)
if (ew <= (-1.5d-90)) then
tmp = t_2
else if (ew <= 1.95d-102) then
tmp = abs(t_3)
else if (ew <= 5.8d+68) then
tmp = (t_1 * cos(atan((eh * (tan(t) / ew))))) - t_3
else
tmp = t_2
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.cos(t);
double t_2 = Math.abs(t_1);
double t_3 = eh * Math.sin(t);
double tmp;
if (ew <= -1.5e-90) {
tmp = t_2;
} else if (ew <= 1.95e-102) {
tmp = Math.abs(t_3);
} else if (ew <= 5.8e+68) {
tmp = (t_1 * Math.cos(Math.atan((eh * (Math.tan(t) / ew))))) - t_3;
} else {
tmp = t_2;
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.cos(t) t_2 = math.fabs(t_1) t_3 = eh * math.sin(t) tmp = 0 if ew <= -1.5e-90: tmp = t_2 elif ew <= 1.95e-102: tmp = math.fabs(t_3) elif ew <= 5.8e+68: tmp = (t_1 * math.cos(math.atan((eh * (math.tan(t) / ew))))) - t_3 else: tmp = t_2 return tmp
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) t_2 = abs(t_1) t_3 = Float64(eh * sin(t)) tmp = 0.0 if (ew <= -1.5e-90) tmp = t_2; elseif (ew <= 1.95e-102) tmp = abs(t_3); elseif (ew <= 5.8e+68) tmp = Float64(Float64(t_1 * cos(atan(Float64(eh * Float64(tan(t) / ew))))) - t_3); else tmp = t_2; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * cos(t); t_2 = abs(t_1); t_3 = eh * sin(t); tmp = 0.0; if (ew <= -1.5e-90) tmp = t_2; elseif (ew <= 1.95e-102) tmp = abs(t_3); elseif (ew <= 5.8e+68) tmp = (t_1 * cos(atan((eh * (tan(t) / ew))))) - t_3; else tmp = t_2; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Abs[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -1.5e-90], t$95$2, If[LessEqual[ew, 1.95e-102], N[Abs[t$95$3], $MachinePrecision], If[LessEqual[ew, 5.8e+68], N[(N[(t$95$1 * N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := \left|t\_1\right|\\
t_3 := eh \cdot \sin t\\
\mathbf{if}\;ew \leq -1.5 \cdot 10^{-90}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;ew \leq 1.95 \cdot 10^{-102}:\\
\;\;\;\;\left|t\_3\right|\\
\mathbf{elif}\;ew \leq 5.8 \cdot 10^{+68}:\\
\;\;\;\;t\_1 \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right) - t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if ew < -1.5000000000000001e-90 or 5.80000000000000023e68 < ew Initial program 99.9%
sub-neg99.9%
associate-*l*99.9%
distribute-rgt-neg-in99.9%
cancel-sign-sub99.9%
associate-/l*99.9%
Simplified99.9%
cos-atan99.9%
un-div-inv99.9%
hypot-1-def99.9%
add-sqr-sqrt46.5%
sqrt-unprod89.7%
sqr-neg89.7%
sqrt-unprod53.4%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
clear-num99.6%
inv-pow99.6%
associate-*r/99.6%
Applied egg-rr99.6%
unpow-199.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in eh around 0 83.2%
if -1.5000000000000001e-90 < ew < 1.95e-102Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan55.1%
associate-*r/54.8%
add-sqr-sqrt24.9%
sqrt-unprod49.4%
sqr-neg49.4%
sqrt-unprod29.6%
add-sqr-sqrt53.9%
hypot-1-def65.2%
add-sqr-sqrt26.7%
Applied egg-rr65.2%
associate-*r*59.6%
associate-/l*66.3%
*-commutative66.3%
associate-*l*66.0%
*-commutative66.0%
associate-*l/66.0%
associate-/l*61.7%
Simplified61.7%
Taylor expanded in eh around -inf 74.6%
if 1.95e-102 < ew < 5.80000000000000023e68Initial program 99.7%
sub-neg99.7%
associate-*l*99.7%
distribute-rgt-neg-in99.7%
cancel-sign-sub99.7%
associate-/l*99.7%
Simplified99.7%
associate-*r*99.7%
sin-atan92.2%
associate-*r/89.5%
add-sqr-sqrt48.5%
sqrt-unprod79.7%
sqr-neg79.7%
sqrt-unprod40.9%
add-sqr-sqrt89.5%
hypot-1-def89.8%
add-sqr-sqrt48.7%
Applied egg-rr89.8%
associate-*r*87.4%
associate-/l*87.5%
*-commutative87.5%
associate-*l*80.0%
*-commutative80.0%
associate-*l/79.9%
associate-/l*79.9%
Simplified79.9%
*-un-lft-identity79.9%
associate-*l*79.9%
fmm-def79.9%
*-commutative79.9%
Applied egg-rr80.0%
rem-square-sqrt61.3%
fabs-sqr61.3%
rem-square-sqrt62.0%
Simplified62.1%
Taylor expanded in eh around inf 77.0%
Final simplification79.3%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -1.35e+127) (not (<= eh 0.002))) (fabs (* eh (sin t))) (fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -1.35e+127) || !(eh <= 0.002)) {
tmp = fabs((eh * sin(t)));
} else {
tmp = fabs((ew * cos(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.35d+127)) .or. (.not. (eh <= 0.002d0))) then
tmp = abs((eh * sin(t)))
else
tmp = abs((ew * cos(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -1.35e+127) || !(eh <= 0.002)) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = Math.abs((ew * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -1.35e+127) or not (eh <= 0.002): tmp = math.fabs((eh * math.sin(t))) else: tmp = math.fabs((ew * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -1.35e+127) || !(eh <= 0.002)) tmp = abs(Float64(eh * sin(t))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -1.35e+127) || ~((eh <= 0.002))) tmp = abs((eh * sin(t))); else tmp = abs((ew * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -1.35e+127], N[Not[LessEqual[eh, 0.002]], $MachinePrecision]], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1.35 \cdot 10^{+127} \lor \neg \left(eh \leq 0.002\right):\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if eh < -1.3500000000000001e127 or 2e-3 < eh Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan56.0%
associate-*r/50.9%
add-sqr-sqrt12.9%
sqrt-unprod30.8%
sqr-neg30.8%
sqrt-unprod37.1%
add-sqr-sqrt50.0%
hypot-1-def55.6%
add-sqr-sqrt13.5%
Applied egg-rr55.6%
associate-*r*43.3%
associate-/l*47.3%
*-commutative47.3%
associate-*l*40.2%
*-commutative40.2%
associate-*l/40.2%
associate-/l*36.4%
Simplified36.4%
Taylor expanded in eh around -inf 71.9%
if -1.3500000000000001e127 < eh < 2e-3Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
add-sqr-sqrt54.8%
sqrt-unprod99.3%
sqr-neg99.3%
sqrt-unprod45.1%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
clear-num99.6%
inv-pow99.6%
associate-*r/99.6%
Applied egg-rr99.6%
unpow-199.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in eh around 0 80.6%
Final simplification77.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -1.25e-13) (not (<= t 3e-30))) (fabs (* eh (sin t))) (fabs ew)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.25e-13) || !(t <= 3e-30)) {
tmp = fabs((eh * sin(t)));
} else {
tmp = fabs(ew);
}
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 <= (-1.25d-13)) .or. (.not. (t <= 3d-30))) then
tmp = abs((eh * sin(t)))
else
tmp = abs(ew)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.25e-13) || !(t <= 3e-30)) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -1.25e-13) or not (t <= 3e-30): tmp = math.fabs((eh * math.sin(t))) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -1.25e-13) || !(t <= 3e-30)) tmp = abs(Float64(eh * sin(t))); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -1.25e-13) || ~((t <= 3e-30))) tmp = abs((eh * sin(t))); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -1.25e-13], N[Not[LessEqual[t, 3e-30]], $MachinePrecision]], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.25 \cdot 10^{-13} \lor \neg \left(t \leq 3 \cdot 10^{-30}\right):\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if t < -1.24999999999999997e-13 or 2.9999999999999999e-30 < t Initial program 99.6%
sub-neg99.6%
associate-*l*99.7%
distribute-rgt-neg-in99.7%
cancel-sign-sub99.7%
associate-/l*99.7%
Simplified99.7%
associate-*r*99.6%
sin-atan71.5%
associate-*r/67.9%
add-sqr-sqrt30.7%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod37.1%
add-sqr-sqrt67.4%
hypot-1-def73.2%
add-sqr-sqrt31.3%
Applied egg-rr73.2%
associate-*r*67.3%
associate-/l*70.6%
*-commutative70.6%
associate-*l*70.5%
*-commutative70.5%
associate-*l/70.5%
associate-/l*70.5%
Simplified70.5%
Taylor expanded in eh around -inf 55.6%
if -1.24999999999999997e-13 < t < 2.9999999999999999e-30Initial program 100.0%
sub-neg100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
cancel-sign-sub100.0%
associate-/l*100.0%
Simplified100.0%
cos-atan100.0%
un-div-inv100.0%
hypot-1-def100.0%
add-sqr-sqrt50.9%
sqrt-unprod89.7%
sqr-neg89.7%
sqrt-unprod49.1%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
clear-num99.7%
inv-pow99.7%
associate-*r/99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 78.7%
Final simplification65.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (sin t) (- eh))))
(if (<= t -126000.0)
t_1
(if (<= t 1.5e+33) (fabs ew) (if (<= t 4.3e+166) (* eh (sin t)) t_1)))))
double code(double eh, double ew, double t) {
double t_1 = sin(t) * -eh;
double tmp;
if (t <= -126000.0) {
tmp = t_1;
} else if (t <= 1.5e+33) {
tmp = fabs(ew);
} else if (t <= 4.3e+166) {
tmp = eh * sin(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 = sin(t) * -eh
if (t <= (-126000.0d0)) then
tmp = t_1
else if (t <= 1.5d+33) then
tmp = abs(ew)
else if (t <= 4.3d+166) then
tmp = eh * sin(t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.sin(t) * -eh;
double tmp;
if (t <= -126000.0) {
tmp = t_1;
} else if (t <= 1.5e+33) {
tmp = Math.abs(ew);
} else if (t <= 4.3e+166) {
tmp = eh * Math.sin(t);
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.sin(t) * -eh tmp = 0 if t <= -126000.0: tmp = t_1 elif t <= 1.5e+33: tmp = math.fabs(ew) elif t <= 4.3e+166: tmp = eh * math.sin(t) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = Float64(sin(t) * Float64(-eh)) tmp = 0.0 if (t <= -126000.0) tmp = t_1; elseif (t <= 1.5e+33) tmp = abs(ew); elseif (t <= 4.3e+166) tmp = Float64(eh * sin(t)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = sin(t) * -eh; tmp = 0.0; if (t <= -126000.0) tmp = t_1; elseif (t <= 1.5e+33) tmp = abs(ew); elseif (t <= 4.3e+166) tmp = eh * sin(t); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Sin[t], $MachinePrecision] * (-eh)), $MachinePrecision]}, If[LessEqual[t, -126000.0], t$95$1, If[LessEqual[t, 1.5e+33], N[Abs[ew], $MachinePrecision], If[LessEqual[t, 4.3e+166], N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin t \cdot \left(-eh\right)\\
\mathbf{if}\;t \leq -126000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.5 \cdot 10^{+33}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{elif}\;t \leq 4.3 \cdot 10^{+166}:\\
\;\;\;\;eh \cdot \sin t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -126000 or 4.3e166 < t Initial program 99.6%
sub-neg99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
cancel-sign-sub99.6%
associate-/l*99.6%
Simplified99.6%
associate-*r*99.6%
sin-atan71.5%
associate-*r/67.1%
add-sqr-sqrt31.8%
sqrt-unprod59.2%
sqr-neg59.2%
sqrt-unprod35.2%
add-sqr-sqrt66.3%
hypot-1-def73.0%
add-sqr-sqrt32.4%
Applied egg-rr73.0%
associate-*r*65.8%
associate-/l*68.0%
*-commutative68.0%
associate-*l*67.9%
*-commutative67.9%
associate-*l/67.8%
associate-/l*67.8%
Simplified67.8%
*-un-lft-identity67.8%
associate-*l*67.8%
fmm-def67.8%
*-commutative67.8%
Applied egg-rr67.9%
rem-square-sqrt34.6%
fabs-sqr34.6%
rem-square-sqrt35.4%
Simplified35.0%
Taylor expanded in ew around 0 35.8%
mul-1-neg35.8%
*-commutative35.8%
distribute-rgt-neg-in35.8%
Simplified35.8%
if -126000 < t < 1.49999999999999992e33Initial program 100.0%
sub-neg100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
cancel-sign-sub100.0%
associate-/l*100.0%
Simplified100.0%
cos-atan100.0%
un-div-inv100.0%
hypot-1-def100.0%
add-sqr-sqrt50.4%
sqrt-unprod91.2%
sqr-neg91.2%
sqrt-unprod49.6%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
clear-num99.7%
inv-pow99.7%
associate-*r/99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 70.5%
if 1.49999999999999992e33 < t < 4.3e166Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan79.0%
associate-*r/75.9%
add-sqr-sqrt36.3%
sqrt-unprod70.2%
sqr-neg70.2%
sqrt-unprod39.5%
add-sqr-sqrt75.9%
hypot-1-def79.2%
add-sqr-sqrt36.6%
Applied egg-rr79.2%
associate-*r*73.5%
associate-/l*73.3%
*-commutative73.3%
associate-*l*73.3%
*-commutative73.3%
associate-*l/73.3%
associate-/l*73.4%
Simplified73.4%
*-un-lft-identity73.4%
associate-*l*73.4%
fmm-def73.4%
*-commutative73.4%
Applied egg-rr73.5%
rem-square-sqrt30.7%
fabs-sqr30.7%
rem-square-sqrt31.6%
Simplified31.6%
Taylor expanded in eh around -inf 34.3%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -3e-10) (not (<= t 4e+33))) (* eh (sin t)) (fabs ew)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -3e-10) || !(t <= 4e+33)) {
tmp = eh * sin(t);
} else {
tmp = fabs(ew);
}
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 <= (-3d-10)) .or. (.not. (t <= 4d+33))) then
tmp = eh * sin(t)
else
tmp = abs(ew)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -3e-10) || !(t <= 4e+33)) {
tmp = eh * Math.sin(t);
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -3e-10) or not (t <= 4e+33): tmp = eh * math.sin(t) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -3e-10) || !(t <= 4e+33)) tmp = Float64(eh * sin(t)); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -3e-10) || ~((t <= 4e+33))) tmp = eh * sin(t); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -3e-10], N[Not[LessEqual[t, 4e+33]], $MachinePrecision]], N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision], N[Abs[ew], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3 \cdot 10^{-10} \lor \neg \left(t \leq 4 \cdot 10^{+33}\right):\\
\;\;\;\;eh \cdot \sin t\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if t < -3e-10 or 3.9999999999999998e33 < t Initial program 99.6%
sub-neg99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
cancel-sign-sub99.6%
associate-/l*99.6%
Simplified99.6%
associate-*r*99.6%
sin-atan72.4%
associate-*r/68.5%
add-sqr-sqrt32.2%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod36.2%
add-sqr-sqrt68.0%
hypot-1-def73.5%
add-sqr-sqrt32.8%
Applied egg-rr73.5%
associate-*r*67.0%
associate-/l*70.0%
*-commutative70.0%
associate-*l*69.9%
*-commutative69.9%
associate-*l/69.9%
associate-/l*69.9%
Simplified69.9%
*-un-lft-identity69.9%
associate-*l*69.9%
fmm-def69.9%
*-commutative69.9%
Applied egg-rr70.0%
rem-square-sqrt32.8%
fabs-sqr32.8%
rem-square-sqrt33.6%
Simplified33.3%
Taylor expanded in eh around -inf 28.0%
if -3e-10 < t < 3.9999999999999998e33Initial program 100.0%
sub-neg100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
cancel-sign-sub100.0%
associate-/l*100.0%
Simplified100.0%
cos-atan100.0%
un-div-inv100.0%
hypot-1-def100.0%
add-sqr-sqrt49.6%
sqrt-unprod90.8%
sqr-neg90.8%
sqrt-unprod50.4%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
clear-num99.7%
inv-pow99.7%
associate-*r/99.7%
Applied egg-rr99.7%
unpow-199.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 73.4%
Final simplification49.8%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -3.3e-197) (not (<= ew 3.2e-196))) (fabs ew) (fabs (* t eh))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -3.3e-197) || !(ew <= 3.2e-196)) {
tmp = fabs(ew);
} else {
tmp = fabs((t * 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 <= (-3.3d-197)) .or. (.not. (ew <= 3.2d-196))) then
tmp = abs(ew)
else
tmp = abs((t * eh))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -3.3e-197) || !(ew <= 3.2e-196)) {
tmp = Math.abs(ew);
} else {
tmp = Math.abs((t * eh));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -3.3e-197) or not (ew <= 3.2e-196): tmp = math.fabs(ew) else: tmp = math.fabs((t * eh)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -3.3e-197) || !(ew <= 3.2e-196)) tmp = abs(ew); else tmp = abs(Float64(t * eh)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -3.3e-197) || ~((ew <= 3.2e-196))) tmp = abs(ew); else tmp = abs((t * eh)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -3.3e-197], N[Not[LessEqual[ew, 3.2e-196]], $MachinePrecision]], N[Abs[ew], $MachinePrecision], N[Abs[N[(t * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -3.3 \cdot 10^{-197} \lor \neg \left(ew \leq 3.2 \cdot 10^{-196}\right):\\
\;\;\;\;\left|ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t \cdot eh\right|\\
\end{array}
\end{array}
if ew < -3.2999999999999997e-197 or 3.2e-196 < ew Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
add-sqr-sqrt47.8%
sqrt-unprod92.5%
sqr-neg92.5%
sqrt-unprod52.0%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
clear-num99.6%
inv-pow99.6%
associate-*r/99.6%
Applied egg-rr99.6%
unpow-199.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in t around 0 47.0%
if -3.2999999999999997e-197 < ew < 3.2e-196Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan37.5%
associate-*r/37.3%
add-sqr-sqrt17.2%
sqrt-unprod27.8%
sqr-neg27.8%
sqrt-unprod19.6%
add-sqr-sqrt36.9%
hypot-1-def55.9%
add-sqr-sqrt22.1%
Applied egg-rr55.9%
associate-*r*44.4%
associate-/l*51.8%
*-commutative51.8%
associate-*l*51.4%
*-commutative51.4%
associate-*l/51.3%
associate-/l*44.4%
Simplified44.4%
Taylor expanded in eh around -inf 86.1%
Taylor expanded in t around 0 40.1%
*-commutative40.1%
Simplified40.1%
Final simplification45.9%
(FPCore (eh ew t) :precision binary64 (fabs ew))
double code(double eh, double ew, double t) {
return fabs(ew);
}
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)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(ew);
}
def code(eh, ew, t): return math.fabs(ew)
function code(eh, ew, t) return abs(ew) end
function tmp = code(eh, ew, t) tmp = abs(ew); end
code[eh_, ew_, t_] := N[Abs[ew], $MachinePrecision]
\begin{array}{l}
\\
\left|ew\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
add-sqr-sqrt47.6%
sqrt-unprod93.6%
sqr-neg93.6%
sqrt-unprod52.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
clear-num99.6%
inv-pow99.6%
associate-*r/99.6%
Applied egg-rr99.6%
unpow-199.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in t around 0 41.8%
(FPCore (eh ew t) :precision binary64 ew)
double code(double eh, double ew, double t) {
return ew;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = ew
end function
public static double code(double eh, double ew, double t) {
return ew;
}
def code(eh, ew, t): return ew
function code(eh, ew, t) return ew end
function tmp = code(eh, ew, t) tmp = ew; end
code[eh_, ew_, t_] := ew
\begin{array}{l}
\\
ew
\end{array}
Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
add-sqr-sqrt47.6%
sqrt-unprod93.6%
sqr-neg93.6%
sqrt-unprod52.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
clear-num99.6%
inv-pow99.6%
associate-*r/99.6%
Applied egg-rr99.6%
unpow-199.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in t around 0 41.8%
add-sqr-sqrt21.5%
fabs-sqr21.5%
add-sqr-sqrt22.4%
/-rgt-identity22.4%
Applied egg-rr22.4%
Final simplification22.4%
herbie shell --seed 2024172
(FPCore (eh ew t)
:name "Example 2 from Robby"
:precision binary64
(fabs (- (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))