
(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 11 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
(fma
(* (tanh (asinh t_1)) (cos t))
eh
(* (* (sin t) ew) (cos (atan t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (ew * tan(t));
return fabs(fma((tanh(asinh(t_1)) * cos(t)), eh, ((sin(t) * ew) * cos(atan(t_1)))));
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(ew * tan(t))) return abs(fma(Float64(tanh(asinh(t_1)) * cos(t)), eh, Float64(Float64(sin(t) * ew) * cos(atan(t_1))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * eh + N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] * 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}\\
\left|\mathsf{fma}\left(\tanh \sinh^{-1} t\_1 \cdot \cos t, eh, \left(\sin t \cdot ew\right) \cdot \cos \tan^{-1} t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.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 (atan (/ (/ eh ew) (tan t)))))
(if (<=
(+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1)))
-4e-215)
(fabs (* ew t))
(* (sin t) ew))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
double tmp;
if ((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))) <= -4e-215) {
tmp = fabs((ew * t));
} else {
tmp = sin(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) :: t_1
real(8) :: tmp
t_1 = atan(((eh / ew) / tan(t)))
if ((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))) <= (-4d-215)) then
tmp = abs((ew * t))
else
tmp = sin(t) * ew
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 ((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))) <= -4e-215) {
tmp = Math.abs((ew * t));
} else {
tmp = Math.sin(t) * ew;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) tmp = 0 if (((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))) <= -4e-215: tmp = math.fabs((ew * t)) else: tmp = math.sin(t) * ew return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) tmp = 0.0 if (Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1))) <= -4e-215) tmp = abs(Float64(ew * t)); else tmp = Float64(sin(t) * ew); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = 0.0; if ((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))) <= -4e-215) tmp = abs((ew * t)); else tmp = sin(t) * ew; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[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], -4e-215], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision], N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\mathbf{if}\;\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1 \leq -4 \cdot 10^{-215}:\\
\;\;\;\;\left|ew \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;\sin t \cdot ew\\
\end{array}
\end{array}
if (+.f64 (*.f64 (*.f64 ew (sin.f64 t)) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) < -4.00000000000000017e-215Initial program 99.7%
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 rewrites60.4%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6439.6
Applied rewrites39.6%
Taylor expanded in t around 0
Applied rewrites15.2%
if -4.00000000000000017e-215 < (+.f64 (*.f64 (*.f64 ew (sin.f64 t)) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) 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 rewrites67.6%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6446.8
Applied rewrites46.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt46.1
Applied rewrites46.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh (tan t)) ew)))
(if (or (<= eh -6e-11) (not (<= eh 3.2e+59)))
(fabs (* eh (* (cos t) (sin (atan (/ (* eh (cos t)) (* 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 tmp;
if ((eh <= -6e-11) || !(eh <= 3.2e+59)) {
tmp = fabs((eh * (cos(t) * sin(atan(((eh * cos(t)) / (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) tmp = 0.0 if ((eh <= -6e-11) || !(eh <= 3.2e+59)) tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh * cos(t)) / 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]}, If[Or[LessEqual[eh, -6e-11], N[Not[LessEqual[eh, 3.2e+59]], $MachinePrecision]], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[(ew * N[Sin[t], $MachinePrecision]), $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}\\
\mathbf{if}\;eh \leq -6 \cdot 10^{-11} \lor \neg \left(eh \leq 3.2 \cdot 10^{+59}\right):\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh \cdot \cos t}{ew \cdot \sin t}\right)\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 < -6e-11 or 3.19999999999999982e59 < 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.f6453.6
Applied rewrites53.6%
Taylor expanded in eh around inf
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.f6487.3
Applied rewrites87.3%
if -6e-11 < eh < 3.19999999999999982e59Initial 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.3%
Final simplification90.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh (tan t)) ew)))
(if (or (<= eh -4.6e-94) (not (<= eh 2e-64)))
(fabs (* eh (* (cos t) (sin (atan (/ (* eh (cos t)) (* 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 tmp;
if ((eh <= -4.6e-94) || !(eh <= 2e-64)) {
tmp = fabs((eh * (cos(t) * sin(atan(((eh * cos(t)) / (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) tmp = 0.0 if ((eh <= -4.6e-94) || !(eh <= 2e-64)) tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh * cos(t)) / 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]}, If[Or[LessEqual[eh, -4.6e-94], N[Not[LessEqual[eh, 2e-64]], $MachinePrecision]], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[(ew * N[Sin[t], $MachinePrecision]), $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}\\
\mathbf{if}\;eh \leq -4.6 \cdot 10^{-94} \lor \neg \left(eh \leq 2 \cdot 10^{-64}\right):\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh \cdot \cos t}{ew \cdot \sin t}\right)\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 < -4.5999999999999999e-94 or 1.99999999999999993e-64 < 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.f6453.0
Applied rewrites53.0%
Taylor expanded in eh around inf
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.f6482.3
Applied rewrites82.3%
if -4.5999999999999999e-94 < eh < 1.99999999999999993e-64Initial 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 rewrites98.4%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
+-commutativeN/A
rem-square-sqrtN/A
+-commutativeN/A
cosh-asinhN/A
lift-asinh.f64N/A
lift-cosh.f64N/A
+-commutativeN/A
cosh-asinhN/A
lift-asinh.f64N/A
lift-cosh.f64N/A
Applied rewrites94.7%
Final simplification86.8%
(FPCore (eh ew t)
:precision binary64
(if (or (<= eh -3e-70) (not (<= eh 2e-64)))
(fabs (* eh (* (cos t) (sin (atan (/ (* eh (cos t)) (* 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 tmp;
if ((eh <= -3e-70) || !(eh <= 2e-64)) {
tmp = fabs((eh * (cos(t) * sin(atan(((eh * cos(t)) / (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) tmp = 0.0 if ((eh <= -3e-70) || !(eh <= 2e-64)) tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh * cos(t)) / 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_] := If[Or[LessEqual[eh, -3e-70], N[Not[LessEqual[eh, 2e-64]], $MachinePrecision]], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[(ew * N[Sin[t], $MachinePrecision]), $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}
\mathbf{if}\;eh \leq -3 \cdot 10^{-70} \lor \neg \left(eh \leq 2 \cdot 10^{-64}\right):\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh \cdot \cos t}{ew \cdot \sin t}\right)\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 < -3.0000000000000001e-70 or 1.99999999999999993e-64 < 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.f6454.1
Applied rewrites54.1%
Taylor expanded in eh around inf
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.0
Applied rewrites83.0%
if -3.0000000000000001e-70 < eh < 1.99999999999999993e-64Initial 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 rewrites98.2%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6484.5
Applied rewrites84.5%
Final simplification83.6%
(FPCore (eh ew t)
:precision binary64
(if (or (<= eh -2.15e+86) (not (<= eh 1.75e+60)))
(fabs (* eh (tanh (asinh (/ eh (* (tan t) ew))))))
(fabs
(/
(fma (/ eh (* ew t)) eh (* (sin t) ew))
(cosh (asinh (/ (/ eh (tan t)) ew)))))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2.15e+86) || !(eh <= 1.75e+60)) {
tmp = fabs((eh * tanh(asinh((eh / (tan(t) * ew))))));
} else {
tmp = fabs((fma((eh / (ew * t)), eh, (sin(t) * ew)) / cosh(asinh(((eh / tan(t)) / ew)))));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((eh <= -2.15e+86) || !(eh <= 1.75e+60)) tmp = abs(Float64(eh * tanh(asinh(Float64(eh / Float64(tan(t) * ew)))))); 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_] := If[Or[LessEqual[eh, -2.15e+86], N[Not[LessEqual[eh, 1.75e+60]], $MachinePrecision]], N[Abs[N[(eh * N[Tanh[N[ArcSinh[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $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}
\mathbf{if}\;eh \leq -2.15 \cdot 10^{+86} \lor \neg \left(eh \leq 1.75 \cdot 10^{+60}\right):\\
\;\;\;\;\left|eh \cdot \tanh \sinh^{-1} \left(\frac{eh}{\tan t \cdot ew}\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 < -2.1500000000000001e86 or 1.7500000000000001e60 < 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.f6455.8
Applied rewrites55.8%
Applied rewrites6.3%
Applied rewrites6.8%
Applied rewrites55.8%
if -2.1500000000000001e86 < eh < 1.7500000000000001e60Initial 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 rewrites91.0%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6474.3
Applied rewrites74.3%
Final simplification67.1%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -3e-70) (not (<= eh 2e-64))) (fabs (* eh (tanh (asinh (/ eh (* (tan t) ew)))))) (fabs (* ew (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3e-70) || !(eh <= 2e-64)) {
tmp = fabs((eh * tanh(asinh((eh / (tan(t) * ew))))));
} else {
tmp = fabs((ew * sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -3e-70) or not (eh <= 2e-64): tmp = math.fabs((eh * math.tanh(math.asinh((eh / (math.tan(t) * ew)))))) else: tmp = math.fabs((ew * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -3e-70) || !(eh <= 2e-64)) tmp = abs(Float64(eh * tanh(asinh(Float64(eh / Float64(tan(t) * ew)))))); else tmp = abs(Float64(ew * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -3e-70) || ~((eh <= 2e-64))) tmp = abs((eh * tanh(asinh((eh / (tan(t) * ew)))))); else tmp = abs((ew * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -3e-70], N[Not[LessEqual[eh, 2e-64]], $MachinePrecision]], N[Abs[N[(eh * N[Tanh[N[ArcSinh[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -3 \cdot 10^{-70} \lor \neg \left(eh \leq 2 \cdot 10^{-64}\right):\\
\;\;\;\;\left|eh \cdot \tanh \sinh^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if eh < -3.0000000000000001e-70 or 1.99999999999999993e-64 < 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.f6454.1
Applied rewrites54.1%
Applied rewrites17.3%
Applied rewrites17.0%
Applied rewrites54.1%
if -3.0000000000000001e-70 < eh < 1.99999999999999993e-64Initial 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 rewrites98.2%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6481.1
Applied rewrites81.1%
Final simplification64.4%
(FPCore (eh ew t)
:precision binary64
(if (or (<= t -1.7e-124) (not (<= t 7.8e-148)))
(fabs (* ew (sin t)))
(fabs
(*
(sin
(atan
(/
(fma
(* t t)
(fma -0.5 (/ eh ew) (* 0.16666666666666666 (/ eh ew)))
(/ eh ew))
t)))
eh))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.7e-124) || !(t <= 7.8e-148)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs((sin(atan((fma((t * t), fma(-0.5, (eh / ew), (0.16666666666666666 * (eh / ew))), (eh / ew)) / t))) * eh));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((t <= -1.7e-124) || !(t <= 7.8e-148)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(sin(atan(Float64(fma(Float64(t * t), fma(-0.5, Float64(eh / ew), Float64(0.16666666666666666 * Float64(eh / ew))), Float64(eh / ew)) / t))) * eh)); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -1.7e-124], N[Not[LessEqual[t, 7.8e-148]], $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[(-0.5 * N[(eh / ew), $MachinePrecision] + N[(0.16666666666666666 * N[(eh / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.7 \cdot 10^{-124} \lor \neg \left(t \leq 7.8 \cdot 10^{-148}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(t \cdot t, \mathsf{fma}\left(-0.5, \frac{eh}{ew}, 0.16666666666666666 \cdot \frac{eh}{ew}\right), \frac{eh}{ew}\right)}{t}\right) \cdot eh\right|\\
\end{array}
\end{array}
if t < -1.7e-124 or 7.79999999999999988e-148 < t Initial program 99.7%
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.0%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6451.0
Applied rewrites51.0%
if -1.7e-124 < t < 7.79999999999999988e-148Initial program 100.0%
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.f6483.3
Applied rewrites83.3%
Taylor expanded in t around 0
Applied rewrites68.5%
Final simplification55.1%
(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 rewrites64.3%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6443.5
Applied rewrites43.5%
(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 rewrites64.3%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6443.5
Applied rewrites43.5%
Taylor expanded in t around 0
Applied rewrites18.7%
(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 rewrites64.3%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6443.5
Applied rewrites43.5%
Taylor expanded in t around 0
Applied rewrites18.7%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt12.1
Applied rewrites12.1%
herbie shell --seed 2024337
(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))))))))