
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * cos(t)) * cos(t_1)) - ((eh * sin(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.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * cos(t)) * cos(t_1)) - ((eh * sin(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.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin 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 (fma (* (sin t_1) eh) (sin t) (* (* (cos t) ew) (cos t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh * (tan(t) / ew)));
return fabs(fma((sin(t_1) * eh), sin(t), ((cos(t) * ew) * cos(t_1))));
}
function code(eh, ew, t) t_1 = atan(Float64(eh * Float64(tan(t) / ew))) return abs(fma(Float64(sin(t_1) * eh), sin(t), Float64(Float64(cos(t) * ew) * cos(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[Sin[t$95$1], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\\
\left|\mathsf{fma}\left(\sin t\_1 \cdot eh, \sin t, \left(\cos t \cdot ew\right) \cdot \cos t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* (sin (atan (* eh (/ t ew)))) eh) (sin t) (* (* (cos t) ew) (cos (atan (* eh (/ (tan t) ew))))))))
double code(double eh, double ew, double t) {
return fabs(fma((sin(atan((eh * (t / ew)))) * eh), sin(t), ((cos(t) * ew) * cos(atan((eh * (tan(t) / ew)))))));
}
function code(eh, ew, t) return abs(fma(Float64(sin(atan(Float64(eh * Float64(t / ew)))) * eh), sin(t), Float64(Float64(cos(t) * ew) * cos(atan(Float64(eh * Float64(tan(t) / ew))))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[N[ArcTan[N[(eh * N[(t / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\sin \tan^{-1} \left(eh \cdot \frac{t}{ew}\right) \cdot eh, \sin t, \left(\cos t \cdot ew\right) \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f6498.9
Applied rewrites98.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (/ (tan t) ew))))
(if (or (<= eh -4.3e-17) (not (<= eh 2.9e+94)))
(fabs
(*
(* (sin t) (- eh))
(sin (atan (* (- eh) (/ (sin t) (* (cos t) ew)))))))
(fabs
(* (fma (- ew) (cos t) (* (* t_1 eh) (- (sin t)))) (cos (atan t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = eh * (tan(t) / ew);
double tmp;
if ((eh <= -4.3e-17) || !(eh <= 2.9e+94)) {
tmp = fabs(((sin(t) * -eh) * sin(atan((-eh * (sin(t) / (cos(t) * ew)))))));
} else {
tmp = fabs((fma(-ew, cos(t), ((t_1 * eh) * -sin(t))) * cos(atan(t_1))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh * Float64(tan(t) / ew)) tmp = 0.0 if ((eh <= -4.3e-17) || !(eh <= 2.9e+94)) tmp = abs(Float64(Float64(sin(t) * Float64(-eh)) * sin(atan(Float64(Float64(-eh) * Float64(sin(t) / Float64(cos(t) * ew))))))); else tmp = abs(Float64(fma(Float64(-ew), cos(t), Float64(Float64(t_1 * eh) * Float64(-sin(t)))) * cos(atan(t_1)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -4.3e-17], N[Not[LessEqual[eh, 2.9e+94]], $MachinePrecision]], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * (-eh)), $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) * N[(N[Sin[t], $MachinePrecision] / N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[((-ew) * N[Cos[t], $MachinePrecision] + N[(N[(t$95$1 * eh), $MachinePrecision] * (-N[Sin[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \frac{\tan t}{ew}\\
\mathbf{if}\;eh \leq -4.3 \cdot 10^{-17} \lor \neg \left(eh \leq 2.9 \cdot 10^{+94}\right):\\
\;\;\;\;\left|\left(\sin t \cdot \left(-eh\right)\right) \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\sin t}{\cos t \cdot ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(-ew, \cos t, \left(t\_1 \cdot eh\right) \cdot \left(-\sin t\right)\right) \cdot \cos \tan^{-1} t\_1\right|\\
\end{array}
\end{array}
if eh < -4.30000000000000023e-17 or 2.8999999999999998e94 < eh Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites20.3%
Taylor expanded in eh around inf
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
Applied rewrites75.5%
if -4.30000000000000023e-17 < eh < 2.8999999999999998e94Initial program 99.8%
Applied rewrites84.3%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
/-rgt-identityN/A
lower-*.f6484.3
Applied rewrites84.3%
Final simplification80.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (cos t) ew)) (t_2 (atan (* (- eh) (/ (sin t) t_1)))))
(if (or (<= eh -4.3e-17) (not (<= eh 2.9e+94)))
(fabs (* (* (sin t) (- eh)) (sin t_2)))
(fabs (* t_1 (cos t_2))))))
double code(double eh, double ew, double t) {
double t_1 = cos(t) * ew;
double t_2 = atan((-eh * (sin(t) / t_1)));
double tmp;
if ((eh <= -4.3e-17) || !(eh <= 2.9e+94)) {
tmp = fabs(((sin(t) * -eh) * sin(t_2)));
} else {
tmp = fabs((t_1 * cos(t_2)));
}
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) :: t_2
real(8) :: tmp
t_1 = cos(t) * ew
t_2 = atan((-eh * (sin(t) / t_1)))
if ((eh <= (-4.3d-17)) .or. (.not. (eh <= 2.9d+94))) then
tmp = abs(((sin(t) * -eh) * sin(t_2)))
else
tmp = abs((t_1 * cos(t_2)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.cos(t) * ew;
double t_2 = Math.atan((-eh * (Math.sin(t) / t_1)));
double tmp;
if ((eh <= -4.3e-17) || !(eh <= 2.9e+94)) {
tmp = Math.abs(((Math.sin(t) * -eh) * Math.sin(t_2)));
} else {
tmp = Math.abs((t_1 * Math.cos(t_2)));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.cos(t) * ew t_2 = math.atan((-eh * (math.sin(t) / t_1))) tmp = 0 if (eh <= -4.3e-17) or not (eh <= 2.9e+94): tmp = math.fabs(((math.sin(t) * -eh) * math.sin(t_2))) else: tmp = math.fabs((t_1 * math.cos(t_2))) return tmp
function code(eh, ew, t) t_1 = Float64(cos(t) * ew) t_2 = atan(Float64(Float64(-eh) * Float64(sin(t) / t_1))) tmp = 0.0 if ((eh <= -4.3e-17) || !(eh <= 2.9e+94)) tmp = abs(Float64(Float64(sin(t) * Float64(-eh)) * sin(t_2))); else tmp = abs(Float64(t_1 * cos(t_2))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = cos(t) * ew; t_2 = atan((-eh * (sin(t) / t_1))); tmp = 0.0; if ((eh <= -4.3e-17) || ~((eh <= 2.9e+94))) tmp = abs(((sin(t) * -eh) * sin(t_2))); else tmp = abs((t_1 * cos(t_2))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[((-eh) * N[(N[Sin[t], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[eh, -4.3e-17], N[Not[LessEqual[eh, 2.9e+94]], $MachinePrecision]], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * (-eh)), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$1 * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \cos t \cdot ew\\
t_2 := \tan^{-1} \left(\left(-eh\right) \cdot \frac{\sin t}{t\_1}\right)\\
\mathbf{if}\;eh \leq -4.3 \cdot 10^{-17} \lor \neg \left(eh \leq 2.9 \cdot 10^{+94}\right):\\
\;\;\;\;\left|\left(\sin t \cdot \left(-eh\right)\right) \cdot \sin t\_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1 \cdot \cos t\_2\right|\\
\end{array}
\end{array}
if eh < -4.30000000000000023e-17 or 2.8999999999999998e94 < eh Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites20.3%
Taylor expanded in eh around inf
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
Applied rewrites75.5%
if -4.30000000000000023e-17 < eh < 2.8999999999999998e94Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.1%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
neg-mul-1N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6483.3
Applied rewrites83.3%
Final simplification79.7%
(FPCore (eh ew t) :precision binary64 (fabs (/ (* (- ew) (cos t)) (pow (cos (atan (* (/ (tan t) ew) eh))) -1.0))))
double code(double eh, double ew, double t) {
return fabs(((-ew * cos(t)) / pow(cos(atan(((tan(t) / ew) * eh))), -1.0)));
}
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 * cos(t)) / (cos(atan(((tan(t) / ew) * eh))) ** (-1.0d0))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((-ew * Math.cos(t)) / Math.pow(Math.cos(Math.atan(((Math.tan(t) / ew) * eh))), -1.0)));
}
def code(eh, ew, t): return math.fabs(((-ew * math.cos(t)) / math.pow(math.cos(math.atan(((math.tan(t) / ew) * eh))), -1.0)))
function code(eh, ew, t) return abs(Float64(Float64(Float64(-ew) * cos(t)) / (cos(atan(Float64(Float64(tan(t) / ew) * eh))) ^ -1.0))) end
function tmp = code(eh, ew, t) tmp = abs(((-ew * cos(t)) / (cos(atan(((tan(t) / ew) * eh))) ^ -1.0))); end
code[eh_, ew_, t_] := N[Abs[N[(N[((-ew) * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\left(-ew\right) \cdot \cos t}{{\cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)}^{-1}}\right|
\end{array}
Initial program 99.8%
Applied rewrites60.4%
Taylor expanded in eh around 0
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f6457.8
Applied rewrites57.8%
Final simplification57.8%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (* (cos t) ew))) (fabs (* t_1 (cos (atan (* (- eh) (/ (sin t) t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = cos(t) * ew;
return fabs((t_1 * cos(atan((-eh * (sin(t) / 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 = cos(t) * ew
code = abs((t_1 * cos(atan((-eh * (sin(t) / t_1))))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.cos(t) * ew;
return Math.abs((t_1 * Math.cos(Math.atan((-eh * (Math.sin(t) / t_1))))));
}
def code(eh, ew, t): t_1 = math.cos(t) * ew return math.fabs((t_1 * math.cos(math.atan((-eh * (math.sin(t) / t_1))))))
function code(eh, ew, t) t_1 = Float64(cos(t) * ew) return abs(Float64(t_1 * cos(atan(Float64(Float64(-eh) * Float64(sin(t) / t_1)))))) end
function tmp = code(eh, ew, t) t_1 = cos(t) * ew; tmp = abs((t_1 * cos(atan((-eh * (sin(t) / t_1)))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]}, N[Abs[N[(t$95$1 * N[Cos[N[ArcTan[N[((-eh) * N[(N[Sin[t], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \cos t \cdot ew\\
\left|t\_1 \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{\sin t}{t\_1}\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.1%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
neg-mul-1N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6457.8
Applied rewrites57.8%
(FPCore (eh ew t)
:precision binary64
(if (<= t -2.9e-15)
(fabs
(/
(-
(* (cos t) ew)
(*
(fma
(fma
(* (* eh eh) (/ (* t t) ew))
-0.08611111111111111
(* (/ (* eh eh) ew) -0.16666666666666666))
(* t t)
(/ (* (- eh) eh) ew))
(* t t)))
(/ -1.0 (cos (atan (* (/ t ew) eh))))))
(fabs (/ ew 1.0))))
double code(double eh, double ew, double t) {
double tmp;
if (t <= -2.9e-15) {
tmp = fabs((((cos(t) * ew) - (fma(fma(((eh * eh) * ((t * t) / ew)), -0.08611111111111111, (((eh * eh) / ew) * -0.16666666666666666)), (t * t), ((-eh * eh) / ew)) * (t * t))) / (-1.0 / cos(atan(((t / ew) * eh))))));
} else {
tmp = fabs((ew / 1.0));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (t <= -2.9e-15) tmp = abs(Float64(Float64(Float64(cos(t) * ew) - Float64(fma(fma(Float64(Float64(eh * eh) * Float64(Float64(t * t) / ew)), -0.08611111111111111, Float64(Float64(Float64(eh * eh) / ew) * -0.16666666666666666)), Float64(t * t), Float64(Float64(Float64(-eh) * eh) / ew)) * Float64(t * t))) / Float64(-1.0 / cos(atan(Float64(Float64(t / ew) * eh)))))); else tmp = abs(Float64(ew / 1.0)); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[t, -2.9e-15], N[Abs[N[(N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] - N[(N[(N[(N[(N[(eh * eh), $MachinePrecision] * N[(N[(t * t), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] * -0.08611111111111111 + N[(N[(N[(eh * eh), $MachinePrecision] / ew), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] * N[(t * t), $MachinePrecision] + N[(N[((-eh) * eh), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 / N[Cos[N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew / 1.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{-15}:\\
\;\;\;\;\left|\frac{\cos t \cdot ew - \mathsf{fma}\left(\mathsf{fma}\left(\left(eh \cdot eh\right) \cdot \frac{t \cdot t}{ew}, -0.08611111111111111, \frac{eh \cdot eh}{ew} \cdot -0.16666666666666666\right), t \cdot t, \frac{\left(-eh\right) \cdot eh}{ew}\right) \cdot \left(t \cdot t\right)}{\frac{-1}{\cos \tan^{-1} \left(\frac{t}{ew} \cdot eh\right)}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{ew}{1}\right|\\
\end{array}
\end{array}
if t < -2.90000000000000019e-15Initial program 99.7%
Applied rewrites48.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites19.9%
Taylor expanded in t around 0
lower-/.f6419.9
Applied rewrites19.9%
if -2.90000000000000019e-15 < t Initial program 99.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites49.7%
Taylor expanded in t around 0
Applied rewrites48.7%
Applied rewrites47.9%
Taylor expanded in eh around 0
Applied rewrites49.8%
Final simplification40.6%
(FPCore (eh ew t) :precision binary64 (fabs (/ ew 1.0)))
double code(double eh, double ew, double t) {
return fabs((ew / 1.0));
}
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 / 1.0d0))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew / 1.0));
}
def code(eh, ew, t): return math.fabs((ew / 1.0))
function code(eh, ew, t) return abs(Float64(ew / 1.0)) end
function tmp = code(eh, ew, t) tmp = abs((ew / 1.0)); end
code[eh_, ew_, t_] := N[Abs[N[(ew / 1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew}{1}\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.1%
Taylor expanded in t around 0
Applied rewrites36.9%
Applied rewrites35.8%
Taylor expanded in eh around 0
Applied rewrites38.3%
herbie shell --seed 2024325
(FPCore (eh ew t)
:name "Example 2 from Robby"
:precision binary64
(fabs (- (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))