
(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) 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.8%
sub-neg99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l*99.8%
add-sqr-sqrt47.6%
sqrt-unprod91.0%
sqr-neg91.0%
sqrt-unprod52.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (/ (* ew (cos t)) (hypot 1.0 (* eh (/ (tan t) ew)))) (* eh (* (sin t) (sin (atan (/ (* t eh) ew))))))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) / hypot(1.0, (eh * (tan(t) / ew)))) + (eh * (sin(t) * sin(atan(((t * eh) / ew)))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) / Math.hypot(1.0, (eh * (Math.tan(t) / ew)))) + (eh * (Math.sin(t) * Math.sin(Math.atan(((t * eh) / ew)))))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) / math.hypot(1.0, (eh * (math.tan(t) / ew)))) + (eh * (math.sin(t) * math.sin(math.atan(((t * eh) / ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) / hypot(1.0, Float64(eh * Float64(tan(t) / ew)))) + Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(t * eh) / ew))))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) / hypot(1.0, (eh * (tan(t) / ew)))) + (eh * (sin(t) * sin(atan(((t * eh) / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(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] + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)} + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{ew}\right)\right)\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l*99.8%
add-sqr-sqrt47.6%
sqrt-unprod91.0%
sqr-neg91.0%
sqrt-unprod52.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Taylor expanded in t around 0 98.9%
Final simplification98.9%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* ew (cos t)) (* eh (* (sin t) (sin (atan (* eh (/ (tan t) ew)))))))))
double code(double eh, double ew, double t) {
return fabs(((ew * cos(t)) + (eh * (sin(t) * sin(atan((eh * (tan(t) / 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 * cos(t)) + (eh * (sin(t) * sin(atan((eh * (tan(t) / ew))))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * Math.cos(t)) + (eh * (Math.sin(t) * Math.sin(Math.atan((eh * (Math.tan(t) / ew))))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.cos(t)) + (eh * (math.sin(t) * math.sin(math.atan((eh * (math.tan(t) / ew))))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * cos(t)) + Float64(eh * Float64(sin(t) * sin(atan(Float64(eh * Float64(tan(t) / ew)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * cos(t)) + (eh * (sin(t) * sin(atan((eh * (tan(t) / ew)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Cos[t], $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|ew \cdot \cos t + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\right)\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l*99.8%
add-sqr-sqrt47.6%
sqrt-unprod91.0%
sqr-neg91.0%
sqrt-unprod52.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 98.1%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -2e+122) (not (<= ew 3.5e-37))) (fabs (* (* ew (cos t)) (cos (atan (* eh (/ (tan t) (- ew))))))) (fabs (+ ew (* eh (* (sin t) (sin (atan (/ (* t eh) ew)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2e+122) || !(ew <= 3.5e-37)) {
tmp = fabs(((ew * cos(t)) * cos(atan((eh * (tan(t) / -ew))))));
} else {
tmp = fabs((ew + (eh * (sin(t) * sin(atan(((t * eh) / 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 <= (-2d+122)) .or. (.not. (ew <= 3.5d-37))) then
tmp = abs(((ew * cos(t)) * cos(atan((eh * (tan(t) / -ew))))))
else
tmp = abs((ew + (eh * (sin(t) * sin(atan(((t * eh) / ew)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2e+122) || !(ew <= 3.5e-37)) {
tmp = Math.abs(((ew * Math.cos(t)) * Math.cos(Math.atan((eh * (Math.tan(t) / -ew))))));
} else {
tmp = Math.abs((ew + (eh * (Math.sin(t) * Math.sin(Math.atan(((t * eh) / ew)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2e+122) or not (ew <= 3.5e-37): tmp = math.fabs(((ew * math.cos(t)) * math.cos(math.atan((eh * (math.tan(t) / -ew)))))) else: tmp = math.fabs((ew + (eh * (math.sin(t) * math.sin(math.atan(((t * eh) / ew))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2e+122) || !(ew <= 3.5e-37)) tmp = abs(Float64(Float64(ew * cos(t)) * cos(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))))); else tmp = abs(Float64(ew + Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(t * eh) / ew))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2e+122) || ~((ew <= 3.5e-37))) tmp = abs(((ew * cos(t)) * cos(atan((eh * (tan(t) / -ew)))))); else tmp = abs((ew + (eh * (sin(t) * sin(atan(((t * eh) / ew))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2e+122], N[Not[LessEqual[ew, 3.5e-37]], $MachinePrecision]], N[Abs[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]], $MachinePrecision], N[Abs[N[(ew + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2 \cdot 10^{+122} \lor \neg \left(ew \leq 3.5 \cdot 10^{-37}\right):\\
\;\;\;\;\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{ew}\right)\right)\right|\\
\end{array}
\end{array}
if ew < -2.00000000000000003e122 or 3.5000000000000001e-37 < ew Initial program 99.8%
Taylor expanded in ew around inf 92.6%
associate-*r*92.6%
*-commutative92.6%
mul-1-neg92.6%
associate-*r/92.6%
distribute-rgt-neg-in92.6%
distribute-neg-frac292.6%
Simplified92.6%
if -2.00000000000000003e122 < ew < 3.5000000000000001e-37Initial program 99.8%
sub-neg99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l*99.8%
add-sqr-sqrt49.3%
sqrt-unprod96.4%
sqr-neg96.4%
sqrt-unprod50.5%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Taylor expanded in t around 0 98.3%
Taylor expanded in t around 0 85.4%
Final simplification88.3%
(FPCore (eh ew t)
:precision binary64
(if (or (<= t -3400.0) (not (<= t 500.0)))
(fabs (* ew (cos (atan (/ (* eh (tan t)) ew)))))
(fabs
(+
ew
(* t (- (* t (* ew -0.5)) (* eh (sin (atan (/ (* t eh) (- ew)))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -3400.0) || !(t <= 500.0)) {
tmp = fabs((ew * cos(atan(((eh * tan(t)) / ew)))));
} else {
tmp = fabs((ew + (t * ((t * (ew * -0.5)) - (eh * sin(atan(((t * eh) / -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 <= (-3400.0d0)) .or. (.not. (t <= 500.0d0))) then
tmp = abs((ew * cos(atan(((eh * tan(t)) / ew)))))
else
tmp = abs((ew + (t * ((t * (ew * (-0.5d0))) - (eh * sin(atan(((t * eh) / -ew))))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -3400.0) || !(t <= 500.0)) {
tmp = Math.abs((ew * Math.cos(Math.atan(((eh * Math.tan(t)) / ew)))));
} else {
tmp = Math.abs((ew + (t * ((t * (ew * -0.5)) - (eh * Math.sin(Math.atan(((t * eh) / -ew))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -3400.0) or not (t <= 500.0): tmp = math.fabs((ew * math.cos(math.atan(((eh * math.tan(t)) / ew))))) else: tmp = math.fabs((ew + (t * ((t * (ew * -0.5)) - (eh * math.sin(math.atan(((t * eh) / -ew)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -3400.0) || !(t <= 500.0)) tmp = abs(Float64(ew * cos(atan(Float64(Float64(eh * tan(t)) / ew))))); else tmp = abs(Float64(ew + Float64(t * Float64(Float64(t * Float64(ew * -0.5)) - Float64(eh * sin(atan(Float64(Float64(t * eh) / Float64(-ew))))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -3400.0) || ~((t <= 500.0))) tmp = abs((ew * cos(atan(((eh * tan(t)) / ew))))); else tmp = abs((ew + (t * ((t * (ew * -0.5)) - (eh * sin(atan(((t * eh) / -ew)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -3400.0], N[Not[LessEqual[t, 500.0]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew + N[(t * N[(N[(t * N[(ew * -0.5), $MachinePrecision]), $MachinePrecision] - N[(eh * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3400 \lor \neg \left(t \leq 500\right):\\
\;\;\;\;\left|ew \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew + t \cdot \left(t \cdot \left(ew \cdot -0.5\right) - eh \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\
\end{array}
\end{array}
if t < -3400 or 500 < t Initial program 99.7%
Taylor expanded in t around 0 13.9%
associate-*r/13.9%
neg-mul-113.9%
distribute-lft-neg-in13.9%
Simplified13.9%
add-sqr-sqrt6.0%
sqrt-unprod13.4%
sqr-neg13.4%
sqrt-unprod7.9%
add-sqr-sqrt13.9%
pow113.9%
Applied egg-rr13.9%
unpow113.9%
Simplified13.9%
if -3400 < t < 500Initial program 100.0%
add-sqr-sqrt46.3%
pow246.3%
Applied egg-rr52.5%
Taylor expanded in t around 0 59.8%
distribute-lft-out59.8%
associate-*r/59.8%
mul-1-neg59.8%
distribute-lft-neg-out59.8%
Simplified59.8%
Taylor expanded in ew around inf 97.7%
Taylor expanded in t around 0 97.7%
associate-*r/97.7%
associate-*r*97.7%
mul-1-neg97.7%
Simplified97.7%
Final simplification56.1%
(FPCore (eh ew t) :precision binary64 (fabs (+ ew (* eh (* (sin t) (sin (atan (/ (* t eh) ew))))))))
double code(double eh, double ew, double t) {
return fabs((ew + (eh * (sin(t) * sin(atan(((t * eh) / 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 + (eh * (sin(t) * sin(atan(((t * eh) / ew)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew + (eh * (Math.sin(t) * Math.sin(Math.atan(((t * eh) / ew)))))));
}
def code(eh, ew, t): return math.fabs((ew + (eh * (math.sin(t) * math.sin(math.atan(((t * eh) / ew)))))))
function code(eh, ew, t) return abs(Float64(ew + Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(t * eh) / ew))))))) end
function tmp = code(eh, ew, t) tmp = abs((ew + (eh * (sin(t) * sin(atan(((t * eh) / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(ew + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{ew}\right)\right)\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l*99.8%
add-sqr-sqrt47.6%
sqrt-unprod91.0%
sqr-neg91.0%
sqrt-unprod52.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Taylor expanded in t around 0 98.9%
Taylor expanded in t around 0 76.6%
Final simplification76.6%
(FPCore (eh ew t)
:precision binary64
(if (or (<= t -31.0) (not (<= t 6200.0)))
(fabs (* ew (/ 1.0 (hypot 1.0 (* (tan t) (/ eh ew))))))
(fabs
(+
ew
(* t (- (* t (* ew -0.5)) (* eh (sin (atan (/ (* t eh) (- ew)))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -31.0) || !(t <= 6200.0)) {
tmp = fabs((ew * (1.0 / hypot(1.0, (tan(t) * (eh / ew))))));
} else {
tmp = fabs((ew + (t * ((t * (ew * -0.5)) - (eh * sin(atan(((t * eh) / -ew))))))));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -31.0) || !(t <= 6200.0)) {
tmp = Math.abs((ew * (1.0 / Math.hypot(1.0, (Math.tan(t) * (eh / ew))))));
} else {
tmp = Math.abs((ew + (t * ((t * (ew * -0.5)) - (eh * Math.sin(Math.atan(((t * eh) / -ew))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -31.0) or not (t <= 6200.0): tmp = math.fabs((ew * (1.0 / math.hypot(1.0, (math.tan(t) * (eh / ew)))))) else: tmp = math.fabs((ew + (t * ((t * (ew * -0.5)) - (eh * math.sin(math.atan(((t * eh) / -ew)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -31.0) || !(t <= 6200.0)) tmp = abs(Float64(ew * Float64(1.0 / hypot(1.0, Float64(tan(t) * Float64(eh / ew)))))); else tmp = abs(Float64(ew + Float64(t * Float64(Float64(t * Float64(ew * -0.5)) - Float64(eh * sin(atan(Float64(Float64(t * eh) / Float64(-ew))))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -31.0) || ~((t <= 6200.0))) tmp = abs((ew * (1.0 / hypot(1.0, (tan(t) * (eh / ew)))))); else tmp = abs((ew + (t * ((t * (ew * -0.5)) - (eh * sin(atan(((t * eh) / -ew)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -31.0], N[Not[LessEqual[t, 6200.0]], $MachinePrecision]], N[Abs[N[(ew * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew + N[(t * N[(N[(t * N[(ew * -0.5), $MachinePrecision]), $MachinePrecision] - N[(eh * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -31 \lor \neg \left(t \leq 6200\right):\\
\;\;\;\;\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew + t \cdot \left(t \cdot \left(ew \cdot -0.5\right) - eh \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\
\end{array}
\end{array}
if t < -31 or 6200 < t Initial program 99.7%
Taylor expanded in t around 0 13.9%
associate-*r/13.9%
neg-mul-113.9%
distribute-lft-neg-in13.9%
Simplified13.9%
cos-atan13.5%
hypot-1-def13.5%
associate-/l*13.5%
add-sqr-sqrt5.9%
sqrt-unprod12.5%
sqr-neg12.5%
sqrt-unprod7.7%
add-sqr-sqrt13.5%
Applied egg-rr13.5%
*-commutative13.5%
associate-*l/13.5%
associate-*r/13.5%
Simplified13.5%
if -31 < t < 6200Initial program 100.0%
add-sqr-sqrt46.3%
pow246.3%
Applied egg-rr52.5%
Taylor expanded in t around 0 59.8%
distribute-lft-out59.8%
associate-*r/59.8%
mul-1-neg59.8%
distribute-lft-neg-out59.8%
Simplified59.8%
Taylor expanded in ew around inf 97.7%
Taylor expanded in t around 0 97.7%
associate-*r/97.7%
associate-*r*97.7%
mul-1-neg97.7%
Simplified97.7%
Final simplification56.0%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (/ 1.0 (hypot 1.0 (* (tan t) (/ eh ew)))))))
double code(double eh, double ew, double t) {
return fabs((ew * (1.0 / hypot(1.0, (tan(t) * (eh / ew))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((ew * (1.0 / Math.hypot(1.0, (Math.tan(t) * (eh / ew))))));
}
def code(eh, ew, t): return math.fabs((ew * (1.0 / math.hypot(1.0, (math.tan(t) * (eh / ew))))))
function code(eh, ew, t) return abs(Float64(ew * Float64(1.0 / hypot(1.0, Float64(tan(t) * Float64(eh / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs((ew * (1.0 / hypot(1.0, (tan(t) * (eh / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 41.9%
associate-*r/41.9%
neg-mul-141.9%
distribute-lft-neg-in41.9%
Simplified41.9%
cos-atan41.5%
hypot-1-def41.6%
associate-/l*41.6%
add-sqr-sqrt19.5%
sqrt-unprod35.5%
sqr-neg35.5%
sqrt-unprod22.1%
add-sqr-sqrt41.6%
Applied egg-rr41.6%
*-commutative41.6%
associate-*l/41.6%
associate-*r/41.6%
Simplified41.6%
(FPCore (eh ew t) :precision binary64 (* (cos (atan (* t (/ eh ew)))) (fabs ew)))
double code(double eh, double ew, double t) {
return cos(atan((t * (eh / ew)))) * 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 = cos(atan((t * (eh / ew)))) * abs(ew)
end function
public static double code(double eh, double ew, double t) {
return Math.cos(Math.atan((t * (eh / ew)))) * Math.abs(ew);
}
def code(eh, ew, t): return math.cos(math.atan((t * (eh / ew)))) * math.fabs(ew)
function code(eh, ew, t) return Float64(cos(atan(Float64(t * Float64(eh / ew)))) * abs(ew)) end
function tmp = code(eh, ew, t) tmp = cos(atan((t * (eh / ew)))) * abs(ew); end
code[eh_, ew_, t_] := N[(N[Cos[N[ArcTan[N[(t * N[(eh / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Abs[ew], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \tan^{-1} \left(t \cdot \frac{eh}{ew}\right) \cdot \left|ew\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 41.9%
associate-*r/41.9%
neg-mul-141.9%
distribute-lft-neg-in41.9%
Simplified41.9%
Taylor expanded in t around 0 40.6%
associate-*r/52.1%
associate-*r*52.1%
mul-1-neg52.1%
Simplified40.6%
add-sqr-sqrt40.4%
pow240.4%
associate-/l*40.4%
Applied egg-rr40.4%
*-un-lft-identity40.4%
unpow240.4%
add-sqr-sqrt40.6%
distribute-lft-neg-out40.6%
associate-/l*40.6%
atan-neg40.6%
associate-/l*40.6%
Applied egg-rr40.6%
*-lft-identity40.6%
fabs-mul40.6%
*-commutative40.6%
rem-square-sqrt40.6%
fabs-sqr40.6%
rem-square-sqrt40.6%
cos-neg40.6%
associate-*r/40.6%
*-commutative40.6%
associate-/l*40.6%
Simplified40.6%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (/ 1.0 (hypot 1.0 (* eh (/ t (- ew))))))))
double code(double eh, double ew, double t) {
return fabs((ew * (1.0 / hypot(1.0, (eh * (t / -ew))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((ew * (1.0 / Math.hypot(1.0, (eh * (t / -ew))))));
}
def code(eh, ew, t): return math.fabs((ew * (1.0 / math.hypot(1.0, (eh * (t / -ew))))))
function code(eh, ew, t) return abs(Float64(ew * Float64(1.0 / hypot(1.0, Float64(eh * Float64(t / Float64(-ew))))))) end
function tmp = code(eh, ew, t) tmp = abs((ew * (1.0 / hypot(1.0, (eh * (t / -ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(eh * N[(t / (-ew)), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, eh \cdot \frac{t}{-ew}\right)}\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 41.9%
associate-*r/41.9%
neg-mul-141.9%
distribute-lft-neg-in41.9%
Simplified41.9%
Taylor expanded in t around 0 40.6%
associate-*r/52.1%
associate-*r*52.1%
mul-1-neg52.1%
Simplified40.6%
cos-atan39.6%
hypot-1-def39.6%
associate-/l*39.7%
Applied egg-rr39.7%
*-commutative39.7%
Simplified39.7%
Final simplification39.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ ew (* -0.5 (* ew (* t t))))))
double code(double eh, double ew, double t) {
return fabs((ew + (-0.5 * (ew * (t * 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 + ((-0.5d0) * (ew * (t * t)))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew + (-0.5 * (ew * (t * t)))));
}
def code(eh, ew, t): return math.fabs((ew + (-0.5 * (ew * (t * t)))))
function code(eh, ew, t) return abs(Float64(ew + Float64(-0.5 * Float64(ew * Float64(t * t))))) end
function tmp = code(eh, ew, t) tmp = abs((ew + (-0.5 * (ew * (t * t))))); end
code[eh_, ew_, t_] := N[Abs[N[(ew + N[(-0.5 * N[(ew * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew + -0.5 \cdot \left(ew \cdot \left(t \cdot t\right)\right)\right|
\end{array}
Initial program 99.8%
add-sqr-sqrt47.0%
pow247.0%
Applied egg-rr56.4%
Taylor expanded in t around 0 32.8%
distribute-lft-out32.8%
associate-*r/32.8%
mul-1-neg32.8%
distribute-lft-neg-out32.8%
Simplified32.8%
Taylor expanded in ew around inf 37.8%
*-commutative37.8%
Simplified37.8%
unpow237.8%
Applied egg-rr37.8%
Final simplification37.8%
herbie shell --seed 2024123
(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)))))))