
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ eh (* ew (tan t)))))) (fabs (fma 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(fma(ew, (sin(t) * cos(t_1)), (eh * (cos(t) * sin(t_1)))));
}
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * tan(t)))) return abs(fma(ew, Float64(sin(t) * cos(t_1)), Float64(eh * Float64(cos(t) * sin(t_1))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\left|\mathsf{fma}\left(ew, \sin t \cdot \cos t\_1, eh \cdot \left(\cos t \cdot \sin t\_1\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(+
(/ (* ew (sin t)) (hypot 1.0 t_1))
(* (* eh (cos t)) (sin (atan t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs((((ew * sin(t)) / hypot(1.0, t_1)) + ((eh * cos(t)) * sin(atan(t_1)))));
}
public static double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / Math.tan(t);
return Math.abs((((ew * Math.sin(t)) / Math.hypot(1.0, t_1)) + ((eh * Math.cos(t)) * Math.sin(Math.atan(t_1)))));
}
def code(eh, ew, t): t_1 = (eh / ew) / math.tan(t) return math.fabs((((ew * math.sin(t)) / math.hypot(1.0, t_1)) + ((eh * math.cos(t)) * math.sin(math.atan(t_1)))))
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(Float64(Float64(Float64(ew * sin(t)) / hypot(1.0, t_1)) + Float64(Float64(eh * cos(t)) * sin(atan(t_1))))) end
function tmp = code(eh, ew, t) t_1 = (eh / ew) / tan(t); tmp = abs((((ew * sin(t)) / hypot(1.0, t_1)) + ((eh * cos(t)) * sin(atan(t_1))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, t\_1\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t\_1\right|
\end{array}
\end{array}
Initial program 99.9%
associate-/r*99.9%
cos-atan99.9%
un-div-inv99.9%
hypot-1-def99.9%
associate-/r*99.9%
Applied egg-rr99.9%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* ew (sin t)) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs(((ew * sin(t)) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((ew * sin(t)) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * Math.sin(t)) + ((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.sin(t)) + ((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * sin(t)) + Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * sin(t)) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \sin t + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Initial program 99.9%
associate-/r*99.9%
cos-atan99.9%
un-div-inv99.9%
hypot-1-def99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in ew around inf 97.7%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -2.6e-86) (not (<= eh 2.4e-42))) (fabs (* (cos t) (* eh (sin (atan (/ eh (* ew (tan t)))))))) (fabs (* ew (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2.6e-86) || !(eh <= 2.4e-42)) {
tmp = fabs((cos(t) * (eh * sin(atan((eh / (ew * tan(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 <= (-2.6d-86)) .or. (.not. (eh <= 2.4d-42))) then
tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(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 <= -2.6e-86) || !(eh <= 2.4e-42)) {
tmp = Math.abs((Math.cos(t) * (eh * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
} else {
tmp = Math.abs((ew * Math.sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -2.6e-86) or not (eh <= 2.4e-42): tmp = math.fabs((math.cos(t) * (eh * math.sin(math.atan((eh / (ew * math.tan(t)))))))) else: tmp = math.fabs((ew * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -2.6e-86) || !(eh <= 2.4e-42)) tmp = abs(Float64(cos(t) * Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); else tmp = abs(Float64(ew * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -2.6e-86) || ~((eh <= 2.4e-42))) tmp = abs((cos(t) * (eh * sin(atan((eh / (ew * tan(t)))))))); else tmp = abs((ew * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -2.6e-86], N[Not[LessEqual[eh, 2.4e-42]], $MachinePrecision]], N[Abs[N[(N[Cos[t], $MachinePrecision] * N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $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 -2.6 \cdot 10^{-86} \lor \neg \left(eh \leq 2.4 \cdot 10^{-42}\right):\\
\;\;\;\;\left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if eh < -2.6000000000000001e-86 or 2.40000000000000003e-42 < eh Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in ew around 0 81.6%
*-commutative81.6%
associate-*r*81.6%
*-commutative81.6%
Simplified81.6%
if -2.6000000000000001e-86 < eh < 2.40000000000000003e-42Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
log1p-expm1-u99.7%
cos-atan99.7%
un-div-inv99.7%
hypot-1-def99.7%
associate-/r*99.7%
Applied egg-rr99.7%
log1p-expm1-u99.8%
clear-num99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Taylor expanded in ew around inf 74.4%
Final simplification79.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -0.026) (not (<= t 4.2e-7))) (fabs (* ew (sin t))) (fabs (+ (* eh (sin (atan (/ eh (* ew (tan t)))))) (* ew t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.026) || !(t <= 4.2e-7)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs(((eh * sin(atan((eh / (ew * tan(t)))))) + (ew * t)));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-0.026d0)) .or. (.not. (t <= 4.2d-7))) then
tmp = abs((ew * sin(t)))
else
tmp = abs(((eh * sin(atan((eh / (ew * tan(t)))))) + (ew * t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.026) || !(t <= 4.2e-7)) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = Math.abs(((eh * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))) + (ew * t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -0.026) or not (t <= 4.2e-7): tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs(((eh * math.sin(math.atan((eh / (ew * math.tan(t)))))) + (ew * t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -0.026) || !(t <= 4.2e-7)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))) + Float64(ew * t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -0.026) || ~((t <= 4.2e-7))) tmp = abs((ew * sin(t))); else tmp = abs(((eh * sin(atan((eh / (ew * tan(t)))))) + (ew * t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -0.026], N[Not[LessEqual[t, 4.2e-7]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.026 \lor \neg \left(t \leq 4.2 \cdot 10^{-7}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right) + ew \cdot t\right|\\
\end{array}
\end{array}
if t < -0.0259999999999999988 or 4.2e-7 < t Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
log1p-expm1-u99.6%
cos-atan99.6%
un-div-inv99.6%
hypot-1-def99.6%
associate-/r*99.6%
Applied egg-rr99.6%
log1p-expm1-u99.8%
clear-num99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Taylor expanded in ew around inf 55.7%
if -0.0259999999999999988 < t < 4.2e-7Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
associate-/r*100.0%
associate-*l*100.0%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in t around 0 99.3%
+-commutative99.3%
fma-define99.3%
Simplified99.3%
cos-atan99.3%
hypot-1-def99.3%
associate-/r*99.3%
un-div-inv99.3%
associate-/r*99.3%
Applied egg-rr99.3%
*-lft-identity99.3%
times-frac99.3%
associate-*l/99.3%
*-lft-identity99.3%
Simplified99.3%
Taylor expanded in eh around 0 97.0%
Final simplification77.3%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -0.0152) (not (<= t 1.35e-28))) (fabs (* ew (sin t))) (fabs eh)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.0152) || !(t <= 1.35e-28)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs(eh);
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-0.0152d0)) .or. (.not. (t <= 1.35d-28))) then
tmp = abs((ew * sin(t)))
else
tmp = abs(eh)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.0152) || !(t <= 1.35e-28)) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = Math.abs(eh);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -0.0152) or not (t <= 1.35e-28): tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs(eh) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -0.0152) || !(t <= 1.35e-28)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(eh); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -0.0152) || ~((t <= 1.35e-28))) tmp = abs((ew * sin(t))); else tmp = abs(eh); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -0.0152], N[Not[LessEqual[t, 1.35e-28]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.0152 \lor \neg \left(t \leq 1.35 \cdot 10^{-28}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\
\end{array}
\end{array}
if t < -0.0152 or 1.3499999999999999e-28 < t Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
log1p-expm1-u99.7%
cos-atan99.7%
un-div-inv99.7%
hypot-1-def99.7%
associate-/r*99.7%
Applied egg-rr99.7%
log1p-expm1-u99.8%
clear-num99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Taylor expanded in ew around inf 56.0%
if -0.0152 < t < 1.3499999999999999e-28Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
associate-/r*100.0%
associate-*l*100.0%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in t around 0 76.1%
sin-atan24.5%
div-inv22.8%
hypot-1-def35.4%
*-un-lft-identity35.4%
associate-/r*35.4%
times-frac35.6%
associate-/r*35.6%
Applied egg-rr35.6%
Taylor expanded in eh around inf 76.3%
Final simplification66.4%
(FPCore (eh ew t) :precision binary64 (if (<= eh -2.7e-169) (- eh) (if (<= eh -1.7e-266) (fabs (* ew t)) (fabs eh))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -2.7e-169) {
tmp = -eh;
} else if (eh <= -1.7e-266) {
tmp = fabs((ew * t));
} else {
tmp = fabs(eh);
}
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 <= (-2.7d-169)) then
tmp = -eh
else if (eh <= (-1.7d-266)) then
tmp = abs((ew * t))
else
tmp = abs(eh)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -2.7e-169) {
tmp = -eh;
} else if (eh <= -1.7e-266) {
tmp = Math.abs((ew * t));
} else {
tmp = Math.abs(eh);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -2.7e-169: tmp = -eh elif eh <= -1.7e-266: tmp = math.fabs((ew * t)) else: tmp = math.fabs(eh) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -2.7e-169) tmp = Float64(-eh); elseif (eh <= -1.7e-266) tmp = abs(Float64(ew * t)); else tmp = abs(eh); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -2.7e-169) tmp = -eh; elseif (eh <= -1.7e-266) tmp = abs((ew * t)); else tmp = abs(eh); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -2.7e-169], (-eh), If[LessEqual[eh, -1.7e-266], N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -2.7 \cdot 10^{-169}:\\
\;\;\;\;-eh\\
\mathbf{elif}\;eh \leq -1.7 \cdot 10^{-266}:\\
\;\;\;\;\left|ew \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\
\end{array}
\end{array}
if eh < -2.7000000000000002e-169Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in t around 0 55.5%
add-sqr-sqrt24.7%
fabs-sqr24.7%
add-sqr-sqrt25.5%
*-commutative25.5%
Applied egg-rr25.5%
*-commutative25.5%
/-rgt-identity25.5%
sin-atan6.7%
hypot-1-def11.6%
frac-times7.4%
*-un-lft-identity7.4%
Applied egg-rr7.4%
associate-*r/7.0%
unpow27.0%
associate-/r*7.2%
associate-/r*7.1%
Simplified7.1%
Taylor expanded in eh around -inf 55.8%
neg-mul-155.8%
Simplified55.8%
if -2.7000000000000002e-169 < eh < -1.69999999999999997e-266Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in t around 0 72.9%
+-commutative72.9%
fma-define72.9%
Simplified72.9%
cos-atan72.8%
hypot-1-def72.8%
associate-/r*72.8%
un-div-inv72.9%
associate-/r*72.9%
Applied egg-rr72.9%
*-lft-identity72.9%
times-frac72.9%
associate-*l/72.9%
*-lft-identity72.9%
Simplified72.9%
Taylor expanded in ew around inf 62.2%
*-commutative62.2%
Simplified62.2%
if -1.69999999999999997e-266 < eh Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in t around 0 43.5%
sin-atan18.6%
div-inv17.1%
hypot-1-def20.7%
*-un-lft-identity20.7%
associate-/r*20.7%
times-frac21.0%
associate-/r*21.0%
Applied egg-rr21.0%
Taylor expanded in eh around inf 44.0%
Final simplification50.2%
(FPCore (eh ew t) :precision binary64 (fabs eh))
double code(double eh, double ew, double t) {
return fabs(eh);
}
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)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(eh);
}
def code(eh, ew, t): return math.fabs(eh)
function code(eh, ew, t) return abs(eh) end
function tmp = code(eh, ew, t) tmp = abs(eh); end
code[eh_, ew_, t_] := N[Abs[eh], $MachinePrecision]
\begin{array}{l}
\\
\left|eh\right|
\end{array}
Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in t around 0 45.2%
sin-atan15.9%
div-inv15.1%
hypot-1-def22.7%
*-un-lft-identity22.7%
associate-/r*22.7%
times-frac23.0%
associate-/r*22.9%
Applied egg-rr22.9%
Taylor expanded in eh around inf 45.6%
(FPCore (eh ew t) :precision binary64 (if (<= eh -1e-310) (- eh) eh))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1e-310) {
tmp = -eh;
} else {
tmp = eh;
}
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 <= (-1d-310)) then
tmp = -eh
else
tmp = eh
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1e-310) {
tmp = -eh;
} else {
tmp = eh;
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -1e-310: tmp = -eh else: tmp = eh return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -1e-310) tmp = Float64(-eh); else tmp = eh; end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -1e-310) tmp = -eh; else tmp = eh; end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -1e-310], (-eh), eh]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1 \cdot 10^{-310}:\\
\;\;\;\;-eh\\
\mathbf{else}:\\
\;\;\;\;eh\\
\end{array}
\end{array}
if eh < -9.999999999999969e-311Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in t around 0 47.4%
add-sqr-sqrt20.6%
fabs-sqr20.6%
add-sqr-sqrt21.6%
*-commutative21.6%
Applied egg-rr21.6%
*-commutative21.6%
/-rgt-identity21.6%
sin-atan6.7%
hypot-1-def10.4%
frac-times7.3%
*-un-lft-identity7.3%
Applied egg-rr7.3%
associate-*r/6.2%
unpow26.2%
associate-/r*6.6%
associate-/r*6.5%
Simplified6.5%
Taylor expanded in eh around -inf 47.9%
neg-mul-147.9%
Simplified47.9%
if -9.999999999999969e-311 < eh Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in t around 0 42.8%
sin-atan18.2%
div-inv17.4%
hypot-1-def21.3%
*-un-lft-identity21.3%
associate-/r*21.3%
times-frac21.5%
associate-/r*21.6%
Applied egg-rr21.6%
Taylor expanded in eh around inf 43.2%
add-sqr-sqrt43.0%
fabs-sqr43.0%
add-sqr-sqrt43.2%
*-un-lft-identity43.2%
Applied egg-rr43.2%
Final simplification45.6%
(FPCore (eh ew t) :precision binary64 (- eh))
double code(double eh, double ew, double t) {
return -eh;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = -eh
end function
public static double code(double eh, double ew, double t) {
return -eh;
}
def code(eh, ew, t): return -eh
function code(eh, ew, t) return Float64(-eh) end
function tmp = code(eh, ew, t) tmp = -eh; end
code[eh_, ew_, t_] := (-eh)
\begin{array}{l}
\\
-eh
\end{array}
Initial program 99.9%
associate-*l*99.9%
fma-define99.9%
associate-/r*99.9%
associate-*l*99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in t around 0 45.2%
add-sqr-sqrt20.4%
fabs-sqr20.4%
add-sqr-sqrt21.4%
*-commutative21.4%
Applied egg-rr21.4%
*-commutative21.4%
/-rgt-identity21.4%
sin-atan6.9%
hypot-1-def9.7%
frac-times8.0%
*-un-lft-identity8.0%
Applied egg-rr8.0%
associate-*r/6.6%
unpow26.6%
associate-/r*6.8%
associate-/r*6.8%
Simplified6.8%
Taylor expanded in eh around -inf 25.2%
neg-mul-125.2%
Simplified25.2%
herbie shell --seed 2024170
(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))))))))