
(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 (* eh (tan t))))
(fabs
(-
(* (cos (atan (/ t_1 ew))) (* ew (cos t)))
(* (* eh (sin t)) (sin (atan (/ t_1 (- ew)))))))))
double code(double eh, double ew, double t) {
double t_1 = eh * tan(t);
return fabs(((cos(atan((t_1 / ew))) * (ew * cos(t))) - ((eh * sin(t)) * sin(atan((t_1 / -ew))))));
}
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 = eh * tan(t)
code = abs(((cos(atan((t_1 / ew))) * (ew * cos(t))) - ((eh * sin(t)) * sin(atan((t_1 / -ew))))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = eh * Math.tan(t);
return Math.abs(((Math.cos(Math.atan((t_1 / ew))) * (ew * Math.cos(t))) - ((eh * Math.sin(t)) * Math.sin(Math.atan((t_1 / -ew))))));
}
def code(eh, ew, t): t_1 = eh * math.tan(t) return math.fabs(((math.cos(math.atan((t_1 / ew))) * (ew * math.cos(t))) - ((eh * math.sin(t)) * math.sin(math.atan((t_1 / -ew))))))
function code(eh, ew, t) t_1 = Float64(eh * tan(t)) return abs(Float64(Float64(cos(atan(Float64(t_1 / ew))) * Float64(ew * cos(t))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(t_1 / Float64(-ew))))))) end
function tmp = code(eh, ew, t) t_1 = eh * tan(t); tmp = abs(((cos(atan((t_1 / ew))) * (ew * cos(t))) - ((eh * sin(t)) * sin(atan((t_1 / -ew)))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[Cos[N[ArcTan[N[(t$95$1 / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(t$95$1 / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \tan t\\
\left|\cos \tan^{-1} \left(\frac{t\_1}{ew}\right) \cdot \left(ew \cdot \cos t\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{t\_1}{-ew}\right)\right|
\end{array}
\end{array}
Initial program 99.9%
add-sqr-sqrt51.1%
sqrt-unprod93.5%
sqr-neg93.5%
sqrt-unprod48.8%
add-sqr-sqrt99.9%
pow199.9%
Applied egg-rr99.9%
unpow199.9%
Simplified99.9%
Final simplification99.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (/ (tan t) ew))))
(fabs
(+
(/ (* ew (cos t)) (hypot 1.0 t_1))
(* eh (* (sin t) (sin (atan t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = eh * (tan(t) / ew);
return fabs((((ew * cos(t)) / hypot(1.0, t_1)) + (eh * (sin(t) * sin(atan(t_1))))));
}
public static double code(double eh, double ew, double t) {
double t_1 = eh * (Math.tan(t) / ew);
return Math.abs((((ew * Math.cos(t)) / Math.hypot(1.0, t_1)) + (eh * (Math.sin(t) * Math.sin(Math.atan(t_1))))));
}
def code(eh, ew, t): t_1 = eh * (math.tan(t) / ew) return math.fabs((((ew * math.cos(t)) / math.hypot(1.0, t_1)) + (eh * (math.sin(t) * math.sin(math.atan(t_1))))))
function code(eh, ew, t) t_1 = Float64(eh * Float64(tan(t) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) / hypot(1.0, t_1)) + Float64(eh * Float64(sin(t) * sin(atan(t_1)))))) end
function tmp = code(eh, ew, t) t_1 = eh * (tan(t) / ew); tmp = abs((((ew * cos(t)) / hypot(1.0, t_1)) + (eh * (sin(t) * sin(atan(t_1)))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \frac{\tan t}{ew}\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, t\_1\right)} + eh \cdot \left(\sin t \cdot \sin \tan^{-1} t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.9%
sub-neg99.9%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l*99.8%
add-sqr-sqrt51.1%
sqrt-unprod93.1%
sqr-neg93.1%
sqrt-unprod48.8%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (/ (tan t) ew))))
(if (or (<= ew -4.1e-155) (not (<= ew 1.12e-170)))
(fabs
(*
ew
(-
(cos t)
(* eh (* (sin t) (/ (sin (atan (* eh (/ (tan t) (- ew))))) ew))))))
(fabs (+ (* eh (* (sin t) (sin (atan t_1)))) (/ ew (hypot 1.0 t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = eh * (tan(t) / ew);
double tmp;
if ((ew <= -4.1e-155) || !(ew <= 1.12e-170)) {
tmp = fabs((ew * (cos(t) - (eh * (sin(t) * (sin(atan((eh * (tan(t) / -ew)))) / ew))))));
} else {
tmp = fabs(((eh * (sin(t) * sin(atan(t_1)))) + (ew / hypot(1.0, t_1))));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double t_1 = eh * (Math.tan(t) / ew);
double tmp;
if ((ew <= -4.1e-155) || !(ew <= 1.12e-170)) {
tmp = Math.abs((ew * (Math.cos(t) - (eh * (Math.sin(t) * (Math.sin(Math.atan((eh * (Math.tan(t) / -ew)))) / ew))))));
} else {
tmp = Math.abs(((eh * (Math.sin(t) * Math.sin(Math.atan(t_1)))) + (ew / Math.hypot(1.0, t_1))));
}
return tmp;
}
def code(eh, ew, t): t_1 = eh * (math.tan(t) / ew) tmp = 0 if (ew <= -4.1e-155) or not (ew <= 1.12e-170): tmp = math.fabs((ew * (math.cos(t) - (eh * (math.sin(t) * (math.sin(math.atan((eh * (math.tan(t) / -ew)))) / ew)))))) else: tmp = math.fabs(((eh * (math.sin(t) * math.sin(math.atan(t_1)))) + (ew / math.hypot(1.0, t_1)))) return tmp
function code(eh, ew, t) t_1 = Float64(eh * Float64(tan(t) / ew)) tmp = 0.0 if ((ew <= -4.1e-155) || !(ew <= 1.12e-170)) tmp = abs(Float64(ew * Float64(cos(t) - Float64(eh * Float64(sin(t) * Float64(sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))) / ew)))))); else tmp = abs(Float64(Float64(eh * Float64(sin(t) * sin(atan(t_1)))) + Float64(ew / hypot(1.0, t_1)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh * (tan(t) / ew); tmp = 0.0; if ((ew <= -4.1e-155) || ~((ew <= 1.12e-170))) tmp = abs((ew * (cos(t) - (eh * (sin(t) * (sin(atan((eh * (tan(t) / -ew)))) / ew)))))); else tmp = abs(((eh * (sin(t) * sin(atan(t_1)))) + (ew / hypot(1.0, t_1)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[ew, -4.1e-155], N[Not[LessEqual[ew, 1.12e-170]], $MachinePrecision]], N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[(N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(ew / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \frac{\tan t}{ew}\\
\mathbf{if}\;ew \leq -4.1 \cdot 10^{-155} \lor \neg \left(ew \leq 1.12 \cdot 10^{-170}\right):\\
\;\;\;\;\left|ew \cdot \left(\cos t - eh \cdot \left(\sin t \cdot \frac{\sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)}{ew}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \left(\sin t \cdot \sin \tan^{-1} t\_1\right) + \frac{ew}{\mathsf{hypot}\left(1, t\_1\right)}\right|\\
\end{array}
\end{array}
if ew < -4.0999999999999998e-155 or 1.12000000000000009e-170 < ew Initial program 99.9%
add-cbrt-cube55.7%
pow355.7%
Applied egg-rr57.2%
Taylor expanded in ew around inf 98.3%
Simplified98.3%
if -4.0999999999999998e-155 < ew < 1.12000000000000009e-170Initial program 99.9%
sub-neg99.9%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.9%
associate-/l*99.9%
add-sqr-sqrt52.3%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod47.5%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
Taylor expanded in t around 0 97.4%
Final simplification98.1%
(FPCore (eh ew t)
:precision binary64
(if (<= eh -6e+203)
(fabs (* (* eh (sin t)) (sin (atan (/ (* t (- eh)) ew)))))
(fabs
(*
ew
(-
(cos t)
(* eh (* (sin t) (/ (sin (atan (* eh (/ (tan t) (- ew))))) ew))))))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -6e+203) {
tmp = fabs(((eh * sin(t)) * sin(atan(((t * -eh) / ew)))));
} else {
tmp = fabs((ew * (cos(t) - (eh * (sin(t) * (sin(atan((eh * (tan(t) / -ew)))) / 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 (eh <= (-6d+203)) then
tmp = abs(((eh * sin(t)) * sin(atan(((t * -eh) / ew)))))
else
tmp = abs((ew * (cos(t) - (eh * (sin(t) * (sin(atan((eh * (tan(t) / -ew)))) / ew))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -6e+203) {
tmp = Math.abs(((eh * Math.sin(t)) * Math.sin(Math.atan(((t * -eh) / ew)))));
} else {
tmp = Math.abs((ew * (Math.cos(t) - (eh * (Math.sin(t) * (Math.sin(Math.atan((eh * (Math.tan(t) / -ew)))) / ew))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -6e+203: tmp = math.fabs(((eh * math.sin(t)) * math.sin(math.atan(((t * -eh) / ew))))) else: tmp = math.fabs((ew * (math.cos(t) - (eh * (math.sin(t) * (math.sin(math.atan((eh * (math.tan(t) / -ew)))) / ew)))))) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -6e+203) tmp = abs(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(t * Float64(-eh)) / ew))))); else tmp = abs(Float64(ew * Float64(cos(t) - Float64(eh * Float64(sin(t) * Float64(sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))) / ew)))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -6e+203) tmp = abs(((eh * sin(t)) * sin(atan(((t * -eh) / ew))))); else tmp = abs((ew * (cos(t) - (eh * (sin(t) * (sin(atan((eh * (tan(t) / -ew)))) / ew)))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -6e+203], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t * (-eh)), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[(N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -6 \cdot 10^{+203}:\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{t \cdot \left(-eh\right)}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \left(\cos t - eh \cdot \left(\sin t \cdot \frac{\sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)}{ew}\right)\right)\right|\\
\end{array}
\end{array}
if eh < -5.9999999999999999e203Initial program 99.8%
Taylor expanded in ew around 0 88.3%
mul-1-neg88.3%
associate-*r*88.3%
distribute-lft-neg-in88.3%
distribute-rgt-neg-in88.3%
mul-1-neg88.3%
associate-*r/88.2%
distribute-rgt-neg-in88.2%
distribute-neg-frac88.2%
Simplified88.2%
Taylor expanded in t around 0 88.3%
associate-*r/88.3%
associate-*r*88.3%
neg-mul-188.3%
Simplified88.3%
if -5.9999999999999999e203 < eh Initial program 99.9%
add-cbrt-cube59.4%
pow359.4%
Applied egg-rr60.2%
Taylor expanded in ew around inf 93.9%
Simplified93.9%
Final simplification93.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -2e+54) (not (<= eh 1.3e+53))) (fabs (* (* eh (sin t)) (sin (atan (/ (* t (- eh)) ew))))) (fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2e+54) || !(eh <= 1.3e+53)) {
tmp = fabs(((eh * sin(t)) * sin(atan(((t * -eh) / ew)))));
} 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 <= (-2d+54)) .or. (.not. (eh <= 1.3d+53))) then
tmp = abs(((eh * sin(t)) * sin(atan(((t * -eh) / ew)))))
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 <= -2e+54) || !(eh <= 1.3e+53)) {
tmp = Math.abs(((eh * Math.sin(t)) * Math.sin(Math.atan(((t * -eh) / ew)))));
} else {
tmp = Math.abs((ew * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -2e+54) or not (eh <= 1.3e+53): tmp = math.fabs(((eh * math.sin(t)) * math.sin(math.atan(((t * -eh) / ew))))) else: tmp = math.fabs((ew * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -2e+54) || !(eh <= 1.3e+53)) tmp = abs(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(t * Float64(-eh)) / ew))))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -2e+54) || ~((eh <= 1.3e+53))) tmp = abs(((eh * sin(t)) * sin(atan(((t * -eh) / ew))))); else tmp = abs((ew * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -2e+54], N[Not[LessEqual[eh, 1.3e+53]], $MachinePrecision]], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t * (-eh)), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -2 \cdot 10^{+54} \lor \neg \left(eh \leq 1.3 \cdot 10^{+53}\right):\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{t \cdot \left(-eh\right)}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if eh < -2.0000000000000002e54 or 1.29999999999999999e53 < eh Initial program 99.9%
Taylor expanded in ew around 0 71.9%
mul-1-neg71.9%
associate-*r*71.9%
distribute-lft-neg-in71.9%
distribute-rgt-neg-in71.9%
mul-1-neg71.9%
associate-*r/71.9%
distribute-rgt-neg-in71.9%
distribute-neg-frac71.9%
Simplified71.9%
Taylor expanded in t around 0 72.0%
associate-*r/72.0%
associate-*r*72.0%
neg-mul-172.0%
Simplified72.0%
if -2.0000000000000002e54 < eh < 1.29999999999999999e53Initial program 99.8%
add-sqr-sqrt50.9%
pow250.9%
Applied egg-rr50.9%
Taylor expanded in ew around inf 83.4%
Final simplification78.4%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -4.6e-5) (not (<= t 0.005))) (fabs (* ew (cos t))) (fabs (+ ew (* (* t eh) (sin (atan (* eh (/ t ew)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -4.6e-5) || !(t <= 0.005)) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((ew + ((t * eh) * sin(atan((eh * (t / 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 <= (-4.6d-5)) .or. (.not. (t <= 0.005d0))) then
tmp = abs((ew * cos(t)))
else
tmp = abs((ew + ((t * eh) * sin(atan((eh * (t / ew)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -4.6e-5) || !(t <= 0.005)) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs((ew + ((t * eh) * Math.sin(Math.atan((eh * (t / ew)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -4.6e-5) or not (t <= 0.005): tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs((ew + ((t * eh) * math.sin(math.atan((eh * (t / ew))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -4.6e-5) || !(t <= 0.005)) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(ew + Float64(Float64(t * eh) * sin(atan(Float64(eh * Float64(t / ew))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -4.6e-5) || ~((t <= 0.005))) tmp = abs((ew * cos(t))); else tmp = abs((ew + ((t * eh) * sin(atan((eh * (t / ew))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -4.6e-5], N[Not[LessEqual[t, 0.005]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew + N[(N[(t * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[(t / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.6 \cdot 10^{-5} \lor \neg \left(t \leq 0.005\right):\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew + \left(t \cdot eh\right) \cdot \sin \tan^{-1} \left(eh \cdot \frac{t}{ew}\right)\right|\\
\end{array}
\end{array}
if t < -4.6e-5 or 0.0050000000000000001 < t Initial program 99.7%
add-sqr-sqrt53.9%
pow253.9%
Applied egg-rr53.9%
Taylor expanded in ew around inf 54.0%
if -4.6e-5 < t < 0.0050000000000000001Initial program 100.0%
add-sqr-sqrt46.2%
pow246.2%
Applied egg-rr46.2%
Taylor expanded in t around 0 98.7%
associate-*r*98.7%
associate-*r/98.7%
Simplified98.7%
Taylor expanded in t around 0 98.7%
Final simplification74.6%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (cos t))))
double code(double eh, double ew, double t) {
return fabs((ew * cos(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)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.cos(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.cos(t)))
function code(eh, ew, t) return abs(Float64(ew * cos(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * cos(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \cos t\right|
\end{array}
Initial program 99.9%
add-sqr-sqrt50.3%
pow250.3%
Applied egg-rr50.3%
Taylor expanded in ew around inf 61.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -80000000.0) (not (<= t 2.3e+57))) (* ew (cos t)) (fabs ew)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -80000000.0) || !(t <= 2.3e+57)) {
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 <= (-80000000.0d0)) .or. (.not. (t <= 2.3d+57))) 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 <= -80000000.0) || !(t <= 2.3e+57)) {
tmp = ew * Math.cos(t);
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -80000000.0) or not (t <= 2.3e+57): tmp = ew * math.cos(t) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -80000000.0) || !(t <= 2.3e+57)) tmp = Float64(ew * cos(t)); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -80000000.0) || ~((t <= 2.3e+57))) tmp = ew * cos(t); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -80000000.0], N[Not[LessEqual[t, 2.3e+57]], $MachinePrecision]], N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision], N[Abs[ew], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -80000000 \lor \neg \left(t \leq 2.3 \cdot 10^{+57}\right):\\
\;\;\;\;ew \cdot \cos t\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if t < -8e7 or 2.2999999999999999e57 < t Initial program 99.7%
add-sqr-sqrt56.3%
pow256.3%
Applied egg-rr56.3%
Taylor expanded in ew around inf 53.7%
*-un-lft-identity53.7%
add-sqr-sqrt29.5%
fabs-sqr29.5%
add-sqr-sqrt30.3%
*-commutative30.3%
Applied egg-rr30.3%
if -8e7 < t < 2.2999999999999999e57Initial program 100.0%
add-sqr-sqrt44.6%
pow244.6%
Applied egg-rr44.6%
Taylor expanded in t around 0 64.0%
Final simplification47.5%
(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.9%
add-sqr-sqrt50.3%
pow250.3%
Applied egg-rr50.3%
Taylor expanded in t around 0 39.0%
(FPCore (eh ew t) :precision binary64 (if (<= ew -1e-310) (- ew) ew))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= -1e-310) {
tmp = -ew;
} else {
tmp = 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 <= (-1d-310)) then
tmp = -ew
else
tmp = ew
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (ew <= -1e-310) {
tmp = -ew;
} else {
tmp = ew;
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if ew <= -1e-310: tmp = -ew else: tmp = ew return tmp
function code(eh, ew, t) tmp = 0.0 if (ew <= -1e-310) tmp = Float64(-ew); else tmp = ew; end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (ew <= -1e-310) tmp = -ew; else tmp = ew; end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[ew, -1e-310], (-ew), ew]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1 \cdot 10^{-310}:\\
\;\;\;\;-ew\\
\mathbf{else}:\\
\;\;\;\;ew\\
\end{array}
\end{array}
if ew < -9.999999999999969e-311Initial program 99.9%
add-sqr-sqrt26.8%
pow226.8%
Applied egg-rr26.8%
Taylor expanded in t around 0 41.5%
add-sqr-sqrt41.2%
pow241.2%
Applied egg-rr41.2%
unpow241.2%
add-sqr-sqrt41.5%
neg-fabs41.5%
add-sqr-sqrt41.2%
fabs-sqr41.2%
add-sqr-sqrt41.5%
neg-sub041.5%
Applied egg-rr41.5%
neg-sub041.5%
Simplified41.5%
if -9.999999999999969e-311 < ew Initial program 99.8%
add-sqr-sqrt77.4%
pow277.4%
Applied egg-rr77.4%
Taylor expanded in t around 0 36.0%
add-sqr-sqrt35.8%
pow235.8%
Applied egg-rr35.8%
Taylor expanded in ew around 0 36.0%
rem-square-sqrt35.8%
fabs-sqr35.8%
rem-square-sqrt36.0%
Simplified36.0%
(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.9%
add-sqr-sqrt50.3%
pow250.3%
Applied egg-rr50.3%
Taylor expanded in t around 0 39.0%
add-sqr-sqrt38.7%
pow238.7%
Applied egg-rr38.7%
Taylor expanded in ew around 0 39.0%
rem-square-sqrt16.6%
fabs-sqr16.6%
rem-square-sqrt17.7%
Simplified17.7%
herbie shell --seed 2024131
(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)))))))