
(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 11 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 (let* ((t_1 (atan (* eh (/ (tan t) (- ew)))))) (fabs (fma ew (* (cos t_1) (- (cos t))) (* eh (* (sin t) (sin t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh * (tan(t) / -ew)));
return fabs(fma(ew, (cos(t_1) * -cos(t)), (eh * (sin(t) * sin(t_1)))));
}
function code(eh, ew, t) t_1 = atan(Float64(eh * Float64(tan(t) / Float64(-ew)))) return abs(fma(ew, Float64(cos(t_1) * Float64(-cos(t))), Float64(eh * Float64(sin(t) * sin(t_1))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(ew * N[(N[Cos[t$95$1], $MachinePrecision] * (-N[Cos[t], $MachinePrecision])), $MachinePrecision] + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\\
\left|\mathsf{fma}\left(ew, \cos t\_1 \cdot \left(-\cos t\right), eh \cdot \left(\sin t \cdot \sin t\_1\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
Final simplification99.8%
(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(eh * Float64(-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{eh \cdot \left(-\tan t\right)}{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}
Initial program 99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (log (exp (cos t))) (* eh (* (sin t) (sin (atan (* eh (/ (tan t) (- ew))))))))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, log(exp(cos(t))), (eh * (sin(t) * sin(atan((eh * (tan(t) / -ew))))))));
}
function code(eh, ew, t) return abs(fma(ew, log(exp(cos(t))), Float64(eh * Float64(sin(t) * sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Log[N[Exp[N[Cos[t], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + 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]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew, \log \left(e^{\cos t}\right), eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right)\right)\right|
\end{array}
Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-undefine99.7%
Applied egg-rr99.1%
expm1-define99.2%
Simplified99.2%
Taylor expanded in eh around 0 98.9%
log1p-define99.0%
expm1-log1p-u99.1%
add-log-exp98.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))))
(if (or (<= eh -6.4e-148) (not (<= eh 2.4e-173)))
(fabs
(* eh (+ (* (sin t) (sin (atan (/ (* eh (- (tan t))) ew)))) (/ t_1 eh))))
(fabs t_1))))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double tmp;
if ((eh <= -6.4e-148) || !(eh <= 2.4e-173)) {
tmp = fabs((eh * ((sin(t) * sin(atan(((eh * -tan(t)) / ew)))) + (t_1 / eh))));
} else {
tmp = fabs(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 * cos(t)
if ((eh <= (-6.4d-148)) .or. (.not. (eh <= 2.4d-173))) then
tmp = abs((eh * ((sin(t) * sin(atan(((eh * -tan(t)) / ew)))) + (t_1 / eh))))
else
tmp = abs(t_1)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.cos(t);
double tmp;
if ((eh <= -6.4e-148) || !(eh <= 2.4e-173)) {
tmp = Math.abs((eh * ((Math.sin(t) * Math.sin(Math.atan(((eh * -Math.tan(t)) / ew)))) + (t_1 / eh))));
} else {
tmp = Math.abs(t_1);
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.cos(t) tmp = 0 if (eh <= -6.4e-148) or not (eh <= 2.4e-173): tmp = math.fabs((eh * ((math.sin(t) * math.sin(math.atan(((eh * -math.tan(t)) / ew)))) + (t_1 / eh)))) else: tmp = math.fabs(t_1) return tmp
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) tmp = 0.0 if ((eh <= -6.4e-148) || !(eh <= 2.4e-173)) tmp = abs(Float64(eh * Float64(Float64(sin(t) * sin(atan(Float64(Float64(eh * Float64(-tan(t))) / ew)))) + Float64(t_1 / eh)))); else tmp = abs(t_1); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * cos(t); tmp = 0.0; if ((eh <= -6.4e-148) || ~((eh <= 2.4e-173))) tmp = abs((eh * ((sin(t) * sin(atan(((eh * -tan(t)) / ew)))) + (t_1 / eh)))); else tmp = abs(t_1); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -6.4e-148], N[Not[LessEqual[eh, 2.4e-173]], $MachinePrecision]], N[Abs[N[(eh * N[(N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * (-N[Tan[t], $MachinePrecision])), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 / eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[t$95$1], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
\mathbf{if}\;eh \leq -6.4 \cdot 10^{-148} \lor \neg \left(eh \leq 2.4 \cdot 10^{-173}\right):\\
\;\;\;\;\left|eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right) + \frac{t\_1}{eh}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1\right|\\
\end{array}
\end{array}
if eh < -6.39999999999999987e-148 or 2.40000000000000017e-173 < eh Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-undefine99.7%
Applied egg-rr99.3%
expm1-define99.4%
Simplified99.4%
Taylor expanded in eh around 0 99.1%
Taylor expanded in eh around inf 97.1%
if -6.39999999999999987e-148 < eh < 2.40000000000000017e-173Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-undefine99.6%
Applied egg-rr98.7%
expm1-define98.9%
Simplified98.9%
Taylor expanded in ew around inf 89.3%
Final simplification94.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* ew (cos t)))))
(if (<= ew -8.5e-9)
t_1
(if (<= ew -9.2e-166)
(*
(fma eh (/ (* (sin t) (sin (atan (* eh (/ (tan t) ew))))) ew) (cos t))
(- ew))
(if (<= ew 9e-92)
(fabs (* eh (sin t)))
(if (<= ew 7e+105)
(*
ew
(+
(cos t)
(/ (* eh (* (sin t) (sin (atan (/ (* eh (tan t)) ew))))) ew)))
t_1))))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * cos(t)));
double tmp;
if (ew <= -8.5e-9) {
tmp = t_1;
} else if (ew <= -9.2e-166) {
tmp = fma(eh, ((sin(t) * sin(atan((eh * (tan(t) / ew))))) / ew), cos(t)) * -ew;
} else if (ew <= 9e-92) {
tmp = fabs((eh * sin(t)));
} else if (ew <= 7e+105) {
tmp = ew * (cos(t) + ((eh * (sin(t) * sin(atan(((eh * tan(t)) / ew))))) / ew));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(ew * cos(t))) tmp = 0.0 if (ew <= -8.5e-9) tmp = t_1; elseif (ew <= -9.2e-166) tmp = Float64(fma(eh, Float64(Float64(sin(t) * sin(atan(Float64(eh * Float64(tan(t) / ew))))) / ew), cos(t)) * Float64(-ew)); elseif (ew <= 9e-92) tmp = abs(Float64(eh * sin(t))); elseif (ew <= 7e+105) tmp = Float64(ew * Float64(cos(t) + Float64(Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(eh * tan(t)) / ew))))) / ew))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -8.5e-9], t$95$1, If[LessEqual[ew, -9.2e-166], N[(N[(eh * N[(N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + N[Cos[t], $MachinePrecision]), $MachinePrecision] * (-ew)), $MachinePrecision], If[LessEqual[ew, 9e-92], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 7e+105], N[(ew * N[(N[Cos[t], $MachinePrecision] + N[(N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -8.5 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq -9.2 \cdot 10^{-166}:\\
\;\;\;\;\mathsf{fma}\left(eh, \frac{\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)}{ew}, \cos t\right) \cdot \left(-ew\right)\\
\mathbf{elif}\;ew \leq 9 \cdot 10^{-92}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{elif}\;ew \leq 7 \cdot 10^{+105}:\\
\;\;\;\;ew \cdot \left(\cos t + \frac{eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right)}{ew}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -8.5e-9 or 6.99999999999999982e105 < ew Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-undefine99.6%
Applied egg-rr99.4%
expm1-define99.7%
Simplified99.7%
Taylor expanded in ew around inf 90.7%
if -8.5e-9 < ew < -9.19999999999999995e-166Initial program 99.7%
Applied egg-rr73.0%
Taylor expanded in ew around inf 70.6%
sub-neg70.6%
mul-1-neg70.6%
distribute-neg-in70.6%
remove-double-neg70.6%
mul-1-neg70.6%
sub-neg70.6%
associate-/l*70.6%
Simplified70.6%
if -9.19999999999999995e-166 < ew < 9.0000000000000001e-92Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-undefine99.8%
Applied egg-rr98.6%
expm1-define98.6%
Simplified98.6%
Taylor expanded in ew around 0 82.7%
mul-1-neg82.7%
associate-/l*82.7%
distribute-lft-neg-out82.7%
associate-*l*82.7%
*-commutative82.7%
Simplified82.7%
sin-atan39.5%
associate-*r/39.3%
associate-*l/36.8%
hypot-1-def53.1%
associate-*r/53.2%
associate-*l/53.0%
Applied egg-rr53.0%
associate-/l*52.8%
hypot-undefine36.8%
*-commutative36.8%
distribute-lft-neg-in36.8%
*-commutative36.8%
distribute-lft-neg-in36.8%
sqr-neg36.8%
hypot-undefine52.8%
associate-*r/52.8%
*-commutative52.8%
associate-*r/52.7%
Simplified52.7%
Taylor expanded in eh around -inf 82.8%
if 9.0000000000000001e-92 < ew < 6.99999999999999982e105Initial program 99.9%
add-sqr-sqrt82.7%
fabs-sqr82.7%
add-sqr-sqrt83.4%
sub-neg83.4%
Applied egg-rr83.4%
associate-/l*83.4%
fma-undefine83.4%
associate-*r*83.4%
*-commutative83.4%
Simplified83.4%
Taylor expanded in ew around inf 80.8%
Final simplification83.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* ew (cos t)))))
(if (<= ew -1.45e-88)
t_1
(if (<= ew 7e-97)
(fabs (* eh (sin t)))
(if (<= ew 2.3e+105)
(*
ew
(+
(cos t)
(/ (* eh (* (sin t) (sin (atan (/ (* eh (tan t)) ew))))) ew)))
t_1)))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * cos(t)));
double tmp;
if (ew <= -1.45e-88) {
tmp = t_1;
} else if (ew <= 7e-97) {
tmp = fabs((eh * sin(t)));
} else if (ew <= 2.3e+105) {
tmp = ew * (cos(t) + ((eh * (sin(t) * sin(atan(((eh * tan(t)) / ew))))) / ew));
} 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 = abs((ew * cos(t)))
if (ew <= (-1.45d-88)) then
tmp = t_1
else if (ew <= 7d-97) then
tmp = abs((eh * sin(t)))
else if (ew <= 2.3d+105) then
tmp = ew * (cos(t) + ((eh * (sin(t) * sin(atan(((eh * tan(t)) / ew))))) / ew))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((ew * Math.cos(t)));
double tmp;
if (ew <= -1.45e-88) {
tmp = t_1;
} else if (ew <= 7e-97) {
tmp = Math.abs((eh * Math.sin(t)));
} else if (ew <= 2.3e+105) {
tmp = ew * (Math.cos(t) + ((eh * (Math.sin(t) * Math.sin(Math.atan(((eh * Math.tan(t)) / ew))))) / ew));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((ew * math.cos(t))) tmp = 0 if ew <= -1.45e-88: tmp = t_1 elif ew <= 7e-97: tmp = math.fabs((eh * math.sin(t))) elif ew <= 2.3e+105: tmp = ew * (math.cos(t) + ((eh * (math.sin(t) * math.sin(math.atan(((eh * math.tan(t)) / ew))))) / ew)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(ew * cos(t))) tmp = 0.0 if (ew <= -1.45e-88) tmp = t_1; elseif (ew <= 7e-97) tmp = abs(Float64(eh * sin(t))); elseif (ew <= 2.3e+105) tmp = Float64(ew * Float64(cos(t) + Float64(Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(eh * tan(t)) / ew))))) / ew))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((ew * cos(t))); tmp = 0.0; if (ew <= -1.45e-88) tmp = t_1; elseif (ew <= 7e-97) tmp = abs((eh * sin(t))); elseif (ew <= 2.3e+105) tmp = ew * (cos(t) + ((eh * (sin(t) * sin(atan(((eh * tan(t)) / ew))))) / ew)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -1.45e-88], t$95$1, If[LessEqual[ew, 7e-97], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 2.3e+105], N[(ew * N[(N[Cos[t], $MachinePrecision] + N[(N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -1.45 \cdot 10^{-88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 7 \cdot 10^{-97}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{elif}\;ew \leq 2.3 \cdot 10^{+105}:\\
\;\;\;\;ew \cdot \left(\cos t + \frac{eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right)}{ew}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -1.4500000000000001e-88 or 2.2999999999999998e105 < ew Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-undefine99.6%
Applied egg-rr99.4%
expm1-define99.7%
Simplified99.7%
Taylor expanded in ew around inf 85.1%
if -1.4500000000000001e-88 < ew < 7.00000000000000038e-97Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-undefine99.7%
Applied egg-rr98.5%
expm1-define98.5%
Simplified98.5%
Taylor expanded in ew around 0 77.2%
mul-1-neg77.2%
associate-/l*77.2%
distribute-lft-neg-out77.2%
associate-*l*77.2%
*-commutative77.2%
Simplified77.2%
sin-atan35.1%
associate-*r/34.9%
associate-*l/32.0%
hypot-1-def49.7%
associate-*r/49.8%
associate-*l/49.7%
Applied egg-rr49.7%
associate-/l*49.5%
hypot-undefine32.1%
*-commutative32.1%
distribute-lft-neg-in32.1%
*-commutative32.1%
distribute-lft-neg-in32.1%
sqr-neg32.1%
hypot-undefine49.5%
associate-*r/49.4%
*-commutative49.4%
associate-*r/49.4%
Simplified49.4%
Taylor expanded in eh around -inf 77.4%
if 7.00000000000000038e-97 < ew < 2.2999999999999998e105Initial program 99.9%
add-sqr-sqrt82.7%
fabs-sqr82.7%
add-sqr-sqrt83.4%
sub-neg83.4%
Applied egg-rr83.4%
associate-/l*83.4%
fma-undefine83.4%
associate-*r*83.4%
*-commutative83.4%
Simplified83.4%
Taylor expanded in ew around inf 80.8%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -2.9e-90) (not (<= ew 8.4e-81))) (fabs (* ew (cos t))) (fabs (* eh (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.9e-90) || !(ew <= 8.4e-81)) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((eh * 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 ((ew <= (-2.9d-90)) .or. (.not. (ew <= 8.4d-81))) then
tmp = abs((ew * cos(t)))
else
tmp = abs((eh * sin(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.9e-90) || !(ew <= 8.4e-81)) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs((eh * Math.sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2.9e-90) or not (ew <= 8.4e-81): tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs((eh * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.9e-90) || !(ew <= 8.4e-81)) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(eh * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2.9e-90) || ~((ew <= 8.4e-81))) tmp = abs((ew * cos(t))); else tmp = abs((eh * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.9e-90], N[Not[LessEqual[ew, 8.4e-81]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.9 \cdot 10^{-90} \lor \neg \left(ew \leq 8.4 \cdot 10^{-81}\right):\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\end{array}
\end{array}
if ew < -2.89999999999999983e-90 or 8.3999999999999997e-81 < ew Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-undefine99.6%
Applied egg-rr99.5%
expm1-define99.7%
Simplified99.7%
Taylor expanded in ew around inf 80.5%
if -2.89999999999999983e-90 < ew < 8.3999999999999997e-81Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-undefine99.7%
Applied egg-rr98.5%
expm1-define98.5%
Simplified98.5%
Taylor expanded in ew around 0 77.2%
mul-1-neg77.2%
associate-/l*77.2%
distribute-lft-neg-out77.2%
associate-*l*77.2%
*-commutative77.2%
Simplified77.2%
sin-atan35.1%
associate-*r/34.9%
associate-*l/32.0%
hypot-1-def49.7%
associate-*r/49.8%
associate-*l/49.7%
Applied egg-rr49.7%
associate-/l*49.5%
hypot-undefine32.1%
*-commutative32.1%
distribute-lft-neg-in32.1%
*-commutative32.1%
distribute-lft-neg-in32.1%
sqr-neg32.1%
hypot-undefine49.5%
associate-*r/49.4%
*-commutative49.4%
associate-*r/49.4%
Simplified49.4%
Taylor expanded in eh around -inf 77.4%
Final simplification79.2%
(FPCore (eh ew t) :precision binary64 (if (<= ew -4.2e-52) (* ew (- (cos t))) (if (<= ew 1.7e-57) (fabs (* eh (sin t))) (fabs ew))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= -4.2e-52) {
tmp = ew * -cos(t);
} else if (ew <= 1.7e-57) {
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 (ew <= (-4.2d-52)) then
tmp = ew * -cos(t)
else if (ew <= 1.7d-57) 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 (ew <= -4.2e-52) {
tmp = ew * -Math.cos(t);
} else if (ew <= 1.7e-57) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if ew <= -4.2e-52: tmp = ew * -math.cos(t) elif ew <= 1.7e-57: tmp = math.fabs((eh * math.sin(t))) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if (ew <= -4.2e-52) tmp = Float64(ew * Float64(-cos(t))); elseif (ew <= 1.7e-57) 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 (ew <= -4.2e-52) tmp = ew * -cos(t); elseif (ew <= 1.7e-57) tmp = abs((eh * sin(t))); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[ew, -4.2e-52], N[(ew * (-N[Cos[t], $MachinePrecision])), $MachinePrecision], If[LessEqual[ew, 1.7e-57], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -4.2 \cdot 10^{-52}:\\
\;\;\;\;ew \cdot \left(-\cos t\right)\\
\mathbf{elif}\;ew \leq 1.7 \cdot 10^{-57}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if ew < -4.1999999999999997e-52Initial program 99.9%
Applied egg-rr77.0%
Taylor expanded in eh around 0 68.4%
associate-*r*68.4%
mul-1-neg68.4%
Simplified68.4%
if -4.1999999999999997e-52 < ew < 1.70000000000000008e-57Initial program 99.7%
fabs-sub99.7%
sub-neg99.7%
+-commutative99.7%
associate-*l*99.7%
distribute-rgt-neg-in99.7%
fma-define99.8%
Simplified99.7%
expm1-log1p-u99.7%
expm1-undefine99.7%
Applied egg-rr98.6%
expm1-define98.6%
Simplified98.6%
Taylor expanded in ew around 0 74.4%
mul-1-neg74.4%
associate-/l*74.4%
distribute-lft-neg-out74.4%
associate-*l*74.4%
*-commutative74.4%
Simplified74.4%
sin-atan33.8%
associate-*r/33.5%
associate-*l/31.0%
hypot-1-def48.6%
associate-*r/48.7%
associate-*l/48.6%
Applied egg-rr48.6%
associate-/l*48.4%
hypot-undefine31.0%
*-commutative31.0%
distribute-lft-neg-in31.0%
*-commutative31.0%
distribute-lft-neg-in31.0%
sqr-neg31.0%
hypot-undefine48.4%
associate-*r/48.3%
*-commutative48.3%
associate-*r/48.3%
Simplified48.3%
Taylor expanded in eh around -inf 74.6%
if 1.70000000000000008e-57 < ew Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.7%
expm1-undefine99.6%
Applied egg-rr99.5%
expm1-define99.7%
Simplified99.7%
Taylor expanded in t around 0 47.7%
Final simplification65.1%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -1.0) (not (<= t 0.00135))) (* ew (- (cos t))) (fabs ew)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.0) || !(t <= 0.00135)) {
tmp = ew * -cos(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.0d0)) .or. (.not. (t <= 0.00135d0))) then
tmp = ew * -cos(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.0) || !(t <= 0.00135)) {
tmp = ew * -Math.cos(t);
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -1.0) or not (t <= 0.00135): tmp = ew * -math.cos(t) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -1.0) || !(t <= 0.00135)) tmp = Float64(ew * Float64(-cos(t))); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -1.0) || ~((t <= 0.00135))) tmp = ew * -cos(t); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -1.0], N[Not[LessEqual[t, 0.00135]], $MachinePrecision]], N[(ew * (-N[Cos[t], $MachinePrecision])), $MachinePrecision], N[Abs[ew], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1 \lor \neg \left(t \leq 0.00135\right):\\
\;\;\;\;ew \cdot \left(-\cos t\right)\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if t < -1 or 0.0013500000000000001 < t Initial program 99.7%
Applied egg-rr44.4%
Taylor expanded in eh around 0 25.2%
associate-*r*25.2%
mul-1-neg25.2%
Simplified25.2%
if -1 < t < 0.0013500000000000001Initial program 100.0%
fabs-sub100.0%
sub-neg100.0%
+-commutative100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
Simplified99.9%
expm1-log1p-u99.9%
expm1-undefine99.9%
Applied egg-rr99.0%
expm1-define99.0%
Simplified99.0%
Taylor expanded in t around 0 67.8%
Final simplification44.3%
(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%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-undefine99.7%
Applied egg-rr99.1%
expm1-define99.2%
Simplified99.2%
Taylor expanded in t around 0 37.6%
(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 Float64(-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%
Applied egg-rr49.1%
Taylor expanded in t around 0 21.2%
mul-1-neg21.2%
Simplified21.2%
herbie shell --seed 2024157
(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)))))))