
(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 12 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 (* (tan t) ew))))) (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 / (tan(t) * ew)));
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 / (tan(t) * ew)))
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 / (Math.tan(t) * ew)));
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 / (math.tan(t) * ew))) 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(eh / Float64(tan(t) * ew))) 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 / (tan(t) * ew))); 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[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $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{eh}{\tan t \cdot ew}\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%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f6499.8
Applied rewrites99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh (tan t)) ew))
(t_2 (* eh (cos t)))
(t_3 (* ew (sin t)))
(t_4 (fabs (* t_2 (sin (atan (/ t_2 t_3)))))))
(if (<= eh -3.5e+136)
t_4
(if (<= eh -3.7e-112)
(fabs
(+
(* t_2 (sin (atan (/ (/ eh ew) t))))
(* t_3 (cos (atan (/ (/ eh ew) (tan t)))))))
(if (<= eh 180000.0)
(fabs (/ (fma (* (cos t) t_1) eh (* (sin t) ew)) (cosh (asinh t_1))))
t_4)))))
double code(double eh, double ew, double t) {
double t_1 = (eh / tan(t)) / ew;
double t_2 = eh * cos(t);
double t_3 = ew * sin(t);
double t_4 = fabs((t_2 * sin(atan((t_2 / t_3)))));
double tmp;
if (eh <= -3.5e+136) {
tmp = t_4;
} else if (eh <= -3.7e-112) {
tmp = fabs(((t_2 * sin(atan(((eh / ew) / t)))) + (t_3 * cos(atan(((eh / ew) / tan(t)))))));
} else if (eh <= 180000.0) {
tmp = fabs((fma((cos(t) * t_1), eh, (sin(t) * ew)) / cosh(asinh(t_1))));
} else {
tmp = t_4;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / tan(t)) / ew) t_2 = Float64(eh * cos(t)) t_3 = Float64(ew * sin(t)) t_4 = abs(Float64(t_2 * sin(atan(Float64(t_2 / t_3))))) tmp = 0.0 if (eh <= -3.5e+136) tmp = t_4; elseif (eh <= -3.7e-112) tmp = abs(Float64(Float64(t_2 * sin(atan(Float64(Float64(eh / ew) / t)))) + Float64(t_3 * cos(atan(Float64(Float64(eh / ew) / tan(t))))))); elseif (eh <= 180000.0) tmp = abs(Float64(fma(Float64(cos(t) * t_1), eh, Float64(sin(t) * ew)) / cosh(asinh(t_1)))); else tmp = t_4; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Abs[N[(t$95$2 * N[Sin[N[ArcTan[N[(t$95$2 / t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -3.5e+136], t$95$4, If[LessEqual[eh, -3.7e-112], N[Abs[N[(N[(t$95$2 * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(t$95$3 * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 180000.0], N[Abs[N[(N[(N[(N[Cos[t], $MachinePrecision] * t$95$1), $MachinePrecision] * eh + N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$4]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{\tan t}}{ew}\\
t_2 := eh \cdot \cos t\\
t_3 := ew \cdot \sin t\\
t_4 := \left|t\_2 \cdot \sin \tan^{-1} \left(\frac{t\_2}{t\_3}\right)\right|\\
\mathbf{if}\;eh \leq -3.5 \cdot 10^{+136}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;eh \leq -3.7 \cdot 10^{-112}:\\
\;\;\;\;\left|t\_2 \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{t}\right) + t\_3 \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{elif}\;eh \leq 180000:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\cos t \cdot t\_1, eh, \sin t \cdot ew\right)}{\cosh \sinh^{-1} t\_1}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if eh < -3.50000000000000001e136 or 1.8e5 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6491.5
Applied rewrites91.5%
if -3.50000000000000001e136 < eh < -3.6999999999999998e-112Initial program 99.8%
Taylor expanded in t around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
if -3.6999999999999998e-112 < eh < 1.8e5Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites97.3%
Final simplification95.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh (tan t)) ew)) (t_2 (* eh (cos t))))
(if (or (<= eh -1.55e+59) (not (<= eh 180000.0)))
(fabs (* t_2 (sin (atan (/ t_2 (* ew (sin t)))))))
(fabs (/ (fma (* (cos t) t_1) eh (* (sin t) ew)) (cosh (asinh t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / tan(t)) / ew;
double t_2 = eh * cos(t);
double tmp;
if ((eh <= -1.55e+59) || !(eh <= 180000.0)) {
tmp = fabs((t_2 * sin(atan((t_2 / (ew * sin(t)))))));
} else {
tmp = fabs((fma((cos(t) * t_1), eh, (sin(t) * ew)) / cosh(asinh(t_1))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / tan(t)) / ew) t_2 = Float64(eh * cos(t)) tmp = 0.0 if ((eh <= -1.55e+59) || !(eh <= 180000.0)) tmp = abs(Float64(t_2 * sin(atan(Float64(t_2 / Float64(ew * sin(t))))))); else tmp = abs(Float64(fma(Float64(cos(t) * t_1), eh, Float64(sin(t) * ew)) / cosh(asinh(t_1)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -1.55e+59], N[Not[LessEqual[eh, 180000.0]], $MachinePrecision]], N[Abs[N[(t$95$2 * N[Sin[N[ArcTan[N[(t$95$2 / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[Cos[t], $MachinePrecision] * t$95$1), $MachinePrecision] * eh + N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{\tan t}}{ew}\\
t_2 := eh \cdot \cos t\\
\mathbf{if}\;eh \leq -1.55 \cdot 10^{+59} \lor \neg \left(eh \leq 180000\right):\\
\;\;\;\;\left|t\_2 \cdot \sin \tan^{-1} \left(\frac{t\_2}{ew \cdot \sin t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\cos t \cdot t\_1, eh, \sin t \cdot ew\right)}{\cosh \sinh^{-1} t\_1}\right|\\
\end{array}
\end{array}
if eh < -1.55000000000000007e59 or 1.8e5 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6488.2
Applied rewrites88.2%
if -1.55000000000000007e59 < eh < 1.8e5Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites94.0%
Final simplification91.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (cos t))))
(if (or (<= eh -1.55e+59) (not (<= eh 180000.0)))
(fabs (* t_1 (sin (atan (/ t_1 (* ew (sin t)))))))
(fabs
(/
(fma (sin t) ew (* (/ (* (/ eh ew) eh) (tan t)) (cos t)))
(cosh (asinh (/ (/ eh (tan t)) ew))))))))
double code(double eh, double ew, double t) {
double t_1 = eh * cos(t);
double tmp;
if ((eh <= -1.55e+59) || !(eh <= 180000.0)) {
tmp = fabs((t_1 * sin(atan((t_1 / (ew * sin(t)))))));
} else {
tmp = fabs((fma(sin(t), ew, ((((eh / ew) * eh) / tan(t)) * cos(t))) / cosh(asinh(((eh / tan(t)) / ew)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh * cos(t)) tmp = 0.0 if ((eh <= -1.55e+59) || !(eh <= 180000.0)) tmp = abs(Float64(t_1 * sin(atan(Float64(t_1 / Float64(ew * sin(t))))))); else tmp = abs(Float64(fma(sin(t), ew, Float64(Float64(Float64(Float64(eh / ew) * eh) / tan(t)) * cos(t))) / cosh(asinh(Float64(Float64(eh / tan(t)) / ew))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -1.55e+59], N[Not[LessEqual[eh, 180000.0]], $MachinePrecision]], N[Abs[N[(t$95$1 * N[Sin[N[ArcTan[N[(t$95$1 / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * ew + N[(N[(N[(N[(eh / ew), $MachinePrecision] * eh), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \cos t\\
\mathbf{if}\;eh \leq -1.55 \cdot 10^{+59} \lor \neg \left(eh \leq 180000\right):\\
\;\;\;\;\left|t\_1 \cdot \sin \tan^{-1} \left(\frac{t\_1}{ew \cdot \sin t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, ew, \frac{\frac{eh}{ew} \cdot eh}{\tan t} \cdot \cos t\right)}{\cosh \sinh^{-1} \left(\frac{\frac{eh}{\tan t}}{ew}\right)}\right|\\
\end{array}
\end{array}
if eh < -1.55000000000000007e59 or 1.8e5 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6488.2
Applied rewrites88.2%
if -1.55000000000000007e59 < eh < 1.8e5Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
associate-*l/N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
Applied rewrites92.2%
Final simplification90.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh (tan t)) ew)) (t_2 (* eh (cos t))))
(if (or (<= eh -6.3e-13) (not (<= eh 3.65e-28)))
(fabs (* t_2 (sin (atan (/ t_2 (* ew (sin t)))))))
(fabs
(/
(fma (* (cos t) t_1) eh (* (sin t) ew))
(sqrt (+ 1.0 (pow t_1 2.0))))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / tan(t)) / ew;
double t_2 = eh * cos(t);
double tmp;
if ((eh <= -6.3e-13) || !(eh <= 3.65e-28)) {
tmp = fabs((t_2 * sin(atan((t_2 / (ew * sin(t)))))));
} else {
tmp = fabs((fma((cos(t) * t_1), eh, (sin(t) * ew)) / sqrt((1.0 + pow(t_1, 2.0)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / tan(t)) / ew) t_2 = Float64(eh * cos(t)) tmp = 0.0 if ((eh <= -6.3e-13) || !(eh <= 3.65e-28)) tmp = abs(Float64(t_2 * sin(atan(Float64(t_2 / Float64(ew * sin(t))))))); else tmp = abs(Float64(fma(Float64(cos(t) * t_1), eh, Float64(sin(t) * ew)) / sqrt(Float64(1.0 + (t_1 ^ 2.0))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -6.3e-13], N[Not[LessEqual[eh, 3.65e-28]], $MachinePrecision]], N[Abs[N[(t$95$2 * N[Sin[N[ArcTan[N[(t$95$2 / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[Cos[t], $MachinePrecision] * t$95$1), $MachinePrecision] * eh + N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{\tan t}}{ew}\\
t_2 := eh \cdot \cos t\\
\mathbf{if}\;eh \leq -6.3 \cdot 10^{-13} \lor \neg \left(eh \leq 3.65 \cdot 10^{-28}\right):\\
\;\;\;\;\left|t\_2 \cdot \sin \tan^{-1} \left(\frac{t\_2}{ew \cdot \sin t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\cos t \cdot t\_1, eh, \sin t \cdot ew\right)}{\sqrt{1 + {t\_1}^{2}}}\right|\\
\end{array}
\end{array}
if eh < -6.30000000000000042e-13 or 3.6499999999999998e-28 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6483.7
Applied rewrites83.7%
if -6.30000000000000042e-13 < eh < 3.6499999999999998e-28Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites96.0%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
+-commutativeN/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
lower-pow.f6490.2
Applied rewrites90.2%
Final simplification87.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (cos t))))
(if (or (<= eh -6.3e-13) (not (<= eh 3.5e-28)))
(fabs (* t_1 (sin (atan (/ t_1 (* ew (sin t)))))))
(fabs
(/
(fma (/ eh (* ew t)) eh (* (sin t) ew))
(cosh (asinh (/ (/ eh (tan t)) ew))))))))
double code(double eh, double ew, double t) {
double t_1 = eh * cos(t);
double tmp;
if ((eh <= -6.3e-13) || !(eh <= 3.5e-28)) {
tmp = fabs((t_1 * sin(atan((t_1 / (ew * sin(t)))))));
} else {
tmp = fabs((fma((eh / (ew * t)), eh, (sin(t) * ew)) / cosh(asinh(((eh / tan(t)) / ew)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh * cos(t)) tmp = 0.0 if ((eh <= -6.3e-13) || !(eh <= 3.5e-28)) tmp = abs(Float64(t_1 * sin(atan(Float64(t_1 / Float64(ew * sin(t))))))); else tmp = abs(Float64(fma(Float64(eh / Float64(ew * t)), eh, Float64(sin(t) * ew)) / cosh(asinh(Float64(Float64(eh / tan(t)) / ew))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -6.3e-13], N[Not[LessEqual[eh, 3.5e-28]], $MachinePrecision]], N[Abs[N[(t$95$1 * N[Sin[N[ArcTan[N[(t$95$1 / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision] * eh + N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \cos t\\
\mathbf{if}\;eh \leq -6.3 \cdot 10^{-13} \lor \neg \left(eh \leq 3.5 \cdot 10^{-28}\right):\\
\;\;\;\;\left|t\_1 \cdot \sin \tan^{-1} \left(\frac{t\_1}{ew \cdot \sin t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\frac{eh}{ew \cdot t}, eh, \sin t \cdot ew\right)}{\cosh \sinh^{-1} \left(\frac{\frac{eh}{\tan t}}{ew}\right)}\right|\\
\end{array}
\end{array}
if eh < -6.30000000000000042e-13 or 3.5e-28 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6483.7
Applied rewrites83.7%
if -6.30000000000000042e-13 < eh < 3.5e-28Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites96.0%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6483.7
Applied rewrites83.7%
Final simplification83.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (asinh (/ (/ eh (tan t)) ew))))
(if (or (<= eh -7.2e+89) (not (<= eh 180000.0)))
(fabs (* (tanh t_1) eh))
(fabs (/ (fma (/ eh (* ew t)) eh (* (sin t) ew)) (cosh t_1))))))
double code(double eh, double ew, double t) {
double t_1 = asinh(((eh / tan(t)) / ew));
double tmp;
if ((eh <= -7.2e+89) || !(eh <= 180000.0)) {
tmp = fabs((tanh(t_1) * eh));
} else {
tmp = fabs((fma((eh / (ew * t)), eh, (sin(t) * ew)) / cosh(t_1)));
}
return tmp;
}
function code(eh, ew, t) t_1 = asinh(Float64(Float64(eh / tan(t)) / ew)) tmp = 0.0 if ((eh <= -7.2e+89) || !(eh <= 180000.0)) tmp = abs(Float64(tanh(t_1) * eh)); else tmp = abs(Float64(fma(Float64(eh / Float64(ew * t)), eh, Float64(sin(t) * ew)) / cosh(t_1))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcSinh[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[eh, -7.2e+89], N[Not[LessEqual[eh, 180000.0]], $MachinePrecision]], N[Abs[N[(N[Tanh[t$95$1], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision] * eh + N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Cosh[t$95$1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sinh^{-1} \left(\frac{\frac{eh}{\tan t}}{ew}\right)\\
\mathbf{if}\;eh \leq -7.2 \cdot 10^{+89} \lor \neg \left(eh \leq 180000\right):\\
\;\;\;\;\left|\tanh t\_1 \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\frac{eh}{ew \cdot t}, eh, \sin t \cdot ew\right)}{\cosh t\_1}\right|\\
\end{array}
\end{array}
if eh < -7.2e89 or 1.8e5 < eh Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6449.8
Applied rewrites49.8%
Applied rewrites49.8%
if -7.2e89 < eh < 1.8e5Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites93.0%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Final simplification69.1%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -2.3e+18) (not (<= ew 8.5e-64))) (fabs (* ew (sin t))) (fabs (* (tanh (asinh (/ (/ eh (tan t)) ew))) eh))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.3e+18) || !(ew <= 8.5e-64)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs((tanh(asinh(((eh / tan(t)) / ew))) * eh));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2.3e+18) or not (ew <= 8.5e-64): tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs((math.tanh(math.asinh(((eh / math.tan(t)) / ew))) * eh)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.3e+18) || !(ew <= 8.5e-64)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(tanh(asinh(Float64(Float64(eh / tan(t)) / ew))) * eh)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2.3e+18) || ~((ew <= 8.5e-64))) tmp = abs((ew * sin(t))); else tmp = abs((tanh(asinh(((eh / tan(t)) / ew))) * eh)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.3e+18], N[Not[LessEqual[ew, 8.5e-64]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Tanh[N[ArcSinh[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.3 \cdot 10^{+18} \lor \neg \left(ew \leq 8.5 \cdot 10^{-64}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\tanh \sinh^{-1} \left(\frac{\frac{eh}{\tan t}}{ew}\right) \cdot eh\right|\\
\end{array}
\end{array}
if ew < -2.3e18 or 8.49999999999999996e-64 < ew Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites84.3%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6470.9
Applied rewrites70.9%
if -2.3e18 < ew < 8.49999999999999996e-64Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6452.7
Applied rewrites52.7%
Applied rewrites52.7%
Final simplification63.3%
(FPCore (eh ew t)
:precision binary64
(if (or (<= ew -2.3e+18) (not (<= ew 8.2e-188)))
(fabs (* ew (sin t)))
(fabs
(*
(sin
(atan (/ (fma (* t t) (* (/ eh ew) -0.3333333333333333) (/ eh ew)) t)))
eh))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.3e+18) || !(ew <= 8.2e-188)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs((sin(atan((fma((t * t), ((eh / ew) * -0.3333333333333333), (eh / ew)) / t))) * eh));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.3e+18) || !(ew <= 8.2e-188)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(sin(atan(Float64(fma(Float64(t * t), Float64(Float64(eh / ew) * -0.3333333333333333), Float64(eh / ew)) / t))) * eh)); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.3e+18], N[Not[LessEqual[ew, 8.2e-188]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(t * t), $MachinePrecision] * N[(N[(eh / ew), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] + N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.3 \cdot 10^{+18} \lor \neg \left(ew \leq 8.2 \cdot 10^{-188}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(t \cdot t, \frac{eh}{ew} \cdot -0.3333333333333333, \frac{eh}{ew}\right)}{t}\right) \cdot eh\right|\\
\end{array}
\end{array}
if ew < -2.3e18 or 8.19999999999999965e-188 < ew Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites80.4%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6464.8
Applied rewrites64.8%
if -2.3e18 < ew < 8.19999999999999965e-188Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6456.9
Applied rewrites56.9%
Taylor expanded in t around 0
Applied rewrites44.6%
Final simplification58.3%
(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%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites71.6%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6447.7
Applied rewrites47.7%
(FPCore (eh ew t) :precision binary64 (fabs (* ew t)))
double code(double eh, double ew, double t) {
return fabs((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 * t))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * t));
}
def code(eh, ew, t): return math.fabs((ew * t))
function code(eh, ew, t) return abs(Float64(ew * t)) end
function tmp = code(eh, ew, t) tmp = abs((ew * t)); end
code[eh_, ew_, t_] := N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot t\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites71.6%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6447.7
Applied rewrites47.7%
Taylor expanded in t around 0
Applied rewrites22.6%
(FPCore (eh ew t) :precision binary64 (* t ew))
double code(double eh, double ew, double t) {
return 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 = t * ew
end function
public static double code(double eh, double ew, double t) {
return t * ew;
}
def code(eh, ew, t): return t * ew
function code(eh, ew, t) return Float64(t * ew) end
function tmp = code(eh, ew, t) tmp = t * ew; end
code[eh_, ew_, t_] := N[(t * ew), $MachinePrecision]
\begin{array}{l}
\\
t \cdot ew
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites71.6%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6447.7
Applied rewrites47.7%
Taylor expanded in t around 0
Applied rewrites22.6%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt13.3
Applied rewrites13.3%
herbie shell --seed 2024340
(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))))))))