
(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 12 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 (- (* (* 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(eh * tan(t)) / Float64(-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{eh \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}
Initial program 99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (- (* eh (sin t))) (sin (atan (/ (* eh (tan t)) (- ew)))) (* ew (cos t)))))
double code(double eh, double ew, double t) {
return fabs(fma(-(eh * sin(t)), sin(atan(((eh * tan(t)) / -ew))), (ew * cos(t))));
}
function code(eh, ew, t) return abs(fma(Float64(-Float64(eh * sin(t))), sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew)))), Float64(ew * cos(t)))) end
code[eh_, ew_, t_] := N[Abs[N[((-N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]) * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(-eh \cdot \sin t, \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right), ew \cdot \cos t\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites41.4%
Taylor expanded in eh around 0
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites98.5%
(FPCore (eh ew t) :precision binary64 (fabs (fma (- (* eh (sin t))) (sin (atan (/ (* t eh) (- ew)))) (* ew (cos t)))))
double code(double eh, double ew, double t) {
return fabs(fma(-(eh * sin(t)), sin(atan(((t * eh) / -ew))), (ew * cos(t))));
}
function code(eh, ew, t) return abs(fma(Float64(-Float64(eh * sin(t))), sin(atan(Float64(Float64(t * eh) / Float64(-ew)))), Float64(ew * cos(t)))) end
code[eh_, ew_, t_] := N[Abs[N[((-N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]) * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(-eh \cdot \sin t, \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right), ew \cdot \cos t\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites41.4%
Taylor expanded in eh around 0
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites98.5%
Taylor expanded in t around 0
Applied rewrites98.5%
Final simplification98.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (* t eh) ew)) (t_2 (* eh (sin t))))
(if (<= eh -1.05e+117)
(fabs
(*
eh
(fma
0.5
(* (/ ew eh) (/ (* ew (fma 0.5 (cos (+ t t)) 0.5)) t_2))
(sin t))))
(if (<= eh 6.8e+35)
(fabs
(fma
(/ (* t eh) (* (- ew) (sqrt (fma t_1 t_1 1.0))))
(- t_2)
(* ew (cos t))))
(fabs (* eh (fma 0.5 (* (/ ew eh) (/ (* ew 1.0) t_2)) (sin t))))))))
double code(double eh, double ew, double t) {
double t_1 = (t * eh) / ew;
double t_2 = eh * sin(t);
double tmp;
if (eh <= -1.05e+117) {
tmp = fabs((eh * fma(0.5, ((ew / eh) * ((ew * fma(0.5, cos((t + t)), 0.5)) / t_2)), sin(t))));
} else if (eh <= 6.8e+35) {
tmp = fabs(fma(((t * eh) / (-ew * sqrt(fma(t_1, t_1, 1.0)))), -t_2, (ew * cos(t))));
} else {
tmp = fabs((eh * fma(0.5, ((ew / eh) * ((ew * 1.0) / t_2)), sin(t))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(t * eh) / ew) t_2 = Float64(eh * sin(t)) tmp = 0.0 if (eh <= -1.05e+117) tmp = abs(Float64(eh * fma(0.5, Float64(Float64(ew / eh) * Float64(Float64(ew * fma(0.5, cos(Float64(t + t)), 0.5)) / t_2)), sin(t)))); elseif (eh <= 6.8e+35) tmp = abs(fma(Float64(Float64(t * eh) / Float64(Float64(-ew) * sqrt(fma(t_1, t_1, 1.0)))), Float64(-t_2), Float64(ew * cos(t)))); else tmp = abs(Float64(eh * fma(0.5, Float64(Float64(ew / eh) * Float64(Float64(ew * 1.0) / t_2)), sin(t)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eh, -1.05e+117], N[Abs[N[(eh * N[(0.5 * N[(N[(ew / eh), $MachinePrecision] * N[(N[(ew * N[(0.5 * N[Cos[N[(t + t), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 6.8e+35], N[Abs[N[(N[(N[(t * eh), $MachinePrecision] / N[((-ew) * N[Sqrt[N[(t$95$1 * t$95$1 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-t$95$2) + N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[(0.5 * N[(N[(ew / eh), $MachinePrecision] * N[(N[(ew * 1.0), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t \cdot eh}{ew}\\
t_2 := eh \cdot \sin t\\
\mathbf{if}\;eh \leq -1.05 \cdot 10^{+117}:\\
\;\;\;\;\left|eh \cdot \mathsf{fma}\left(0.5, \frac{ew}{eh} \cdot \frac{ew \cdot \mathsf{fma}\left(0.5, \cos \left(t + t\right), 0.5\right)}{t\_2}, \sin t\right)\right|\\
\mathbf{elif}\;eh \leq 6.8 \cdot 10^{+35}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{t \cdot eh}{\left(-ew\right) \cdot \sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}}, -t\_2, ew \cdot \cos t\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \mathsf{fma}\left(0.5, \frac{ew}{eh} \cdot \frac{ew \cdot 1}{t\_2}, \sin t\right)\right|\\
\end{array}
\end{array}
if eh < -1.0500000000000001e117Initial program 99.9%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites44.2%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites76.0%
Applied rewrites79.8%
if -1.0500000000000001e117 < eh < 6.8000000000000002e35Initial program 99.8%
Applied rewrites53.1%
Taylor expanded in eh around 0
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites98.6%
Taylor expanded in t around 0
Applied rewrites98.5%
Applied rewrites87.9%
if 6.8000000000000002e35 < eh Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites43.3%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites83.1%
Applied rewrites83.5%
Taylor expanded in t around 0
Applied rewrites85.4%
Final simplification86.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (sin t)))
(t_2 (fabs (* eh (fma 0.5 (* (/ ew eh) (/ (* ew 1.0) t_1)) (sin t)))))
(t_3 (/ (* t eh) ew)))
(if (<= eh -1e+117)
t_2
(if (<= eh 6.8e+35)
(fabs
(fma
(/ (* t eh) (* (- ew) (sqrt (fma t_3 t_3 1.0))))
(- t_1)
(* ew (cos t))))
t_2))))
double code(double eh, double ew, double t) {
double t_1 = eh * sin(t);
double t_2 = fabs((eh * fma(0.5, ((ew / eh) * ((ew * 1.0) / t_1)), sin(t))));
double t_3 = (t * eh) / ew;
double tmp;
if (eh <= -1e+117) {
tmp = t_2;
} else if (eh <= 6.8e+35) {
tmp = fabs(fma(((t * eh) / (-ew * sqrt(fma(t_3, t_3, 1.0)))), -t_1, (ew * cos(t))));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh * sin(t)) t_2 = abs(Float64(eh * fma(0.5, Float64(Float64(ew / eh) * Float64(Float64(ew * 1.0) / t_1)), sin(t)))) t_3 = Float64(Float64(t * eh) / ew) tmp = 0.0 if (eh <= -1e+117) tmp = t_2; elseif (eh <= 6.8e+35) tmp = abs(fma(Float64(Float64(t * eh) / Float64(Float64(-ew) * sqrt(fma(t_3, t_3, 1.0)))), Float64(-t_1), Float64(ew * cos(t)))); else tmp = t_2; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(eh * N[(0.5 * N[(N[(ew / eh), $MachinePrecision] * N[(N[(ew * 1.0), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision]}, If[LessEqual[eh, -1e+117], t$95$2, If[LessEqual[eh, 6.8e+35], N[Abs[N[(N[(N[(t * eh), $MachinePrecision] / N[((-ew) * N[Sqrt[N[(t$95$3 * t$95$3 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-t$95$1) + N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \sin t\\
t_2 := \left|eh \cdot \mathsf{fma}\left(0.5, \frac{ew}{eh} \cdot \frac{ew \cdot 1}{t\_1}, \sin t\right)\right|\\
t_3 := \frac{t \cdot eh}{ew}\\
\mathbf{if}\;eh \leq -1 \cdot 10^{+117}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;eh \leq 6.8 \cdot 10^{+35}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{t \cdot eh}{\left(-ew\right) \cdot \sqrt{\mathsf{fma}\left(t\_3, t\_3, 1\right)}}, -t\_1, ew \cdot \cos t\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if eh < -1.00000000000000005e117 or 6.8000000000000002e35 < eh Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites43.7%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites79.9%
Applied rewrites81.8%
Taylor expanded in t around 0
Applied rewrites82.9%
if -1.00000000000000005e117 < eh < 6.8000000000000002e35Initial program 99.8%
Applied rewrites53.1%
Taylor expanded in eh around 0
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites98.6%
Taylor expanded in t around 0
Applied rewrites98.5%
Applied rewrites87.9%
Final simplification86.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
eh
(fma 0.5 (* (/ ew eh) (/ (* ew 1.0) (* eh (sin t)))) (sin t))))))
(if (<= eh -2.2e+91) t_1 (if (<= eh 6.8e+35) (fabs (* ew (cos t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * fma(0.5, ((ew / eh) * ((ew * 1.0) / (eh * sin(t)))), sin(t))));
double tmp;
if (eh <= -2.2e+91) {
tmp = t_1;
} else if (eh <= 6.8e+35) {
tmp = fabs((ew * cos(t)));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(eh * fma(0.5, Float64(Float64(ew / eh) * Float64(Float64(ew * 1.0) / Float64(eh * sin(t)))), sin(t)))) tmp = 0.0 if (eh <= -2.2e+91) tmp = t_1; elseif (eh <= 6.8e+35) tmp = abs(Float64(ew * cos(t))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[(0.5 * N[(N[(ew / eh), $MachinePrecision] * N[(N[(ew * 1.0), $MachinePrecision] / N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2.2e+91], t$95$1, If[LessEqual[eh, 6.8e+35], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \mathsf{fma}\left(0.5, \frac{ew}{eh} \cdot \frac{ew \cdot 1}{eh \cdot \sin t}, \sin t\right)\right|\\
\mathbf{if}\;eh \leq -2.2 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 6.8 \cdot 10^{+35}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -2.19999999999999999e91 or 6.8000000000000002e35 < eh Initial program 99.9%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites46.0%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites79.8%
Applied rewrites81.6%
Taylor expanded in t around 0
Applied rewrites82.6%
if -2.19999999999999999e91 < eh < 6.8000000000000002e35Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites94.3%
Taylor expanded in ew around inf
lower-*.f64N/A
lower-cos.f6477.2
Applied rewrites77.2%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* eh (fma 0.5 (* (/ ew eh) (/ ew (* t eh))) (sin t)))))) (if (<= eh -2.2e+91) t_1 (if (<= eh 6.8e+35) (fabs (* ew (cos t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * fma(0.5, ((ew / eh) * (ew / (t * eh))), sin(t))));
double tmp;
if (eh <= -2.2e+91) {
tmp = t_1;
} else if (eh <= 6.8e+35) {
tmp = fabs((ew * cos(t)));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(eh * fma(0.5, Float64(Float64(ew / eh) * Float64(ew / Float64(t * eh))), sin(t)))) tmp = 0.0 if (eh <= -2.2e+91) tmp = t_1; elseif (eh <= 6.8e+35) tmp = abs(Float64(ew * cos(t))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[(0.5 * N[(N[(ew / eh), $MachinePrecision] * N[(ew / N[(t * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2.2e+91], t$95$1, If[LessEqual[eh, 6.8e+35], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \mathsf{fma}\left(0.5, \frac{ew}{eh} \cdot \frac{ew}{t \cdot eh}, \sin t\right)\right|\\
\mathbf{if}\;eh \leq -2.2 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 6.8 \cdot 10^{+35}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -2.19999999999999999e91 or 6.8000000000000002e35 < eh Initial program 99.9%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites46.0%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites79.8%
Applied rewrites81.6%
Taylor expanded in t around 0
Applied rewrites82.5%
if -2.19999999999999999e91 < eh < 6.8000000000000002e35Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites94.3%
Taylor expanded in ew around inf
lower-*.f64N/A
lower-cos.f6477.2
Applied rewrites77.2%
Final simplification79.2%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* eh (sin t))))) (if (<= eh -2.2e+91) t_1 (if (<= eh 6.8e+35) (fabs (* ew (cos t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * sin(t)));
double tmp;
if (eh <= -2.2e+91) {
tmp = t_1;
} else if (eh <= 6.8e+35) {
tmp = fabs((ew * cos(t)));
} else {
tmp = 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 = abs((eh * sin(t)))
if (eh <= (-2.2d+91)) then
tmp = t_1
else if (eh <= 6.8d+35) then
tmp = abs((ew * cos(t)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((eh * Math.sin(t)));
double tmp;
if (eh <= -2.2e+91) {
tmp = t_1;
} else if (eh <= 6.8e+35) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((eh * math.sin(t))) tmp = 0 if eh <= -2.2e+91: tmp = t_1 elif eh <= 6.8e+35: tmp = math.fabs((ew * math.cos(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(eh * sin(t))) tmp = 0.0 if (eh <= -2.2e+91) tmp = t_1; elseif (eh <= 6.8e+35) tmp = abs(Float64(ew * cos(t))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((eh * sin(t))); tmp = 0.0; if (eh <= -2.2e+91) tmp = t_1; elseif (eh <= 6.8e+35) tmp = abs((ew * cos(t))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2.2e+91], t$95$1, If[LessEqual[eh, 6.8e+35], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \sin t\right|\\
\mathbf{if}\;eh \leq -2.2 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 6.8 \cdot 10^{+35}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -2.19999999999999999e91 or 6.8000000000000002e35 < eh Initial program 99.9%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites46.0%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6482.1
Applied rewrites82.1%
if -2.19999999999999999e91 < eh < 6.8000000000000002e35Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites94.3%
Taylor expanded in ew around inf
lower-*.f64N/A
lower-cos.f6477.2
Applied rewrites77.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* eh (sin t)))))
(if (<= t -4.2e-49)
t_1
(if (<= t 1.16e-160) (fabs (fma (* t t) (* ew -0.5) ew)) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * sin(t)));
double tmp;
if (t <= -4.2e-49) {
tmp = t_1;
} else if (t <= 1.16e-160) {
tmp = fabs(fma((t * t), (ew * -0.5), ew));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(eh * sin(t))) tmp = 0.0 if (t <= -4.2e-49) tmp = t_1; elseif (t <= 1.16e-160) tmp = abs(fma(Float64(t * t), Float64(ew * -0.5), ew)); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -4.2e-49], t$95$1, If[LessEqual[t, 1.16e-160], N[Abs[N[(N[(t * t), $MachinePrecision] * N[(ew * -0.5), $MachinePrecision] + ew), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \sin t\right|\\
\mathbf{if}\;t \leq -4.2 \cdot 10^{-49}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.16 \cdot 10^{-160}:\\
\;\;\;\;\left|\mathsf{fma}\left(t \cdot t, ew \cdot -0.5, ew\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.1999999999999998e-49 or 1.16e-160 < t Initial program 99.7%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites67.9%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6460.4
Applied rewrites60.4%
if -4.1999999999999998e-49 < t < 1.16e-160Initial program 100.0%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites92.1%
Taylor expanded in t around 0
+-commutativeN/A
associate--l+N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
Applied rewrites75.6%
Taylor expanded in ew around inf
Applied rewrites80.9%
(FPCore (eh ew t)
:precision binary64
(if (<= eh 5.2e+31)
(fabs (fma (* t (* ew -0.5)) t ew))
(fabs
(/
(fma
(* eh (* t t))
(fma 0.5 (* (/ (* ew ew) (* eh eh)) -0.8333333333333334) 1.0)
(/ (* 0.5 (* ew ew)) eh))
t))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= 5.2e+31) {
tmp = fabs(fma((t * (ew * -0.5)), t, ew));
} else {
tmp = fabs((fma((eh * (t * t)), fma(0.5, (((ew * ew) / (eh * eh)) * -0.8333333333333334), 1.0), ((0.5 * (ew * ew)) / eh)) / t));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (eh <= 5.2e+31) tmp = abs(fma(Float64(t * Float64(ew * -0.5)), t, ew)); else tmp = abs(Float64(fma(Float64(eh * Float64(t * t)), fma(0.5, Float64(Float64(Float64(ew * ew) / Float64(eh * eh)) * -0.8333333333333334), 1.0), Float64(Float64(0.5 * Float64(ew * ew)) / eh)) / t)); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[eh, 5.2e+31], N[Abs[N[(N[(t * N[(ew * -0.5), $MachinePrecision]), $MachinePrecision] * t + ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(eh * N[(t * t), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(N[(N[(ew * ew), $MachinePrecision] / N[(eh * eh), $MachinePrecision]), $MachinePrecision] * -0.8333333333333334), $MachinePrecision] + 1.0), $MachinePrecision] + N[(N[(0.5 * N[(ew * ew), $MachinePrecision]), $MachinePrecision] / eh), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq 5.2 \cdot 10^{+31}:\\
\;\;\;\;\left|\mathsf{fma}\left(t \cdot \left(ew \cdot -0.5\right), t, ew\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(eh \cdot \left(t \cdot t\right), \mathsf{fma}\left(0.5, \frac{ew \cdot ew}{eh \cdot eh} \cdot -0.8333333333333334, 1\right), \frac{0.5 \cdot \left(ew \cdot ew\right)}{eh}\right)}{t}\right|\\
\end{array}
\end{array}
if eh < 5.2e31Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites84.2%
Taylor expanded in t around 0
+-commutativeN/A
associate--l+N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
Applied rewrites39.4%
Taylor expanded in ew around inf
Applied rewrites41.2%
Applied rewrites41.3%
if 5.2e31 < eh Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites46.4%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites80.5%
Taylor expanded in t around 0
Applied rewrites27.9%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* t (* ew -0.5)) t ew)))
double code(double eh, double ew, double t) {
return fabs(fma((t * (ew * -0.5)), t, ew));
}
function code(eh, ew, t) return abs(fma(Float64(t * Float64(ew * -0.5)), t, ew)) end
code[eh_, ew_, t_] := N[Abs[N[(N[(t * N[(ew * -0.5), $MachinePrecision]), $MachinePrecision] * t + ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(t \cdot \left(ew \cdot -0.5\right), t, ew\right)\right|
\end{array}
Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites76.2%
Taylor expanded in t around 0
+-commutativeN/A
associate--l+N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
Applied rewrites33.3%
Taylor expanded in ew around inf
Applied rewrites35.9%
Applied rewrites35.9%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* t t) (* ew -0.5) ew)))
double code(double eh, double ew, double t) {
return fabs(fma((t * t), (ew * -0.5), ew));
}
function code(eh, ew, t) return abs(fma(Float64(t * t), Float64(ew * -0.5), ew)) end
code[eh_, ew_, t_] := N[Abs[N[(N[(t * t), $MachinePrecision] * N[(ew * -0.5), $MachinePrecision] + ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(t \cdot t, ew \cdot -0.5, ew\right)\right|
\end{array}
Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites76.2%
Taylor expanded in t around 0
+-commutativeN/A
associate--l+N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
Applied rewrites33.3%
Taylor expanded in ew around inf
Applied rewrites35.9%
herbie shell --seed 2024233
(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)))))))