
(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 9 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%
Applied egg-rr99.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (/ ew (/ (hypot 1.0 (/ eh (* ew (tan t)))) (sin t))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (ew / (hypot(1.0, (eh / (ew * tan(t)))) / sin(t)))));
}
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.hypot(1.0, (eh / (ew * Math.tan(t)))) / Math.sin(t)))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + (ew / (math.hypot(1.0, (eh / (ew * math.tan(t)))) / math.sin(t)))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(ew / Float64(hypot(1.0, Float64(eh / Float64(ew * tan(t)))) / sin(t))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (ew / (hypot(1.0, (eh / (ew * tan(t)))) / sin(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[(ew / N[(N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[t], $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) + \frac{ew}{\frac{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}{\sin t}}\right|
\end{array}
Initial program 99.8%
add-cube-cbrt99.0%
pow399.1%
associate-*l*99.1%
cos-atan99.1%
un-div-inv99.1%
hypot-1-def99.1%
Applied egg-rr99.1%
rem-cube-cbrt99.8%
clear-num99.8%
un-div-inv99.7%
associate-/l/99.7%
Applied egg-rr99.7%
Final simplification99.7%
(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 99.4%
Final simplification99.4%
(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(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / 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[(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]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \sin t + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Initial program 99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
Taylor expanded in ew around inf 98.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ eh (* ew (tan t))))))
(if (or (<= eh -1.25e-74) (not (<= eh 5.6e-158)))
(fabs (* eh (* (cos t) (sin t_1))))
(fabs (* ew (* (sin t) (cos t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * tan(t))));
double tmp;
if ((eh <= -1.25e-74) || !(eh <= 5.6e-158)) {
tmp = fabs((eh * (cos(t) * sin(t_1))));
} else {
tmp = fabs((ew * (sin(t) * cos(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 = atan((eh / (ew * tan(t))))
if ((eh <= (-1.25d-74)) .or. (.not. (eh <= 5.6d-158))) then
tmp = abs((eh * (cos(t) * sin(t_1))))
else
tmp = abs((ew * (sin(t) * cos(t_1))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((eh / (ew * Math.tan(t))));
double tmp;
if ((eh <= -1.25e-74) || !(eh <= 5.6e-158)) {
tmp = Math.abs((eh * (Math.cos(t) * Math.sin(t_1))));
} else {
tmp = Math.abs((ew * (Math.sin(t) * Math.cos(t_1))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan((eh / (ew * math.tan(t)))) tmp = 0 if (eh <= -1.25e-74) or not (eh <= 5.6e-158): tmp = math.fabs((eh * (math.cos(t) * math.sin(t_1)))) else: tmp = math.fabs((ew * (math.sin(t) * math.cos(t_1)))) return tmp
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * tan(t)))) tmp = 0.0 if ((eh <= -1.25e-74) || !(eh <= 5.6e-158)) tmp = abs(Float64(eh * Float64(cos(t) * sin(t_1)))); else tmp = abs(Float64(ew * Float64(sin(t) * cos(t_1)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan((eh / (ew * tan(t)))); tmp = 0.0; if ((eh <= -1.25e-74) || ~((eh <= 5.6e-158))) tmp = abs((eh * (cos(t) * sin(t_1)))); else tmp = abs((ew * (sin(t) * cos(t_1)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[eh, -1.25e-74], N[Not[LessEqual[eh, 5.6e-158]], $MachinePrecision]], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\mathbf{if}\;eh \leq -1.25 \cdot 10^{-74} \lor \neg \left(eh \leq 5.6 \cdot 10^{-158}\right):\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin t\_1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \left(\sin t \cdot \cos t\_1\right)\right|\\
\end{array}
\end{array}
if eh < -1.25e-74 or 5.60000000000000004e-158 < eh Initial program 99.8%
add-cube-cbrt99.5%
pow399.5%
associate-*l*99.5%
cos-atan99.5%
un-div-inv99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
Taylor expanded in ew around 0 83.8%
if -1.25e-74 < eh < 5.60000000000000004e-158Initial program 99.8%
add-cbrt-cube85.2%
pow385.2%
Applied egg-rr85.2%
Taylor expanded in ew around inf 83.0%
*-commutative83.0%
Simplified83.0%
Final simplification83.5%
(FPCore (eh ew t) :precision binary64 (fabs (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs((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((eh * (cos(t) * sin(atan((eh / (ew * tan(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))))))));
}
def code(eh, ew, t): return math.fabs((eh * (math.cos(t) * math.sin(math.atan((eh / (ew * math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs((eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[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]
\begin{array}{l}
\\
\left|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.0%
pow399.1%
associate-*l*99.1%
cos-atan99.1%
un-div-inv99.1%
hypot-1-def99.1%
Applied egg-rr99.1%
Taylor expanded in ew around 0 63.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* ew t))))
(if (or (<= t -0.00021) (not (<= t 7.5e+76)))
(* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t)))))
(fabs (+ (/ (* ew (sin t)) t_1) (* eh (sin (atan t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (ew * t);
double tmp;
if ((t <= -0.00021) || !(t <= 7.5e+76)) {
tmp = (eh * cos(t)) * sin(atan(((eh / ew) / tan(t))));
} else {
tmp = fabs((((ew * sin(t)) / t_1) + (eh * sin(atan(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 = eh / (ew * t)
if ((t <= (-0.00021d0)) .or. (.not. (t <= 7.5d+76))) then
tmp = (eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))
else
tmp = abs((((ew * sin(t)) / t_1) + (eh * sin(atan(t_1)))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = eh / (ew * t);
double tmp;
if ((t <= -0.00021) || !(t <= 7.5e+76)) {
tmp = (eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))));
} else {
tmp = Math.abs((((ew * Math.sin(t)) / t_1) + (eh * Math.sin(Math.atan(t_1)))));
}
return tmp;
}
def code(eh, ew, t): t_1 = eh / (ew * t) tmp = 0 if (t <= -0.00021) or not (t <= 7.5e+76): tmp = (eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))) else: tmp = math.fabs((((ew * math.sin(t)) / t_1) + (eh * math.sin(math.atan(t_1))))) return tmp
function code(eh, ew, t) t_1 = Float64(eh / Float64(ew * t)) tmp = 0.0 if ((t <= -0.00021) || !(t <= 7.5e+76)) tmp = Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))); else tmp = abs(Float64(Float64(Float64(ew * sin(t)) / t_1) + Float64(eh * sin(atan(t_1))))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh / (ew * t); tmp = 0.0; if ((t <= -0.00021) || ~((t <= 7.5e+76))) tmp = (eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))); else tmp = abs((((ew * sin(t)) / t_1) + (eh * sin(atan(t_1))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t, -0.00021], N[Not[LessEqual[t, 7.5e+76]], $MachinePrecision]], 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[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{ew \cdot t}\\
\mathbf{if}\;t \leq -0.00021 \lor \neg \left(t \leq 7.5 \cdot 10^{+76}\right):\\
\;\;\;\;\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{ew \cdot \sin t}{t\_1} + eh \cdot \sin \tan^{-1} t\_1\right|\\
\end{array}
\end{array}
if t < -2.1000000000000001e-4 or 7.4999999999999995e76 < t Initial program 99.7%
add-cube-cbrt98.8%
pow398.9%
associate-*l*98.9%
cos-atan98.9%
un-div-inv98.9%
hypot-1-def98.9%
Applied egg-rr98.9%
rem-cube-cbrt99.7%
add-sqr-sqrt46.0%
fabs-sqr46.0%
add-sqr-sqrt47.0%
Applied egg-rr47.0%
Taylor expanded in eh around inf 25.9%
associate-*r*25.9%
associate-/r*25.9%
Simplified25.9%
if -2.1000000000000001e-4 < t < 7.4999999999999995e76Initial program 99.9%
cos-atan99.9%
un-div-inv99.9%
hypot-1-def99.9%
Applied egg-rr99.9%
Taylor expanded in t around 0 68.7%
Taylor expanded in t around 0 64.0%
Taylor expanded in t around 0 64.0%
Final simplification49.3%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -0.01) (not (<= t 2.1e+78))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (fabs eh)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.01) || !(t <= 2.1e+78)) {
tmp = (eh * cos(t)) * sin(atan(((eh / ew) / tan(t))));
} else {
tmp = fabs(eh);
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-0.01d0)) .or. (.not. (t <= 2.1d+78))) then
tmp = (eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))
else
tmp = abs(eh)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.01) || !(t <= 2.1e+78)) {
tmp = (eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))));
} else {
tmp = Math.abs(eh);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -0.01) or not (t <= 2.1e+78): tmp = (eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))) else: tmp = math.fabs(eh) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -0.01) || !(t <= 2.1e+78)) tmp = Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))); else tmp = abs(eh); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -0.01) || ~((t <= 2.1e+78))) tmp = (eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))); else tmp = abs(eh); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -0.01], N[Not[LessEqual[t, 2.1e+78]], $MachinePrecision]], 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[Abs[eh], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.01 \lor \neg \left(t \leq 2.1 \cdot 10^{+78}\right):\\
\;\;\;\;\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\
\end{array}
\end{array}
if t < -0.0100000000000000002 or 2.1000000000000001e78 < t Initial program 99.7%
add-cube-cbrt98.8%
pow398.9%
associate-*l*98.9%
cos-atan98.9%
un-div-inv98.9%
hypot-1-def98.9%
Applied egg-rr98.9%
rem-cube-cbrt99.7%
add-sqr-sqrt46.0%
fabs-sqr46.0%
add-sqr-sqrt47.0%
Applied egg-rr47.0%
Taylor expanded in eh around inf 25.9%
associate-*r*25.9%
associate-/r*25.9%
Simplified25.9%
if -0.0100000000000000002 < t < 2.1000000000000001e78Initial program 99.9%
add-cube-cbrt99.2%
pow399.2%
associate-*l*99.2%
cos-atan99.2%
un-div-inv99.2%
hypot-1-def99.2%
Applied egg-rr99.2%
Taylor expanded in t around 0 63.3%
*-commutative63.3%
sin-atan21.6%
div-inv21.5%
*-commutative21.5%
hypot-1-def32.3%
*-un-lft-identity32.3%
times-frac32.4%
*-commutative32.4%
Applied egg-rr32.4%
Taylor expanded in eh around inf 63.7%
Final simplification49.1%
(FPCore (eh ew t) :precision binary64 (fabs eh))
double code(double eh, double ew, double t) {
return fabs(eh);
}
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)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(eh);
}
def code(eh, ew, t): return math.fabs(eh)
function code(eh, ew, t) return abs(eh) end
function tmp = code(eh, ew, t) tmp = abs(eh); end
code[eh_, ew_, t_] := N[Abs[eh], $MachinePrecision]
\begin{array}{l}
\\
\left|eh\right|
\end{array}
Initial program 99.8%
add-cube-cbrt99.0%
pow399.1%
associate-*l*99.1%
cos-atan99.1%
un-div-inv99.1%
hypot-1-def99.1%
Applied egg-rr99.1%
Taylor expanded in t around 0 44.0%
*-commutative44.0%
sin-atan16.5%
div-inv16.4%
*-commutative16.4%
hypot-1-def24.4%
*-un-lft-identity24.4%
times-frac24.5%
*-commutative24.5%
Applied egg-rr24.5%
Taylor expanded in eh around inf 44.4%
herbie shell --seed 2024170
(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))))))))