
(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 (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}
Initial program 99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(+
(* (* eh (cos t)) (sin (atan t_1)))
(/ (* ew (sin t)) (hypot 1.0 t_1))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs((((eh * cos(t)) * sin(atan(t_1))) + ((ew * sin(t)) / hypot(1.0, t_1))));
}
public static double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / Math.tan(t);
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(t_1))) + ((ew * Math.sin(t)) / Math.hypot(1.0, t_1))));
}
def code(eh, ew, t): t_1 = (eh / ew) / math.tan(t) return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(t_1))) + ((ew * math.sin(t)) / math.hypot(1.0, t_1))))
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(t_1))) + Float64(Float64(ew * sin(t)) / hypot(1.0, t_1)))) end
function tmp = code(eh, ew, t) t_1 = (eh / ew) / tan(t); tmp = abs((((eh * cos(t)) * sin(atan(t_1))) + ((ew * sin(t)) / hypot(1.0, 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[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t\_1 + \frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, t\_1\right)}\right|
\end{array}
\end{array}
Initial program 99.8%
associate-/l/99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
(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%
associate-/l/99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in ew around inf 98.3%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -6.6e-78) (not (<= ew 3.1e+25))) (fabs (+ (* ew (sin t)) (* eh (sin (atan (/ (/ eh ew) (tan t))))))) (fabs (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -6.6e-78) || !(ew <= 3.1e+25)) {
tmp = fabs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(t)))))));
} else {
tmp = fabs((eh * (cos(t) * 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 ((ew <= (-6.6d-78)) .or. (.not. (ew <= 3.1d+25))) then
tmp = abs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(t)))))))
else
tmp = abs((eh * (cos(t) * 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 ((ew <= -6.6e-78) || !(ew <= 3.1e+25)) {
tmp = Math.abs(((ew * Math.sin(t)) + (eh * Math.sin(Math.atan(((eh / ew) / Math.tan(t)))))));
} else {
tmp = Math.abs((eh * (Math.cos(t) * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -6.6e-78) or not (ew <= 3.1e+25): tmp = math.fabs(((ew * math.sin(t)) + (eh * math.sin(math.atan(((eh / ew) / math.tan(t))))))) else: tmp = math.fabs((eh * (math.cos(t) * math.sin(math.atan((eh / (ew * math.tan(t)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -6.6e-78) || !(ew <= 3.1e+25)) tmp = abs(Float64(Float64(ew * sin(t)) + Float64(eh * sin(atan(Float64(Float64(eh / ew) / tan(t))))))); else tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -6.6e-78) || ~((ew <= 3.1e+25))) tmp = abs(((ew * sin(t)) + (eh * sin(atan(((eh / ew) / tan(t))))))); else tmp = abs((eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -6.6e-78], N[Not[LessEqual[ew, 3.1e+25]], $MachinePrecision]], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -6.6 \cdot 10^{-78} \lor \neg \left(ew \leq 3.1 \cdot 10^{+25}\right):\\
\;\;\;\;\left|ew \cdot \sin t + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|\\
\end{array}
\end{array}
if ew < -6.59999999999999963e-78 or 3.0999999999999998e25 < ew Initial program 99.8%
associate-/l/99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in t around 0 87.3%
Taylor expanded in ew around inf 86.7%
if -6.59999999999999963e-78 < ew < 3.0999999999999998e25Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 87.4%
Final simplification87.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -3e+38) (not (<= ew 1.05e+190))) (fabs (* ew (sin t))) (fabs (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -3e+38) || !(ew <= 1.05e+190)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs((eh * (cos(t) * 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 ((ew <= (-3d+38)) .or. (.not. (ew <= 1.05d+190))) then
tmp = abs((ew * sin(t)))
else
tmp = abs((eh * (cos(t) * 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 ((ew <= -3e+38) || !(ew <= 1.05e+190)) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = Math.abs((eh * (Math.cos(t) * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -3e+38) or not (ew <= 1.05e+190): tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs((eh * (math.cos(t) * math.sin(math.atan((eh / (ew * math.tan(t)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -3e+38) || !(ew <= 1.05e+190)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -3e+38) || ~((ew <= 1.05e+190))) tmp = abs((ew * sin(t))); else tmp = abs((eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -3e+38], N[Not[LessEqual[ew, 1.05e+190]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -3 \cdot 10^{+38} \lor \neg \left(ew \leq 1.05 \cdot 10^{+190}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|\\
\end{array}
\end{array}
if ew < -3.0000000000000001e38 or 1.05e190 < ew Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-cube-cbrt97.7%
pow397.8%
Applied egg-rr40.4%
Taylor expanded in ew around inf 26.9%
*-commutative26.9%
Simplified26.9%
add-sqr-sqrt26.3%
sqrt-unprod38.3%
pow238.3%
*-commutative38.3%
Applied egg-rr38.3%
unpow238.3%
rem-sqrt-square75.8%
Simplified75.8%
if -3.0000000000000001e38 < ew < 1.05e190Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 79.1%
Final simplification78.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -1.2e-18) (not (<= t 1.9e-55))) (fabs (* ew (sin t))) (fabs (* eh (sin (atan (/ eh (* ew t))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.2e-18) || !(t <= 1.9e-55)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs((eh * 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 ((t <= (-1.2d-18)) .or. (.not. (t <= 1.9d-55))) then
tmp = abs((ew * sin(t)))
else
tmp = abs((eh * sin(atan((eh / (ew * t))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.2e-18) || !(t <= 1.9e-55)) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = Math.abs((eh * Math.sin(Math.atan((eh / (ew * t))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -1.2e-18) or not (t <= 1.9e-55): tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs((eh * math.sin(math.atan((eh / (ew * t)))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -1.2e-18) || !(t <= 1.9e-55)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(eh * sin(atan(Float64(eh / Float64(ew * t)))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -1.2e-18) || ~((t <= 1.9e-55))) tmp = abs((ew * sin(t))); else tmp = abs((eh * sin(atan((eh / (ew * t)))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -1.2e-18], N[Not[LessEqual[t, 1.9e-55]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.2 \cdot 10^{-18} \lor \neg \left(t \leq 1.9 \cdot 10^{-55}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|\\
\end{array}
\end{array}
if t < -1.19999999999999997e-18 or 1.8999999999999998e-55 < t Initial program 99.7%
fma-define99.7%
associate-/l/99.7%
associate-*l*99.7%
associate-/l/99.7%
Simplified99.7%
add-cube-cbrt97.8%
pow397.9%
Applied egg-rr45.4%
Taylor expanded in ew around inf 19.4%
*-commutative19.4%
Simplified19.4%
add-sqr-sqrt18.5%
sqrt-unprod25.3%
pow225.3%
*-commutative25.3%
Applied egg-rr25.3%
unpow225.3%
rem-sqrt-square45.9%
Simplified45.9%
if -1.19999999999999997e-18 < t < 1.8999999999999998e-55Initial program 100.0%
fma-define100.0%
associate-/l/100.0%
associate-*l*100.0%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in t around 0 76.2%
Taylor expanded in t around 0 76.2%
Final simplification58.1%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -4.2e-156) (not (<= t 4e-77))) (fabs (* ew (sin t))) (* eh (sin (atan (/ (/ eh t) ew))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -4.2e-156) || !(t <= 4e-77)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = 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.2d-156)) .or. (.not. (t <= 4d-77))) then
tmp = abs((ew * sin(t)))
else
tmp = 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.2e-156) || !(t <= 4e-77)) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = eh * Math.sin(Math.atan(((eh / t) / ew)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -4.2e-156) or not (t <= 4e-77): tmp = math.fabs((ew * math.sin(t))) else: tmp = eh * math.sin(math.atan(((eh / t) / ew))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -4.2e-156) || !(t <= 4e-77)) tmp = abs(Float64(ew * sin(t))); else tmp = Float64(eh * sin(atan(Float64(Float64(eh / t) / ew)))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -4.2e-156) || ~((t <= 4e-77))) tmp = abs((ew * sin(t))); else tmp = eh * sin(atan(((eh / t) / ew))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -4.2e-156], N[Not[LessEqual[t, 4e-77]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(eh * N[Sin[N[ArcTan[N[(N[(eh / t), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.2 \cdot 10^{-156} \lor \neg \left(t \leq 4 \cdot 10^{-77}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\\
\end{array}
\end{array}
if t < -4.20000000000000025e-156 or 3.9999999999999997e-77 < t Initial program 99.7%
fma-define99.7%
associate-/l/99.7%
associate-*l*99.7%
associate-/l/99.7%
Simplified99.7%
add-cube-cbrt97.8%
pow397.8%
Applied egg-rr42.6%
Taylor expanded in ew around inf 18.5%
*-commutative18.5%
Simplified18.5%
add-sqr-sqrt17.5%
sqrt-unprod25.6%
pow225.6%
*-commutative25.6%
Applied egg-rr25.6%
unpow225.6%
rem-sqrt-square44.6%
Simplified44.6%
if -4.20000000000000025e-156 < t < 3.9999999999999997e-77Initial program 100.0%
fma-define100.0%
associate-/l/100.0%
associate-*l*100.0%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in t around 0 82.0%
Taylor expanded in t around 0 82.0%
add-sqr-sqrt81.5%
pow281.5%
*-commutative81.5%
Applied egg-rr81.5%
add-sqr-sqrt43.7%
fabs-sqr43.7%
add-sqr-sqrt43.7%
pow243.7%
add-sqr-sqrt44.8%
*-commutative44.8%
associate-/r*44.8%
Applied egg-rr44.8%
Final simplification44.7%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (sin t))))
double code(double eh, double ew, double t) {
return fabs((ew * sin(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)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.sin(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.sin(t)))
function code(eh, ew, t) return abs(Float64(ew * sin(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * sin(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \sin t\right|
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-cube-cbrt97.8%
pow397.8%
Applied egg-rr44.8%
Taylor expanded in ew around inf 16.3%
*-commutative16.3%
Simplified16.3%
add-sqr-sqrt15.4%
sqrt-unprod23.6%
pow223.6%
*-commutative23.6%
Applied egg-rr23.6%
unpow223.6%
rem-sqrt-square38.6%
Simplified38.6%
(FPCore (eh ew t) :precision binary64 (* ew (sin t)))
double code(double eh, double ew, double t) {
return ew * sin(t);
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = ew * sin(t)
end function
public static double code(double eh, double ew, double t) {
return ew * Math.sin(t);
}
def code(eh, ew, t): return ew * math.sin(t)
function code(eh, ew, t) return Float64(ew * sin(t)) end
function tmp = code(eh, ew, t) tmp = ew * sin(t); end
code[eh_, ew_, t_] := N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
ew \cdot \sin t
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-cube-cbrt97.8%
pow397.8%
Applied egg-rr44.8%
Taylor expanded in ew around inf 16.3%
*-commutative16.3%
Simplified16.3%
Final simplification16.3%
(FPCore (eh ew t) :precision binary64 (* ew t))
double code(double eh, double ew, double t) {
return 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 = ew * t
end function
public static double code(double eh, double ew, double t) {
return ew * t;
}
def code(eh, ew, t): return ew * t
function code(eh, ew, t) return Float64(ew * t) end
function tmp = code(eh, ew, t) tmp = ew * t; end
code[eh_, ew_, t_] := N[(ew * t), $MachinePrecision]
\begin{array}{l}
\\
ew \cdot t
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
add-cube-cbrt97.8%
pow397.8%
Applied egg-rr44.8%
Taylor expanded in ew around inf 16.3%
*-commutative16.3%
Simplified16.3%
Taylor expanded in t around 0 8.1%
*-commutative8.1%
Simplified8.1%
Final simplification8.1%
herbie shell --seed 2024113
(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))))))))