
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(+
(/ (* ew (sin t)) (hypot 1.0 t_1))
(* (* eh (cos t)) (sin (atan t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs((((ew * sin(t)) / hypot(1.0, t_1)) + ((eh * cos(t)) * sin(atan(t_1)))));
}
public static double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / Math.tan(t);
return Math.abs((((ew * Math.sin(t)) / Math.hypot(1.0, t_1)) + ((eh * Math.cos(t)) * Math.sin(Math.atan(t_1)))));
}
def code(eh, ew, t): t_1 = (eh / ew) / math.tan(t) return math.fabs((((ew * math.sin(t)) / math.hypot(1.0, t_1)) + ((eh * math.cos(t)) * math.sin(math.atan(t_1)))))
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(Float64(Float64(Float64(ew * sin(t)) / hypot(1.0, t_1)) + Float64(Float64(eh * cos(t)) * sin(atan(t_1))))) end
function tmp = code(eh, ew, t) t_1 = (eh / ew) / tan(t); tmp = abs((((ew * sin(t)) / hypot(1.0, t_1)) + ((eh * cos(t)) * sin(atan(t_1))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, t\_1\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t\_1\right|
\end{array}
\end{array}
Initial program 99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
associate-/l/99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/r*99.8%
Simplified99.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (* (* ew (sin t)) (cos (atan (/ eh (* ew t))))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + ((ew * Math.sin(t)) * Math.cos(Math.atan((eh / (ew * t)))))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + ((ew * math.sin(t)) * math.cos(math.atan((eh / (ew * t)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(eh / Float64(ew * t))))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + ((ew * sin(t)) * cos(atan((eh / (ew * t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 98.9%
Final simplification98.9%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* ew (sin t)) (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
return fabs(((ew * sin(t)) + (eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((ew * sin(t)) + (eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * Math.sin(t)) + (eh * (Math.cos(t) * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.sin(t)) + (eh * (math.cos(t) * math.sin(math.atan((eh / (ew * math.tan(t)))))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * sin(t)) + Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t))))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * sin(t)) + (eh * (cos(t) * sin(atan((eh / (ew * tan(t))))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \sin t + eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|
\end{array}
Initial program 99.8%
add-cube-cbrt99.2%
pow399.2%
associate-*l*99.2%
cos-atan99.2%
un-div-inv99.2%
hypot-1-def99.2%
associate-/l/99.2%
*-commutative99.2%
Applied egg-rr99.2%
Taylor expanded in eh around 0 98.0%
Final simplification98.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (sin (atan (/ (/ eh ew) (tan t))))))
(if (or (<= eh -2.6e+120) (not (<= eh 6.3e+86)))
(fabs (* (* eh (cos t)) t_1))
(fabs (+ (* ew (sin t)) (* eh t_1))))))
double code(double eh, double ew, double t) {
double t_1 = sin(atan(((eh / ew) / tan(t))));
double tmp;
if ((eh <= -2.6e+120) || !(eh <= 6.3e+86)) {
tmp = fabs(((eh * cos(t)) * t_1));
} else {
tmp = fabs(((ew * sin(t)) + (eh * t_1)));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = sin(atan(((eh / ew) / tan(t))))
if ((eh <= (-2.6d+120)) .or. (.not. (eh <= 6.3d+86))) then
tmp = abs(((eh * cos(t)) * t_1))
else
tmp = abs(((ew * sin(t)) + (eh * t_1)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.sin(Math.atan(((eh / ew) / Math.tan(t))));
double tmp;
if ((eh <= -2.6e+120) || !(eh <= 6.3e+86)) {
tmp = Math.abs(((eh * Math.cos(t)) * t_1));
} else {
tmp = Math.abs(((ew * Math.sin(t)) + (eh * t_1)));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.sin(math.atan(((eh / ew) / math.tan(t)))) tmp = 0 if (eh <= -2.6e+120) or not (eh <= 6.3e+86): tmp = math.fabs(((eh * math.cos(t)) * t_1)) else: tmp = math.fabs(((ew * math.sin(t)) + (eh * t_1))) return tmp
function code(eh, ew, t) t_1 = sin(atan(Float64(Float64(eh / ew) / tan(t)))) tmp = 0.0 if ((eh <= -2.6e+120) || !(eh <= 6.3e+86)) tmp = abs(Float64(Float64(eh * cos(t)) * t_1)); else tmp = abs(Float64(Float64(ew * sin(t)) + Float64(eh * t_1))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = sin(atan(((eh / ew) / tan(t)))); tmp = 0.0; if ((eh <= -2.6e+120) || ~((eh <= 6.3e+86))) tmp = abs(((eh * cos(t)) * t_1)); else tmp = abs(((ew * sin(t)) + (eh * t_1))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[eh, -2.6e+120], N[Not[LessEqual[eh, 6.3e+86]], $MachinePrecision]], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(eh * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\mathbf{if}\;eh \leq -2.6 \cdot 10^{+120} \lor \neg \left(eh \leq 6.3 \cdot 10^{+86}\right):\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot t\_1\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t + eh \cdot t\_1\right|\\
\end{array}
\end{array}
if eh < -2.5999999999999999e120 or 6.30000000000000023e86 < eh Initial program 99.8%
add-cube-cbrt98.0%
pow398.0%
Applied egg-rr98.0%
Taylor expanded in eh around inf 99.8%
Taylor expanded in eh around inf 93.8%
associate-*r*93.8%
associate-/r*93.8%
Simplified93.8%
if -2.5999999999999999e120 < eh < 6.30000000000000023e86Initial program 99.8%
add-cube-cbrt98.9%
pow398.9%
associate-*l*98.9%
cos-atan98.9%
un-div-inv98.9%
hypot-1-def98.9%
associate-/l/98.9%
*-commutative98.9%
Applied egg-rr98.9%
Taylor expanded in eh around 0 97.6%
Taylor expanded in t around 0 84.9%
associate-/r*84.9%
Simplified84.9%
Final simplification88.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -0.000235) (not (<= t 7.1e-10))) (fabs (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t)))))) (fabs (+ (* ew t) (* eh (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.000235) || !(t <= 7.1e-10)) {
tmp = fabs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))));
} else {
tmp = fabs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t))))))));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-0.000235d0)) .or. (.not. (t <= 7.1d-10))) then
tmp = abs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))
else
tmp = abs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t))))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.000235) || !(t <= 7.1e-10)) {
tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))));
} else {
tmp = Math.abs(((ew * t) + (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -0.000235) or not (t <= 7.1e-10): tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))) else: tmp = math.fabs(((ew * t) + (eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -0.000235) || !(t <= 7.1e-10)) tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))); else tmp = abs(Float64(Float64(ew * t) + Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -0.000235) || ~((t <= 7.1e-10))) tmp = abs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))); else tmp = abs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -0.000235], N[Not[LessEqual[t, 7.1e-10]], $MachinePrecision]], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * t), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.000235 \lor \neg \left(t \leq 7.1 \cdot 10^{-10}\right):\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot t + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\end{array}
\end{array}
if t < -2.34999999999999993e-4 or 7.1000000000000003e-10 < t Initial program 99.6%
add-cube-cbrt98.6%
pow398.6%
Applied egg-rr98.6%
Taylor expanded in eh around inf 95.0%
Taylor expanded in eh around inf 59.3%
associate-*r*59.3%
associate-/r*59.3%
Simplified59.3%
if -2.34999999999999993e-4 < t < 7.1000000000000003e-10Initial program 100.0%
add-cube-cbrt99.4%
pow399.4%
associate-*l*99.4%
cos-atan99.4%
un-div-inv99.4%
hypot-1-def99.4%
associate-/l/99.4%
*-commutative99.4%
Applied egg-rr99.4%
Taylor expanded in eh around 0 98.5%
expm1-log1p-u98.5%
expm1-undefine67.7%
Applied egg-rr67.7%
expm1-define98.5%
Simplified98.5%
Taylor expanded in t around 0 98.5%
Final simplification79.6%
(FPCore (eh ew t) :precision binary64 (if (<= eh -1.45e+170) (fabs (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t)))))) (fabs (+ (* ew (sin t)) (* eh (* (cos t) (sin (atan (/ (/ eh ew) t)))))))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1.45e+170) {
tmp = fabs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))));
} else {
tmp = fabs(((ew * sin(t)) + (eh * (cos(t) * sin(atan(((eh / ew) / t)))))));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if (eh <= (-1.45d+170)) then
tmp = abs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))
else
tmp = abs(((ew * sin(t)) + (eh * (cos(t) * sin(atan(((eh / ew) / t)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1.45e+170) {
tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))));
} else {
tmp = Math.abs(((ew * Math.sin(t)) + (eh * (Math.cos(t) * Math.sin(Math.atan(((eh / ew) / t)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -1.45e+170: tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))) else: tmp = math.fabs(((ew * math.sin(t)) + (eh * (math.cos(t) * math.sin(math.atan(((eh / ew) / t))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -1.45e+170) tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))); else tmp = abs(Float64(Float64(ew * sin(t)) + Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh / ew) / t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -1.45e+170) tmp = abs(((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))); else tmp = abs(((ew * sin(t)) + (eh * (cos(t) * sin(atan(((eh / ew) / t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -1.45e+170], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1.45 \cdot 10^{+170}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t + eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{t}\right)\right)\right|\\
\end{array}
\end{array}
if eh < -1.45e170Initial program 99.7%
add-cube-cbrt98.0%
pow398.1%
Applied egg-rr98.1%
Taylor expanded in eh around inf 99.6%
Taylor expanded in eh around inf 96.3%
associate-*r*96.3%
associate-/r*96.3%
Simplified96.3%
if -1.45e170 < eh Initial program 99.8%
add-cube-cbrt99.1%
pow399.1%
associate-*l*99.1%
cos-atan99.1%
un-div-inv99.1%
hypot-1-def99.1%
associate-/l/99.1%
*-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in eh around 0 98.1%
Taylor expanded in t around 0 91.0%
associate-/r*91.0%
Simplified91.0%
Final simplification91.5%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -2.1) (not (<= t 0.0062))) (fabs (* ew (* (sin t) (cos (atan (/ eh (* ew t))))))) (fabs (+ (* ew t) (* eh (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -2.1) || !(t <= 0.0062)) {
tmp = fabs((ew * (sin(t) * cos(atan((eh / (ew * t)))))));
} else {
tmp = fabs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t))))))));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-2.1d0)) .or. (.not. (t <= 0.0062d0))) then
tmp = abs((ew * (sin(t) * cos(atan((eh / (ew * t)))))))
else
tmp = abs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t))))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -2.1) || !(t <= 0.0062)) {
tmp = Math.abs((ew * (Math.sin(t) * Math.cos(Math.atan((eh / (ew * t)))))));
} else {
tmp = Math.abs(((ew * t) + (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -2.1) or not (t <= 0.0062): tmp = math.fabs((ew * (math.sin(t) * math.cos(math.atan((eh / (ew * t))))))) else: tmp = math.fabs(((ew * t) + (eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -2.1) || !(t <= 0.0062)) tmp = abs(Float64(ew * Float64(sin(t) * cos(atan(Float64(eh / Float64(ew * t))))))); else tmp = abs(Float64(Float64(ew * t) + Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -2.1) || ~((t <= 0.0062))) tmp = abs((ew * (sin(t) * cos(atan((eh / (ew * t))))))); else tmp = abs(((ew * t) + (eh * sin(atan((eh / (ew * tan(t)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -2.1], N[Not[LessEqual[t, 0.0062]], $MachinePrecision]], N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * t), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.1 \lor \neg \left(t \leq 0.0062\right):\\
\;\;\;\;\left|ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot t + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\end{array}
\end{array}
if t < -2.10000000000000009 or 0.00619999999999999978 < t Initial program 99.6%
add-cube-cbrt98.6%
pow398.6%
Applied egg-rr98.6%
Taylor expanded in eh around inf 94.9%
Taylor expanded in eh around 0 44.8%
*-commutative44.8%
associate-/r*44.8%
Simplified44.8%
Taylor expanded in t around 0 45.0%
if -2.10000000000000009 < t < 0.00619999999999999978Initial program 100.0%
add-cube-cbrt99.4%
pow399.4%
associate-*l*99.4%
cos-atan99.4%
un-div-inv99.4%
hypot-1-def99.4%
associate-/l/99.4%
*-commutative99.4%
Applied egg-rr99.4%
Taylor expanded in eh around 0 98.3%
expm1-log1p-u98.3%
expm1-undefine68.2%
Applied egg-rr68.2%
expm1-define98.3%
Simplified98.3%
Taylor expanded in t around 0 97.5%
Final simplification72.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* ew (tan t)))))
(if (or (<= t -690000.0) (not (<= t 0.0054)))
(* (sin t) (/ ew (hypot 1.0 t_1)))
(fabs (* ew (* t (cos (atan t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (ew * tan(t));
double tmp;
if ((t <= -690000.0) || !(t <= 0.0054)) {
tmp = sin(t) * (ew / hypot(1.0, t_1));
} else {
tmp = fabs((ew * (t * cos(atan(t_1)))));
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double t_1 = eh / (ew * Math.tan(t));
double tmp;
if ((t <= -690000.0) || !(t <= 0.0054)) {
tmp = Math.sin(t) * (ew / Math.hypot(1.0, t_1));
} else {
tmp = Math.abs((ew * (t * Math.cos(Math.atan(t_1)))));
}
return tmp;
}
def code(eh, ew, t): t_1 = eh / (ew * math.tan(t)) tmp = 0 if (t <= -690000.0) or not (t <= 0.0054): tmp = math.sin(t) * (ew / math.hypot(1.0, t_1)) else: tmp = math.fabs((ew * (t * math.cos(math.atan(t_1))))) return tmp
function code(eh, ew, t) t_1 = Float64(eh / Float64(ew * tan(t))) tmp = 0.0 if ((t <= -690000.0) || !(t <= 0.0054)) tmp = Float64(sin(t) * Float64(ew / hypot(1.0, t_1))); else tmp = abs(Float64(ew * Float64(t * cos(atan(t_1))))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh / (ew * tan(t)); tmp = 0.0; if ((t <= -690000.0) || ~((t <= 0.0054))) tmp = sin(t) * (ew / hypot(1.0, t_1)); else tmp = abs((ew * (t * cos(atan(t_1))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t, -690000.0], N[Not[LessEqual[t, 0.0054]], $MachinePrecision]], N[(N[Sin[t], $MachinePrecision] * N[(ew / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[(ew * N[(t * N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{ew \cdot \tan t}\\
\mathbf{if}\;t \leq -690000 \lor \neg \left(t \leq 0.0054\right):\\
\;\;\;\;\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \left(t \cdot \cos \tan^{-1} t\_1\right)\right|\\
\end{array}
\end{array}
if t < -6.9e5 or 0.0054000000000000003 < t Initial program 99.6%
add-cube-cbrt98.6%
pow398.6%
Applied egg-rr98.6%
Taylor expanded in eh around inf 94.9%
Taylor expanded in eh around 0 44.7%
*-commutative44.7%
associate-/r*44.7%
Simplified44.7%
fabs-mul44.7%
add-sqr-sqrt20.5%
fabs-sqr20.5%
add-sqr-sqrt21.4%
add-sqr-sqrt11.1%
fabs-sqr11.1%
add-sqr-sqrt21.8%
associate-*r*21.8%
cos-atan21.7%
hypot-1-def21.7%
div-inv21.7%
*-commutative21.7%
associate-*r/21.7%
*-commutative21.7%
Applied egg-rr21.7%
if -6.9e5 < t < 0.0054000000000000003Initial program 100.0%
add-cube-cbrt98.5%
pow398.4%
Applied egg-rr98.4%
Taylor expanded in eh around inf 96.5%
Taylor expanded in eh around 0 35.8%
*-commutative35.8%
associate-/r*35.8%
Simplified35.8%
Taylor expanded in t around 0 35.2%
Final simplification29.0%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (* (sin t) (cos (atan (/ eh (* ew t))))))))
double code(double eh, double ew, double t) {
return fabs((ew * (sin(t) * cos(atan((eh / (ew * t)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((ew * (sin(t) * cos(atan((eh / (ew * t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * (Math.sin(t) * Math.cos(Math.atan((eh / (ew * t)))))));
}
def code(eh, ew, t): return math.fabs((ew * (math.sin(t) * math.cos(math.atan((eh / (ew * t)))))))
function code(eh, ew, t) return abs(Float64(ew * Float64(sin(t) * cos(atan(Float64(eh / Float64(ew * t))))))) end
function tmp = code(eh, ew, t) tmp = abs((ew * (sin(t) * cos(atan((eh / (ew * t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right|
\end{array}
Initial program 99.8%
add-cube-cbrt98.5%
pow398.5%
Applied egg-rr98.5%
Taylor expanded in eh around inf 95.7%
Taylor expanded in eh around 0 39.9%
*-commutative39.9%
associate-/r*39.9%
Simplified39.9%
Taylor expanded in t around 0 40.0%
(FPCore (eh ew t) :precision binary64 (* (sin t) (/ ew (hypot 1.0 (/ eh (* ew (tan t)))))))
double code(double eh, double ew, double t) {
return sin(t) * (ew / hypot(1.0, (eh / (ew * tan(t)))));
}
public static double code(double eh, double ew, double t) {
return Math.sin(t) * (ew / Math.hypot(1.0, (eh / (ew * Math.tan(t)))));
}
def code(eh, ew, t): return math.sin(t) * (ew / math.hypot(1.0, (eh / (ew * math.tan(t)))))
function code(eh, ew, t) return Float64(sin(t) * Float64(ew / hypot(1.0, Float64(eh / Float64(ew * tan(t)))))) end
function tmp = code(eh, ew, t) tmp = sin(t) * (ew / hypot(1.0, (eh / (ew * tan(t))))); end
code[eh_, ew_, t_] := N[(N[Sin[t], $MachinePrecision] * N[(ew / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}
\end{array}
Initial program 99.8%
add-cube-cbrt98.5%
pow398.5%
Applied egg-rr98.5%
Taylor expanded in eh around inf 95.7%
Taylor expanded in eh around 0 39.9%
*-commutative39.9%
associate-/r*39.9%
Simplified39.9%
fabs-mul39.9%
add-sqr-sqrt19.5%
fabs-sqr19.5%
add-sqr-sqrt20.6%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt18.8%
associate-*r*18.8%
cos-atan18.7%
hypot-1-def18.7%
div-inv18.7%
*-commutative18.7%
associate-*r/18.7%
*-commutative18.7%
Applied egg-rr18.7%
Final simplification18.7%
herbie shell --seed 2024119
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))