
(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 (fabs (- (* (* (sin (atan (/ (/ (- eh) ew) (tan t)))) (cos t)) eh) (* (* (sin t) ew) (cos (atan (/ (/ eh (tan t)) ew)))))))
double code(double eh, double ew, double t) {
return fabs((((sin(atan(((-eh / ew) / tan(t)))) * cos(t)) * eh) - ((sin(t) * ew) * cos(atan(((eh / tan(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 = abs((((sin(atan(((-eh / ew) / tan(t)))) * cos(t)) * eh) - ((sin(t) * ew) * cos(atan(((eh / tan(t)) / ew))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((Math.sin(Math.atan(((-eh / ew) / Math.tan(t)))) * Math.cos(t)) * eh) - ((Math.sin(t) * ew) * Math.cos(Math.atan(((eh / Math.tan(t)) / ew))))));
}
def code(eh, ew, t): return math.fabs((((math.sin(math.atan(((-eh / ew) / math.tan(t)))) * math.cos(t)) * eh) - ((math.sin(t) * ew) * math.cos(math.atan(((eh / math.tan(t)) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(sin(atan(Float64(Float64(Float64(-eh) / ew) / tan(t)))) * cos(t)) * eh) - Float64(Float64(sin(t) * ew) * cos(atan(Float64(Float64(eh / tan(t)) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs((((sin(atan(((-eh / ew) / tan(t)))) * cos(t)) * eh) - ((sin(t) * ew) * cos(atan(((eh / tan(t)) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(N[Sin[N[ArcTan[N[(N[((-eh) / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision] - N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(\sin \tan^{-1} \left(\frac{\frac{-eh}{ew}}{\tan t}\right) \cdot \cos t\right) \cdot eh - \left(\sin t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{\tan t}}{ew}\right)\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
Applied rewrites99.8%
Final simplification99.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-263)
(fabs (* t (fma -0.16666666666666666 (* ew (* t t)) ew)))
(* (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-263) {
tmp = fabs((t * fma(-0.16666666666666666, (ew * (t * t)), ew)));
} else {
tmp = 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-263) tmp = abs(Float64(t * fma(-0.16666666666666666, Float64(ew * Float64(t * t)), ew))); else tmp = Float64(sin(t) * ew); end return 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-263], N[Abs[N[(t * N[(-0.16666666666666666 * N[(ew * N[(t * t), $MachinePrecision]), $MachinePrecision] + ew), $MachinePrecision]), $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^{-263}:\\
\;\;\;\;\left|t \cdot \mathsf{fma}\left(-0.16666666666666666, ew \cdot \left(t \cdot t\right), ew\right)\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)))))) < -4e-263Initial 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 rewrites68.0%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6437.9
Applied rewrites37.9%
Taylor expanded in t around 0
Applied rewrites14.9%
if -4e-263 < (+.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 rewrites64.7%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6445.2
Applied rewrites45.2%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
pow2N/A
lower-pow.f6429.1
Applied rewrites29.1%
lift-sqrt.f64N/A
lift-pow.f64N/A
sqrt-pow1N/A
metadata-evalN/A
unpow145.2
Applied rewrites45.2%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ eh (* (tan t) ew))))) (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan((eh / (tan(t) * ew))))) + ((ew * sin(t)) * cos(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 / (tan(t) * ew))))) + ((ew * sin(t)) * cos(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 / (Math.tan(t) * ew))))) + ((ew * Math.sin(t)) * Math.cos(Math.atan(((eh / ew) / Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan((eh / (math.tan(t) * ew))))) + ((ew * math.sin(t)) * math.cos(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(tan(t) * ew))))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(Float64(eh / ew) / tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan((eh / (tan(t) * ew))))) + ((ew * sin(t)) * cos(atan(((eh / ew) / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\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%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(fabs
(+
(*
(* eh (cos t))
(sin (atan (/ (/ (fma (* (* t t) eh) -0.3333333333333333 eh) ew) t))))
(* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((fma(((t * t) * eh), -0.3333333333333333, eh) / ew) / t)))) + ((ew * sin(t)) * cos(atan(((eh / ew) / tan(t)))))));
}
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(fma(Float64(Float64(t * t) * eh), -0.3333333333333333, eh) / ew) / t)))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(Float64(eh / ew) / tan(t))))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(N[(N[(N[(t * t), $MachinePrecision] * eh), $MachinePrecision] * -0.3333333333333333 + eh), $MachinePrecision] / ew), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[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{\mathsf{fma}\left(\left(t \cdot t\right) \cdot eh, -0.3333333333333333, eh\right)}{ew}}{t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
Applied rewrites99.5%
Final simplification99.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (cos t))))
(if (or (<= ew -7.5e-29) (not (<= ew 4.5e-169)))
(fabs
(+
(* t_1 (sin (atan (/ (/ eh ew) t))))
(* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t)))))))
(fabs t_1))))
double code(double eh, double ew, double t) {
double t_1 = eh * cos(t);
double tmp;
if ((ew <= -7.5e-29) || !(ew <= 4.5e-169)) {
tmp = fabs(((t_1 * sin(atan(((eh / ew) / t)))) + ((ew * sin(t)) * cos(atan(((eh / ew) / tan(t)))))));
} else {
tmp = fabs(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 * cos(t)
if ((ew <= (-7.5d-29)) .or. (.not. (ew <= 4.5d-169))) then
tmp = abs(((t_1 * sin(atan(((eh / ew) / t)))) + ((ew * sin(t)) * cos(atan(((eh / ew) / tan(t)))))))
else
tmp = abs(t_1)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = eh * Math.cos(t);
double tmp;
if ((ew <= -7.5e-29) || !(ew <= 4.5e-169)) {
tmp = Math.abs(((t_1 * Math.sin(Math.atan(((eh / ew) / t)))) + ((ew * Math.sin(t)) * Math.cos(Math.atan(((eh / ew) / Math.tan(t)))))));
} else {
tmp = Math.abs(t_1);
}
return tmp;
}
def code(eh, ew, t): t_1 = eh * math.cos(t) tmp = 0 if (ew <= -7.5e-29) or not (ew <= 4.5e-169): tmp = math.fabs(((t_1 * math.sin(math.atan(((eh / ew) / t)))) + ((ew * math.sin(t)) * math.cos(math.atan(((eh / ew) / math.tan(t))))))) else: tmp = math.fabs(t_1) return tmp
function code(eh, ew, t) t_1 = Float64(eh * cos(t)) tmp = 0.0 if ((ew <= -7.5e-29) || !(ew <= 4.5e-169)) tmp = abs(Float64(Float64(t_1 * sin(atan(Float64(Float64(eh / ew) / t)))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(Float64(eh / ew) / tan(t))))))); else tmp = abs(t_1); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh * cos(t); tmp = 0.0; if ((ew <= -7.5e-29) || ~((ew <= 4.5e-169))) tmp = abs(((t_1 * sin(atan(((eh / ew) / t)))) + ((ew * sin(t)) * cos(atan(((eh / ew) / tan(t))))))); else tmp = abs(t_1); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[ew, -7.5e-29], N[Not[LessEqual[ew, 4.5e-169]], $MachinePrecision]], N[Abs[N[(N[(t$95$1 * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[t$95$1], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \cos t\\
\mathbf{if}\;ew \leq -7.5 \cdot 10^{-29} \lor \neg \left(ew \leq 4.5 \cdot 10^{-169}\right):\\
\;\;\;\;\left|t\_1 \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1\right|\\
\end{array}
\end{array}
if ew < -7.50000000000000006e-29 or 4.4999999999999999e-169 < ew Initial program 99.8%
Taylor expanded in t around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
if -7.50000000000000006e-29 < ew < 4.4999999999999999e-169Initial program 99.9%
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 rewrites50.2%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
+-commutativeN/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
lower-pow.f6431.2
Applied rewrites31.2%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6493.1
Applied rewrites93.1%
Final simplification94.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh (tan t)) ew)))
(if (or (<= eh -3.15e-24) (not (<= eh 1.6e-36)))
(fabs (* eh (cos t)))
(fabs (/ (fma (sin t) ew (* (* t_1 eh) (cos t))) (cosh (asinh t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / tan(t)) / ew;
double tmp;
if ((eh <= -3.15e-24) || !(eh <= 1.6e-36)) {
tmp = fabs((eh * cos(t)));
} else {
tmp = fabs((fma(sin(t), ew, ((t_1 * eh) * cos(t))) / cosh(asinh(t_1))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / tan(t)) / ew) tmp = 0.0 if ((eh <= -3.15e-24) || !(eh <= 1.6e-36)) tmp = abs(Float64(eh * cos(t))); else tmp = abs(Float64(fma(sin(t), ew, Float64(Float64(t_1 * eh) * cos(t))) / 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, -3.15e-24], N[Not[LessEqual[eh, 1.6e-36]], $MachinePrecision]], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * ew + N[(N[(t$95$1 * eh), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $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 -3.15 \cdot 10^{-24} \lor \neg \left(eh \leq 1.6 \cdot 10^{-36}\right):\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, ew, \left(t\_1 \cdot eh\right) \cdot \cos t\right)}{\cosh \sinh^{-1} t\_1}\right|\\
\end{array}
\end{array}
if eh < -3.1499999999999999e-24 or 1.60000000000000011e-36 < eh 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 rewrites40.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.f6431.5
Applied rewrites31.5%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6487.4
Applied rewrites87.4%
if -3.1499999999999999e-24 < eh < 1.60000000000000011e-36Initial 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.2%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6496.2
Applied rewrites96.2%
Final simplification91.5%
(FPCore (eh ew t)
:precision binary64
(if (or (<= eh -5.1e-26) (not (<= eh 1.1e-54)))
(fabs (* eh (cos 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 <= -5.1e-26) || !(eh <= 1.1e-54)) {
tmp = fabs((eh * cos(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 <= -5.1e-26) || !(eh <= 1.1e-54)) tmp = abs(Float64(eh * cos(t))); else tmp = abs(Float64(fma(Float64(Float64(eh / 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, -5.1e-26], N[Not[LessEqual[eh, 1.1e-54]], $MachinePrecision]], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[(eh / ew), $MachinePrecision] / t), $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 -5.1 \cdot 10^{-26} \lor \neg \left(eh \leq 1.1 \cdot 10^{-54}\right):\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\frac{\frac{eh}{ew}}{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 < -5.09999999999999991e-26 or 1.1e-54 < eh 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 rewrites41.1%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
+-commutativeN/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
lower-pow.f6432.3
Applied rewrites32.3%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6487.0
Applied rewrites87.0%
if -5.09999999999999991e-26 < eh < 1.1e-54Initial 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.2%
Taylor expanded in t around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f6486.6
Applied rewrites86.6%
Final simplification86.8%
(FPCore (eh ew t)
:precision binary64
(if (or (<= eh -1.55e-89) (not (<= eh 7.8e-80)))
(fabs (* eh (cos t)))
(fabs
(/
(fma (/ (/ eh ew) t) eh (* (sin t) ew))
(sqrt (+ 1.0 (pow (/ (/ eh (tan t)) ew) 2.0)))))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -1.55e-89) || !(eh <= 7.8e-80)) {
tmp = fabs((eh * cos(t)));
} else {
tmp = fabs((fma(((eh / ew) / t), eh, (sin(t) * ew)) / sqrt((1.0 + pow(((eh / tan(t)) / ew), 2.0)))));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((eh <= -1.55e-89) || !(eh <= 7.8e-80)) tmp = abs(Float64(eh * cos(t))); else tmp = abs(Float64(fma(Float64(Float64(eh / ew) / t), eh, Float64(sin(t) * ew)) / sqrt(Float64(1.0 + (Float64(Float64(eh / tan(t)) / ew) ^ 2.0))))); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -1.55e-89], N[Not[LessEqual[eh, 7.8e-80]], $MachinePrecision]], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[(eh / ew), $MachinePrecision] / t), $MachinePrecision] * eh + N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1.55 \cdot 10^{-89} \lor \neg \left(eh \leq 7.8 \cdot 10^{-80}\right):\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\frac{\frac{eh}{ew}}{t}, eh, \sin t \cdot ew\right)}{\sqrt{1 + {\left(\frac{\frac{eh}{\tan t}}{ew}\right)}^{2}}}\right|\\
\end{array}
\end{array}
if eh < -1.54999999999999998e-89 or 7.7999999999999995e-80 < eh 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 rewrites48.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.f6435.9
Applied rewrites35.9%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6483.8
Applied rewrites83.8%
if -1.54999999999999998e-89 < eh < 7.7999999999999995e-80Initial 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.5%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
+-commutativeN/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
lower-pow.f6488.2
Applied rewrites88.2%
Taylor expanded in t around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.4
Applied rewrites81.4%
Final simplification82.9%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -8.6e-92) (not (<= eh 7.8e-80))) (fabs (* eh (cos t))) (fabs (* ew (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -8.6e-92) || !(eh <= 7.8e-80)) {
tmp = fabs((eh * cos(t)));
} else {
tmp = fabs((ew * sin(t)));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((eh <= (-8.6d-92)) .or. (.not. (eh <= 7.8d-80))) then
tmp = abs((eh * cos(t)))
else
tmp = abs((ew * sin(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -8.6e-92) || !(eh <= 7.8e-80)) {
tmp = Math.abs((eh * Math.cos(t)));
} else {
tmp = Math.abs((ew * Math.sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -8.6e-92) or not (eh <= 7.8e-80): tmp = math.fabs((eh * math.cos(t))) else: tmp = math.fabs((ew * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -8.6e-92) || !(eh <= 7.8e-80)) tmp = abs(Float64(eh * cos(t))); else tmp = abs(Float64(ew * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -8.6e-92) || ~((eh <= 7.8e-80))) tmp = abs((eh * cos(t))); else tmp = abs((ew * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -8.6e-92], N[Not[LessEqual[eh, 7.8e-80]], $MachinePrecision]], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -8.6 \cdot 10^{-92} \lor \neg \left(eh \leq 7.8 \cdot 10^{-80}\right):\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if eh < -8.60000000000000027e-92 or 7.7999999999999995e-80 < eh 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 rewrites48.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.f6435.9
Applied rewrites35.9%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6483.8
Applied rewrites83.8%
if -8.60000000000000027e-92 < eh < 7.7999999999999995e-80Initial 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.5%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6475.1
Applied rewrites75.1%
Final simplification80.5%
(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 rewrites66.5%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6441.1
Applied rewrites41.1%
(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 rewrites66.5%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6441.1
Applied rewrites41.1%
Taylor expanded in t around 0
Applied rewrites17.1%
(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 rewrites66.5%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6441.1
Applied rewrites41.1%
Taylor expanded in t around 0
Applied rewrites17.1%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt9.8
Applied rewrites9.8%
herbie shell --seed 2024326
(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))))))))