
(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 11 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 (- (* (* eh (sin t)) (sin t_1)) (* (* ew (cos t)) (cos t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
return fabs((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(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((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(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((((eh * Math.sin(t)) * Math.sin(t_1)) - ((ew * Math.cos(t)) * Math.cos(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh * math.tan(t)) / -ew)) return math.fabs((((eh * math.sin(t)) * math.sin(t_1)) - ((ew * math.cos(t)) * math.cos(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(t_1)) - Float64(Float64(ew * cos(t)) * cos(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh * tan(t)) / -ew)); tmp = abs((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(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[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[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(eh \cdot \sin t\right) \cdot \sin t\_1 - \left(ew \cdot \cos t\right) \cdot \cos t\_1\right|
\end{array}
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))) (t_2 (atan (/ (* eh (tan t)) (- ew)))))
(if (<= (- (* t_1 (cos t_2)) (* (* eh (sin t)) (sin t_2))) 1e-247)
(fabs
(* (cos (atan (/ (* (sin t) eh) (* (fma (* t t) -0.5 1.0) (- ew))))) ew))
t_1)))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double t_2 = atan(((eh * tan(t)) / -ew));
double tmp;
if (((t_1 * cos(t_2)) - ((eh * sin(t)) * sin(t_2))) <= 1e-247) {
tmp = fabs((cos(atan(((sin(t) * eh) / (fma((t * t), -0.5, 1.0) * -ew)))) * ew));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) t_2 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(t_1 * cos(t_2)) - Float64(Float64(eh * sin(t)) * sin(t_2))) <= 1e-247) tmp = abs(Float64(cos(atan(Float64(Float64(sin(t) * eh) / Float64(fma(Float64(t * t), -0.5, 1.0) * Float64(-ew))))) * ew)); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-247], N[Abs[N[(N[Cos[N[ArcTan[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] / N[(N[(N[(t * t), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;t\_1 \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2 \leq 10^{-247}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{\sin t \cdot eh}{\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot \left(-ew\right)}\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < 1e-247Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites44.6%
Taylor expanded in t around 0
Applied rewrites44.6%
Applied rewrites44.6%
if 1e-247 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.9%
Applied rewrites73.4%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6427.6
Applied rewrites27.6%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6461.8
Applied rewrites61.8%
Final simplification52.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))) (t_2 (atan (/ (* eh (tan t)) (- ew)))))
(if (<= (- (* t_1 (cos t_2)) (* (* eh (sin t)) (sin t_2))) -5e-295)
(fabs (* (cos (atan (* (/ (tan t) ew) eh))) ew))
t_1)))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double t_2 = atan(((eh * tan(t)) / -ew));
double tmp;
if (((t_1 * cos(t_2)) - ((eh * sin(t)) * sin(t_2))) <= -5e-295) {
tmp = fabs((cos(atan(((tan(t) / ew) * eh))) * ew));
} 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) :: t_2
real(8) :: tmp
t_1 = ew * cos(t)
t_2 = atan(((eh * tan(t)) / -ew))
if (((t_1 * cos(t_2)) - ((eh * sin(t)) * sin(t_2))) <= (-5d-295)) then
tmp = abs((cos(atan(((tan(t) / ew) * eh))) * ew))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.cos(t);
double t_2 = Math.atan(((eh * Math.tan(t)) / -ew));
double tmp;
if (((t_1 * Math.cos(t_2)) - ((eh * Math.sin(t)) * Math.sin(t_2))) <= -5e-295) {
tmp = Math.abs((Math.cos(Math.atan(((Math.tan(t) / ew) * eh))) * ew));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.cos(t) t_2 = math.atan(((eh * math.tan(t)) / -ew)) tmp = 0 if ((t_1 * math.cos(t_2)) - ((eh * math.sin(t)) * math.sin(t_2))) <= -5e-295: tmp = math.fabs((math.cos(math.atan(((math.tan(t) / ew) * eh))) * ew)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) t_2 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(t_1 * cos(t_2)) - Float64(Float64(eh * sin(t)) * sin(t_2))) <= -5e-295) tmp = abs(Float64(cos(atan(Float64(Float64(tan(t) / ew) * eh))) * ew)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * cos(t); t_2 = atan(((eh * tan(t)) / -ew)); tmp = 0.0; if (((t_1 * cos(t_2)) - ((eh * sin(t)) * sin(t_2))) <= -5e-295) tmp = abs((cos(atan(((tan(t) / ew) * eh))) * ew)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-295], N[Abs[N[(N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;t\_1 \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2 \leq -5 \cdot 10^{-295}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -5.00000000000000008e-295Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites44.0%
Applied rewrites44.0%
if -5.00000000000000008e-295 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.9%
Applied rewrites74.0%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6428.6
Applied rewrites28.6%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6462.0
Applied rewrites62.0%
Final simplification52.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))) (t_2 (atan (/ (* eh (tan t)) (- ew)))))
(if (<= (- (* t_1 (cos t_2)) (* (* eh (sin t)) (sin t_2))) -5e-295)
(fabs (* (sin (+ (/ (PI) 2.0) (atan (/ (* eh t) ew)))) ew))
t_1)))\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;t\_1 \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2 \leq -5 \cdot 10^{-295}:\\
\;\;\;\;\left|\sin \left(\frac{\mathsf{PI}\left(\right)}{2} + \tan^{-1} \left(\frac{eh \cdot t}{ew}\right)\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -5.00000000000000008e-295Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites44.0%
Applied rewrites43.7%
Taylor expanded in t around 0
Applied rewrites42.0%
if -5.00000000000000008e-295 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.9%
Applied rewrites74.0%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6428.6
Applied rewrites28.6%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6462.0
Applied rewrites62.0%
Final simplification51.7%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* eh (sin t)) (sin (atan (/ (* (- t) eh) ew)))) (* (* ew (cos t)) (cos (atan (/ (* eh (tan t)) (- ew))))))))
double code(double eh, double ew, double t) {
return fabs((((eh * sin(t)) * sin(atan(((-t * eh) / ew)))) - ((ew * cos(t)) * cos(atan(((eh * tan(t)) / -ew))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((eh * sin(t)) * sin(atan(((-t * eh) / ew)))) - ((ew * cos(t)) * cos(atan(((eh * tan(t)) / -ew))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.sin(t)) * Math.sin(Math.atan(((-t * eh) / ew)))) - ((ew * Math.cos(t)) * Math.cos(Math.atan(((eh * Math.tan(t)) / -ew))))));
}
def code(eh, ew, t): return math.fabs((((eh * math.sin(t)) * math.sin(math.atan(((-t * eh) / ew)))) - ((ew * math.cos(t)) * math.cos(math.atan(((eh * math.tan(t)) / -ew))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-t) * eh) / ew)))) - Float64(Float64(ew * cos(t)) * cos(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * sin(t)) * sin(atan(((-t * eh) / ew)))) - ((ew * cos(t)) * cos(atan(((eh * tan(t)) / -ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[((-t) * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-t\right) \cdot eh}{ew}\right) - \left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6499.5
Applied rewrites99.5%
Final simplification99.5%
(FPCore (eh ew t)
:precision binary64
(if (or (<= eh -2.9e-43) (not (<= eh 1.22e-5)))
(fabs
(-
(* (* eh (sin t)) (sin (atan (/ (* (- t) eh) ew))))
(* (* ew 1.0) (cos (atan (/ (* eh (tan t)) (- ew)))))))
(fabs
(* (cos (atan (* (/ (- (sin t)) ew) (/ eh (cos t))))) (* (cos t) ew)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2.9e-43) || !(eh <= 1.22e-5)) {
tmp = fabs((((eh * sin(t)) * sin(atan(((-t * eh) / ew)))) - ((ew * 1.0) * cos(atan(((eh * tan(t)) / -ew))))));
} else {
tmp = fabs((cos(atan(((-sin(t) / ew) * (eh / cos(t))))) * (cos(t) * 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 ((eh <= (-2.9d-43)) .or. (.not. (eh <= 1.22d-5))) then
tmp = abs((((eh * sin(t)) * sin(atan(((-t * eh) / ew)))) - ((ew * 1.0d0) * cos(atan(((eh * tan(t)) / -ew))))))
else
tmp = abs((cos(atan(((-sin(t) / ew) * (eh / cos(t))))) * (cos(t) * ew)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2.9e-43) || !(eh <= 1.22e-5)) {
tmp = Math.abs((((eh * Math.sin(t)) * Math.sin(Math.atan(((-t * eh) / ew)))) - ((ew * 1.0) * Math.cos(Math.atan(((eh * Math.tan(t)) / -ew))))));
} else {
tmp = Math.abs((Math.cos(Math.atan(((-Math.sin(t) / ew) * (eh / Math.cos(t))))) * (Math.cos(t) * ew)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -2.9e-43) or not (eh <= 1.22e-5): tmp = math.fabs((((eh * math.sin(t)) * math.sin(math.atan(((-t * eh) / ew)))) - ((ew * 1.0) * math.cos(math.atan(((eh * math.tan(t)) / -ew)))))) else: tmp = math.fabs((math.cos(math.atan(((-math.sin(t) / ew) * (eh / math.cos(t))))) * (math.cos(t) * ew))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -2.9e-43) || !(eh <= 1.22e-5)) tmp = abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-t) * eh) / ew)))) - Float64(Float64(ew * 1.0) * cos(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))))); else tmp = abs(Float64(cos(atan(Float64(Float64(Float64(-sin(t)) / ew) * Float64(eh / cos(t))))) * Float64(cos(t) * ew))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -2.9e-43) || ~((eh <= 1.22e-5))) tmp = abs((((eh * sin(t)) * sin(atan(((-t * eh) / ew)))) - ((ew * 1.0) * cos(atan(((eh * tan(t)) / -ew)))))); else tmp = abs((cos(atan(((-sin(t) / ew) * (eh / cos(t))))) * (cos(t) * ew))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -2.9e-43], N[Not[LessEqual[eh, 1.22e-5]], $MachinePrecision]], N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[((-t) * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(ew * 1.0), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[N[ArcTan[N[(N[((-N[Sin[t], $MachinePrecision]) / ew), $MachinePrecision] * N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -2.9 \cdot 10^{-43} \lor \neg \left(eh \leq 1.22 \cdot 10^{-5}\right):\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-t\right) \cdot eh}{ew}\right) - \left(ew \cdot 1\right) \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{-\sin t}{ew} \cdot \frac{eh}{\cos t}\right) \cdot \left(\cos t \cdot ew\right)\right|\\
\end{array}
\end{array}
if eh < -2.9000000000000001e-43 or 1.22000000000000001e-5 < eh Initial program 99.8%
Taylor expanded in t around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6499.5
Applied rewrites99.5%
Taylor expanded in t around 0
Applied rewrites89.1%
if -2.9000000000000001e-43 < eh < 1.22000000000000001e-5Initial program 99.9%
Taylor expanded in eh around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.7%
Final simplification91.2%
(FPCore (eh ew t)
:precision binary64
(if (or (<= eh -4.4e-5) (not (<= eh 2e+74)))
(fabs
(*
(*
(tanh
(asinh (* t (/ (fma -0.3333333333333333 (* eh (* t t)) (- eh)) ew))))
(sin t))
(- eh)))
(fabs
(* (cos (atan (* (/ (- (sin t)) ew) (/ eh (cos t))))) (* (cos t) ew)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -4.4e-5) || !(eh <= 2e+74)) {
tmp = fabs(((tanh(asinh((t * (fma(-0.3333333333333333, (eh * (t * t)), -eh) / ew)))) * sin(t)) * -eh));
} else {
tmp = fabs((cos(atan(((-sin(t) / ew) * (eh / cos(t))))) * (cos(t) * ew)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((eh <= -4.4e-5) || !(eh <= 2e+74)) tmp = abs(Float64(Float64(tanh(asinh(Float64(t * Float64(fma(-0.3333333333333333, Float64(eh * Float64(t * t)), Float64(-eh)) / ew)))) * sin(t)) * Float64(-eh))); else tmp = abs(Float64(cos(atan(Float64(Float64(Float64(-sin(t)) / ew) * Float64(eh / cos(t))))) * Float64(cos(t) * ew))); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -4.4e-5], N[Not[LessEqual[eh, 2e+74]], $MachinePrecision]], N[Abs[N[(N[(N[Tanh[N[ArcSinh[N[(t * N[(N[(-0.3333333333333333 * N[(eh * N[(t * t), $MachinePrecision]), $MachinePrecision] + (-eh)), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[N[ArcTan[N[(N[((-N[Sin[t], $MachinePrecision]) / ew), $MachinePrecision] * N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -4.4 \cdot 10^{-5} \lor \neg \left(eh \leq 2 \cdot 10^{+74}\right):\\
\;\;\;\;\left|\left(\tanh \sinh^{-1} \left(t \cdot \frac{\mathsf{fma}\left(-0.3333333333333333, eh \cdot \left(t \cdot t\right), -eh\right)}{ew}\right) \cdot \sin t\right) \cdot \left(-eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{-\sin t}{ew} \cdot \frac{eh}{\cos t}\right) \cdot \left(\cos t \cdot ew\right)\right|\\
\end{array}
\end{array}
if eh < -4.3999999999999999e-5 or 1.9999999999999999e74 < eh Initial program 99.8%
Taylor expanded in eh around inf
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
*-commutativeN/A
times-fracN/A
distribute-lft-neg-inN/A
Applied rewrites71.1%
Applied rewrites71.1%
Taylor expanded in t around 0
Applied rewrites71.4%
if -4.3999999999999999e-5 < eh < 1.9999999999999999e74Initial program 99.9%
Taylor expanded in eh around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.4%
Final simplification81.7%
(FPCore (eh ew t)
:precision binary64
(if (or (<= eh -2.55e-5) (not (<= eh 1.85e+74)))
(fabs
(*
(*
(tanh
(asinh (* t (/ (fma -0.3333333333333333 (* eh (* t t)) (- eh)) ew))))
(sin t))
(- eh)))
(fabs
(* (cos (atan (/ (* (sin t) eh) (* (fma (* t t) -0.5 1.0) (- ew))))) ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2.55e-5) || !(eh <= 1.85e+74)) {
tmp = fabs(((tanh(asinh((t * (fma(-0.3333333333333333, (eh * (t * t)), -eh) / ew)))) * sin(t)) * -eh));
} else {
tmp = fabs((cos(atan(((sin(t) * eh) / (fma((t * t), -0.5, 1.0) * -ew)))) * ew));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((eh <= -2.55e-5) || !(eh <= 1.85e+74)) tmp = abs(Float64(Float64(tanh(asinh(Float64(t * Float64(fma(-0.3333333333333333, Float64(eh * Float64(t * t)), Float64(-eh)) / ew)))) * sin(t)) * Float64(-eh))); else tmp = abs(Float64(cos(atan(Float64(Float64(sin(t) * eh) / Float64(fma(Float64(t * t), -0.5, 1.0) * Float64(-ew))))) * ew)); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -2.55e-5], N[Not[LessEqual[eh, 1.85e+74]], $MachinePrecision]], N[Abs[N[(N[(N[Tanh[N[ArcSinh[N[(t * N[(N[(-0.3333333333333333 * N[(eh * N[(t * t), $MachinePrecision]), $MachinePrecision] + (-eh)), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[N[ArcTan[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] / N[(N[(N[(t * t), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -2.55 \cdot 10^{-5} \lor \neg \left(eh \leq 1.85 \cdot 10^{+74}\right):\\
\;\;\;\;\left|\left(\tanh \sinh^{-1} \left(t \cdot \frac{\mathsf{fma}\left(-0.3333333333333333, eh \cdot \left(t \cdot t\right), -eh\right)}{ew}\right) \cdot \sin t\right) \cdot \left(-eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{\sin t \cdot eh}{\mathsf{fma}\left(t \cdot t, -0.5, 1\right) \cdot \left(-ew\right)}\right) \cdot ew\right|\\
\end{array}
\end{array}
if eh < -2.54999999999999998e-5 or 1.8500000000000001e74 < eh Initial program 99.8%
Taylor expanded in eh around inf
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
*-commutativeN/A
times-fracN/A
distribute-lft-neg-inN/A
Applied rewrites71.1%
Applied rewrites71.1%
Taylor expanded in t around 0
Applied rewrites71.4%
if -2.54999999999999998e-5 < eh < 1.8500000000000001e74Initial program 99.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.6%
Taylor expanded in t around 0
Applied rewrites57.6%
Applied rewrites57.6%
Final simplification63.9%
(FPCore (eh ew t) :precision binary64 (* ew (cos t)))
double code(double eh, double ew, double t) {
return ew * cos(t);
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = ew * cos(t)
end function
public static double code(double eh, double ew, double t) {
return ew * Math.cos(t);
}
def code(eh, ew, t): return ew * math.cos(t)
function code(eh, ew, t) return Float64(ew * cos(t)) end
function tmp = code(eh, ew, t) tmp = ew * cos(t); end
code[eh_, ew_, t_] := N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
ew \cdot \cos t
\end{array}
Initial program 99.8%
Applied rewrites36.4%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6414.8
Applied rewrites14.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6430.7
Applied rewrites30.7%
(FPCore (eh ew t) :precision binary64 (fma (* (* -0.5 ew) t) t ew))
double code(double eh, double ew, double t) {
return fma(((-0.5 * ew) * t), t, ew);
}
function code(eh, ew, t) return fma(Float64(Float64(-0.5 * ew) * t), t, ew) end
code[eh_, ew_, t_] := N[(N[(N[(-0.5 * ew), $MachinePrecision] * t), $MachinePrecision] * t + ew), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(-0.5 \cdot ew\right) \cdot t, t, ew\right)
\end{array}
Initial program 99.8%
Applied rewrites36.4%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6414.8
Applied rewrites14.8%
Taylor expanded in eh around 0
Applied rewrites16.7%
Applied rewrites16.8%
(FPCore (eh ew t) :precision binary64 (fma (* (* t t) ew) -0.5 ew))
double code(double eh, double ew, double t) {
return fma(((t * t) * ew), -0.5, ew);
}
function code(eh, ew, t) return fma(Float64(Float64(t * t) * ew), -0.5, ew) end
code[eh_, ew_, t_] := N[(N[(N[(t * t), $MachinePrecision] * ew), $MachinePrecision] * -0.5 + ew), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(t \cdot t\right) \cdot ew, -0.5, ew\right)
\end{array}
Initial program 99.8%
Applied rewrites36.4%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6414.8
Applied rewrites14.8%
Taylor expanded in eh around 0
Applied rewrites16.7%
Taylor expanded in eh around 0
Applied rewrites16.7%
herbie shell --seed 2024337
(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)))))))