?

Average Error: 0.21% → 0.21%
Time: 21.5s
Precision: binary64
Cost: 65280

?

\[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
\[\begin{array}{l} t_1 := \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right)\\ \left|\mathsf{fma}\left(\cos t, ew \cdot \left(-\cos t_1\right), \left(eh \cdot \sin t\right) \cdot \sin t_1\right)\right| \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (fabs
  (-
   (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew))))
   (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (atan (* eh (/ (- (tan t)) ew)))))
   (fabs (fma (cos t) (* ew (- (cos t_1))) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
	return fabs((((ew * cos(t)) * cos(atan(((-eh * tan(t)) / ew)))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew))))));
}
double code(double eh, double ew, double t) {
	double t_1 = atan((eh * (-tan(t) / ew)));
	return fabs(fma(cos(t), (ew * -cos(t_1)), ((eh * sin(t)) * sin(t_1))));
}
function code(eh, ew, t)
	return abs(Float64(Float64(Float64(ew * cos(t)) * cos(atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-eh) * tan(t)) / ew))))))
end
function code(eh, ew, t)
	t_1 = atan(Float64(eh * Float64(Float64(-tan(t)) / ew)))
	return abs(fma(cos(t), Float64(ew * Float64(-cos(t_1))), Float64(Float64(eh * sin(t)) * sin(t_1))))
end
code[eh_, ew_, t_] := N[Abs[N[(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] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[Cos[t], $MachinePrecision] * N[(ew * (-N[Cos[t$95$1], $MachinePrecision])), $MachinePrecision] + N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right|
\begin{array}{l}
t_1 := \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right)\\
\left|\mathsf{fma}\left(\cos t, ew \cdot \left(-\cos t_1\right), \left(eh \cdot \sin t\right) \cdot \sin t_1\right)\right|
\end{array}

Error?

Derivation?

  1. Initial program 0.21

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Simplified0.21

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(\cos t, \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right) \cdot \left(-ew\right), \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|} \]
    Proof

    [Start]0.21

    \[ \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]

    fabs-sub [=>]0.21

    \[ \color{blue}{\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right|} \]

    sub-neg [=>]0.21

    \[ \left|\color{blue}{\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) + \left(-\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)}\right| \]

    +-commutative [=>]0.21

    \[ \left|\color{blue}{\left(-\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right) + \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)}\right| \]

    cancel-sign-sub [<=]0.21

    \[ \left|\color{blue}{\left(-\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right) - \left(-eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)}\right| \]

    associate-*l* [=>]0.21

    \[ \left|\left(-\color{blue}{ew \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)}\right) - \left(-eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]

    distribute-lft-neg-in [=>]0.21

    \[ \left|\color{blue}{\left(-ew\right) \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)} - \left(-eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]

    distribute-lft-neg-in [<=]0.21

    \[ \left|\left(-ew\right) \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right) - \color{blue}{\left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)}\right| \]
  3. Final simplification0.21

    \[\leadsto \left|\mathsf{fma}\left(\cos t, ew \cdot \left(-\cos \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right)\right), \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right)\right)\right| \]

Alternatives

Alternative 1
Error0.21%
Cost52544
\[\left|\frac{\cos t \cdot ew}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right)\right| \]
Alternative 2
Error1.45%
Cost45504
\[\left|\mathsf{fma}\left(\cos t, ew, \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right)\right| \]
Alternative 3
Error1.68%
Cost39168
\[\left|\mathsf{fma}\left(\cos t, ew, \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{-t}{\frac{ew}{eh}}\right)\right)\right| \]
Alternative 4
Error1.9%
Cost25920
\[\left|\mathsf{fma}\left(\cos t, ew, eh \cdot \sin t\right)\right| \]
Alternative 5
Error26.03%
Cost20233
\[\begin{array}{l} \mathbf{if}\;t \leq -215000000 \lor \neg \left(t \leq 0.000125\right):\\ \;\;\;\;\left|\cos t \cdot ew\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew + t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{t \cdot \left(-eh\right)}{ew}\right)\right)\right|\\ \end{array} \]
Alternative 6
Error38.79%
Cost12992
\[\left|\cos t \cdot ew\right| \]
Alternative 7
Error58.17%
Cost6464
\[\left|ew\right| \]

Error

Reproduce?

herbie shell --seed 2023090 
(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)))))))