
(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 9 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
(let* ((t_1 (/ (tan t) ew))
(t_2 (* (- eh) t_1))
(t_3 (* ew (cos t)))
(t_4 (fabs (* eh (- (/ t_3 eh) (* (sin t) (sin (atan t_2))))))))
(if (<= eh -2e-41)
t_4
(if (<= eh 0.46)
(fabs
(/ (+ t_3 (* eh (* (sin t) (* eh t_1)))) (sqrt (+ 1.0 (pow t_2 2.0)))))
t_4))))
double code(double eh, double ew, double t) {
double t_1 = tan(t) / ew;
double t_2 = -eh * t_1;
double t_3 = ew * cos(t);
double t_4 = fabs((eh * ((t_3 / eh) - (sin(t) * sin(atan(t_2))))));
double tmp;
if (eh <= -2e-41) {
tmp = t_4;
} else if (eh <= 0.46) {
tmp = fabs(((t_3 + (eh * (sin(t) * (eh * t_1)))) / sqrt((1.0 + pow(t_2, 2.0)))));
} else {
tmp = t_4;
}
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) :: t_3
real(8) :: t_4
real(8) :: tmp
t_1 = tan(t) / ew
t_2 = -eh * t_1
t_3 = ew * cos(t)
t_4 = abs((eh * ((t_3 / eh) - (sin(t) * sin(atan(t_2))))))
if (eh <= (-2d-41)) then
tmp = t_4
else if (eh <= 0.46d0) then
tmp = abs(((t_3 + (eh * (sin(t) * (eh * t_1)))) / sqrt((1.0d0 + (t_2 ** 2.0d0)))))
else
tmp = t_4
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.tan(t) / ew;
double t_2 = -eh * t_1;
double t_3 = ew * Math.cos(t);
double t_4 = Math.abs((eh * ((t_3 / eh) - (Math.sin(t) * Math.sin(Math.atan(t_2))))));
double tmp;
if (eh <= -2e-41) {
tmp = t_4;
} else if (eh <= 0.46) {
tmp = Math.abs(((t_3 + (eh * (Math.sin(t) * (eh * t_1)))) / Math.sqrt((1.0 + Math.pow(t_2, 2.0)))));
} else {
tmp = t_4;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.tan(t) / ew t_2 = -eh * t_1 t_3 = ew * math.cos(t) t_4 = math.fabs((eh * ((t_3 / eh) - (math.sin(t) * math.sin(math.atan(t_2)))))) tmp = 0 if eh <= -2e-41: tmp = t_4 elif eh <= 0.46: tmp = math.fabs(((t_3 + (eh * (math.sin(t) * (eh * t_1)))) / math.sqrt((1.0 + math.pow(t_2, 2.0))))) else: tmp = t_4 return tmp
function code(eh, ew, t) t_1 = Float64(tan(t) / ew) t_2 = Float64(Float64(-eh) * t_1) t_3 = Float64(ew * cos(t)) t_4 = abs(Float64(eh * Float64(Float64(t_3 / eh) - Float64(sin(t) * sin(atan(t_2)))))) tmp = 0.0 if (eh <= -2e-41) tmp = t_4; elseif (eh <= 0.46) tmp = abs(Float64(Float64(t_3 + Float64(eh * Float64(sin(t) * Float64(eh * t_1)))) / sqrt(Float64(1.0 + (t_2 ^ 2.0))))); else tmp = t_4; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = tan(t) / ew; t_2 = -eh * t_1; t_3 = ew * cos(t); t_4 = abs((eh * ((t_3 / eh) - (sin(t) * sin(atan(t_2)))))); tmp = 0.0; if (eh <= -2e-41) tmp = t_4; elseif (eh <= 0.46) tmp = abs(((t_3 + (eh * (sin(t) * (eh * t_1)))) / sqrt((1.0 + (t_2 ^ 2.0))))); else tmp = t_4; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[((-eh) * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Abs[N[(eh * N[(N[(t$95$3 / eh), $MachinePrecision] - N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[t$95$2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2e-41], t$95$4, If[LessEqual[eh, 0.46], N[Abs[N[(N[(t$95$3 + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[(eh * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$4]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew}\\
t_2 := \left(-eh\right) \cdot t\_1\\
t_3 := ew \cdot \cos t\\
t_4 := \left|eh \cdot \left(\frac{t\_3}{eh} - \sin t \cdot \sin \tan^{-1} t\_2\right)\right|\\
\mathbf{if}\;eh \leq -2 \cdot 10^{-41}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;eh \leq 0.46:\\
\;\;\;\;\left|\frac{t\_3 + eh \cdot \left(\sin t \cdot \left(eh \cdot t\_1\right)\right)}{\sqrt{1 + {t\_2}^{2}}}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if eh < -2.00000000000000001e-41 or 0.46000000000000002 < eh Initial program 99.9%
Applied rewrites54.7%
Applied rewrites70.9%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites87.2%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites99.8%
if -2.00000000000000001e-41 < eh < 0.46000000000000002Initial program 99.8%
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (- (cos t)))
(t_2 (* (sin t) (sin (atan (* (- eh) (/ (tan t) ew)))))))
(if (<= ew -9e-15)
(fabs (* ew (fma eh (/ t_2 ew) t_1)))
(if (<= ew 1e-17)
(fabs (* eh (- (/ (* ew (cos t)) eh) t_2)))
(fabs
(*
ew
(fma eh (/ (* (sin t) (sin (atan (- (/ (* t eh) ew))))) ew) t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = -cos(t);
double t_2 = sin(t) * sin(atan((-eh * (tan(t) / ew))));
double tmp;
if (ew <= -9e-15) {
tmp = fabs((ew * fma(eh, (t_2 / ew), t_1)));
} else if (ew <= 1e-17) {
tmp = fabs((eh * (((ew * cos(t)) / eh) - t_2)));
} else {
tmp = fabs((ew * fma(eh, ((sin(t) * sin(atan(-((t * eh) / ew)))) / ew), t_1)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(-cos(t)) t_2 = Float64(sin(t) * sin(atan(Float64(Float64(-eh) * Float64(tan(t) / ew))))) tmp = 0.0 if (ew <= -9e-15) tmp = abs(Float64(ew * fma(eh, Float64(t_2 / ew), t_1))); elseif (ew <= 1e-17) tmp = abs(Float64(eh * Float64(Float64(Float64(ew * cos(t)) / eh) - t_2))); else tmp = abs(Float64(ew * fma(eh, Float64(Float64(sin(t) * sin(atan(Float64(-Float64(Float64(t * eh) / ew))))) / ew), t_1))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = (-N[Cos[t], $MachinePrecision])}, Block[{t$95$2 = N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -9e-15], N[Abs[N[(ew * N[(eh * N[(t$95$2 / ew), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 1e-17], N[Abs[N[(eh * N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / eh), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[(eh * N[(N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[(-N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -\cos t\\
t_2 := \sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\\
\mathbf{if}\;ew \leq -9 \cdot 10^{-15}:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(eh, \frac{t\_2}{ew}, t\_1\right)\right|\\
\mathbf{elif}\;ew \leq 10^{-17}:\\
\;\;\;\;\left|eh \cdot \left(\frac{ew \cdot \cos t}{eh} - t\_2\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(eh, \frac{\sin t \cdot \sin \tan^{-1} \left(-\frac{t \cdot eh}{ew}\right)}{ew}, t\_1\right)\right|\\
\end{array}
\end{array}
if ew < -8.9999999999999995e-15Initial program 99.8%
Applied rewrites90.2%
Applied rewrites36.8%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites99.8%
if -8.9999999999999995e-15 < ew < 1.00000000000000007e-17Initial program 99.9%
Applied rewrites57.5%
Applied rewrites71.3%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites84.5%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites98.8%
if 1.00000000000000007e-17 < ew Initial program 99.9%
Applied rewrites93.7%
Applied rewrites64.8%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites99.4%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6499.4
Applied rewrites99.4%
Final simplification99.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
ew
(fma
eh
(/ (* (sin t) (sin (atan (- (/ (* t eh) ew))))) ew)
(- (cos t)))))))
(if (<= ew -9e-15)
t_1
(if (<= ew 1e-17)
(fabs
(*
eh
(-
(/ (* ew (cos t)) eh)
(* (sin t) (sin (atan (* (- eh) (/ (tan t) ew))))))))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * fma(eh, ((sin(t) * sin(atan(-((t * eh) / ew)))) / ew), -cos(t))));
double tmp;
if (ew <= -9e-15) {
tmp = t_1;
} else if (ew <= 1e-17) {
tmp = fabs((eh * (((ew * cos(t)) / eh) - (sin(t) * sin(atan((-eh * (tan(t) / ew))))))));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(ew * fma(eh, Float64(Float64(sin(t) * sin(atan(Float64(-Float64(Float64(t * eh) / ew))))) / ew), Float64(-cos(t))))) tmp = 0.0 if (ew <= -9e-15) tmp = t_1; elseif (ew <= 1e-17) tmp = abs(Float64(eh * Float64(Float64(Float64(ew * cos(t)) / eh) - Float64(sin(t) * sin(atan(Float64(Float64(-eh) * Float64(tan(t) / ew)))))))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[(eh * N[(N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[(-N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -9e-15], t$95$1, If[LessEqual[ew, 1e-17], N[Abs[N[(eh * N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / eh), $MachinePrecision] - N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \mathsf{fma}\left(eh, \frac{\sin t \cdot \sin \tan^{-1} \left(-\frac{t \cdot eh}{ew}\right)}{ew}, -\cos t\right)\right|\\
\mathbf{if}\;ew \leq -9 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 10^{-17}:\\
\;\;\;\;\left|eh \cdot \left(\frac{ew \cdot \cos t}{eh} - \sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -8.9999999999999995e-15 or 1.00000000000000007e-17 < ew Initial program 99.8%
Applied rewrites92.1%
Applied rewrites52.1%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites99.5%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
if -8.9999999999999995e-15 < ew < 1.00000000000000007e-17Initial program 99.9%
Applied rewrites57.5%
Applied rewrites71.3%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites84.5%
Taylor expanded in eh around inf
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites98.8%
Final simplification99.2%
(FPCore (eh ew t)
:precision binary64
(if (<= eh -2.6e+227)
(fabs (* eh (sin t)))
(fabs
(*
ew
(fma
eh
(/ (* (sin t) (sin (atan (- (/ (* t eh) ew))))) ew)
(- (cos t)))))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -2.6e+227) {
tmp = fabs((eh * sin(t)));
} else {
tmp = fabs((ew * fma(eh, ((sin(t) * sin(atan(-((t * eh) / ew)))) / ew), -cos(t))));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (eh <= -2.6e+227) tmp = abs(Float64(eh * sin(t))); else tmp = abs(Float64(ew * fma(eh, Float64(Float64(sin(t) * sin(atan(Float64(-Float64(Float64(t * eh) / ew))))) / ew), Float64(-cos(t))))); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[eh, -2.6e+227], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[(eh * N[(N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[(-N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -2.6 \cdot 10^{+227}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(eh, \frac{\sin t \cdot \sin \tan^{-1} \left(-\frac{t \cdot eh}{ew}\right)}{ew}, -\cos t\right)\right|\\
\end{array}
\end{array}
if eh < -2.59999999999999982e227Initial program 99.8%
Applied rewrites14.3%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6493.4
Applied rewrites93.4%
if -2.59999999999999982e227 < eh Initial program 99.9%
Applied rewrites79.9%
Applied rewrites58.6%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites94.4%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6494.3
Applied rewrites94.3%
Final simplification94.2%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* ew (cos t))))) (if (<= ew -1.3e+23) t_1 (if (<= ew 4.5e-11) (fabs (* eh (sin t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * cos(t)));
double tmp;
if (ew <= -1.3e+23) {
tmp = t_1;
} else if (ew <= 4.5e-11) {
tmp = fabs((eh * sin(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((ew * cos(t)))
if (ew <= (-1.3d+23)) then
tmp = t_1
else if (ew <= 4.5d-11) then
tmp = abs((eh * sin(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((ew * Math.cos(t)));
double tmp;
if (ew <= -1.3e+23) {
tmp = t_1;
} else if (ew <= 4.5e-11) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((ew * math.cos(t))) tmp = 0 if ew <= -1.3e+23: tmp = t_1 elif ew <= 4.5e-11: tmp = math.fabs((eh * math.sin(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(ew * cos(t))) tmp = 0.0 if (ew <= -1.3e+23) tmp = t_1; elseif (ew <= 4.5e-11) tmp = abs(Float64(eh * sin(t))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((ew * cos(t))); tmp = 0.0; if (ew <= -1.3e+23) tmp = t_1; elseif (ew <= 4.5e-11) tmp = abs((eh * sin(t))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -1.3e+23], t$95$1, If[LessEqual[ew, 4.5e-11], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -1.3 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 4.5 \cdot 10^{-11}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -1.29999999999999996e23 or 4.5e-11 < ew Initial program 99.8%
Applied rewrites94.0%
Taylor expanded in ew around inf
lower-*.f64N/A
lower-cos.f6488.3
Applied rewrites88.3%
if -1.29999999999999996e23 < ew < 4.5e-11Initial program 99.9%
Applied rewrites57.5%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6470.4
Applied rewrites70.4%
(FPCore (eh ew t) :precision binary64 (if (<= ew -1.6e+31) (fabs ew) (if (<= ew 2e+132) (fabs (* eh (sin t))) (fabs ew))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= -1.6e+31) {
tmp = fabs(ew);
} else if (ew <= 2e+132) {
tmp = fabs((eh * sin(t)));
} else {
tmp = fabs(ew);
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if (ew <= (-1.6d+31)) then
tmp = abs(ew)
else if (ew <= 2d+132) then
tmp = abs((eh * sin(t)))
else
tmp = abs(ew)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (ew <= -1.6e+31) {
tmp = Math.abs(ew);
} else if (ew <= 2e+132) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if ew <= -1.6e+31: tmp = math.fabs(ew) elif ew <= 2e+132: tmp = math.fabs((eh * math.sin(t))) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if (ew <= -1.6e+31) tmp = abs(ew); elseif (ew <= 2e+132) tmp = abs(Float64(eh * sin(t))); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (ew <= -1.6e+31) tmp = abs(ew); elseif (ew <= 2e+132) tmp = abs((eh * sin(t))); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[ew, -1.6e+31], N[Abs[ew], $MachinePrecision], If[LessEqual[ew, 2e+132], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.6 \cdot 10^{+31}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{elif}\;ew \leq 2 \cdot 10^{+132}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if ew < -1.6e31 or 1.99999999999999998e132 < ew Initial program 99.9%
Applied rewrites97.0%
Applied rewrites52.1%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in t around 0
Applied rewrites59.3%
if -1.6e31 < ew < 1.99999999999999998e132Initial program 99.8%
Applied rewrites63.3%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6463.3
Applied rewrites63.3%
Final simplification61.8%
(FPCore (eh ew t) :precision binary64 (if (<= ew -6.5e-112) (fabs ew) (if (<= ew 1.28e-194) (fabs (* t eh)) (fabs ew))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= -6.5e-112) {
tmp = fabs(ew);
} else if (ew <= 1.28e-194) {
tmp = fabs((t * eh));
} else {
tmp = fabs(ew);
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if (ew <= (-6.5d-112)) then
tmp = abs(ew)
else if (ew <= 1.28d-194) then
tmp = abs((t * eh))
else
tmp = abs(ew)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (ew <= -6.5e-112) {
tmp = Math.abs(ew);
} else if (ew <= 1.28e-194) {
tmp = Math.abs((t * eh));
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if ew <= -6.5e-112: tmp = math.fabs(ew) elif ew <= 1.28e-194: tmp = math.fabs((t * eh)) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if (ew <= -6.5e-112) tmp = abs(ew); elseif (ew <= 1.28e-194) tmp = abs(Float64(t * eh)); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (ew <= -6.5e-112) tmp = abs(ew); elseif (ew <= 1.28e-194) tmp = abs((t * eh)); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[ew, -6.5e-112], N[Abs[ew], $MachinePrecision], If[LessEqual[ew, 1.28e-194], N[Abs[N[(t * eh), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -6.5 \cdot 10^{-112}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{elif}\;ew \leq 1.28 \cdot 10^{-194}:\\
\;\;\;\;\left|t \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if ew < -6.49999999999999956e-112 or 1.2800000000000001e-194 < ew Initial program 99.8%
Applied rewrites86.7%
Applied rewrites55.8%
Taylor expanded in ew around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-fma.f64N/A
Applied rewrites97.8%
Taylor expanded in t around 0
Applied rewrites46.5%
if -6.49999999999999956e-112 < ew < 1.2800000000000001e-194Initial program 99.9%
Applied rewrites47.0%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6481.6
Applied rewrites81.6%
Taylor expanded in t around 0
lower-*.f6446.4
Applied rewrites46.4%
Final simplification46.4%
(FPCore (eh ew t) :precision binary64 (fabs (* t eh)))
double code(double eh, double ew, double t) {
return fabs((t * 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((t * eh))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((t * eh));
}
def code(eh, ew, t): return math.fabs((t * eh))
function code(eh, ew, t) return abs(Float64(t * eh)) end
function tmp = code(eh, ew, t) tmp = abs((t * eh)); end
code[eh_, ew_, t_] := N[Abs[N[(t * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|t \cdot eh\right|
\end{array}
Initial program 99.8%
Applied rewrites76.0%
Taylor expanded in ew around 0
lower-*.f64N/A
lower-sin.f6442.5
Applied rewrites42.5%
Taylor expanded in t around 0
lower-*.f6421.0
Applied rewrites21.0%
Final simplification21.0%
herbie shell --seed 2024219
(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)))))))