| Alternative 1 | |
|---|---|
| Error | 0.21% |
| Cost | 52544 |
\[\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|
\]
(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}
Initial program 0.21
Simplified0.21
[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|
\] |
Final simplification0.21
| Alternative 1 | |
|---|---|
| Error | 0.21% |
| Cost | 52544 |
| Alternative 2 | |
|---|---|
| Error | 1.45% |
| Cost | 45504 |
| Alternative 3 | |
|---|---|
| Error | 1.68% |
| Cost | 39168 |
| Alternative 4 | |
|---|---|
| Error | 1.9% |
| Cost | 25920 |
| Alternative 5 | |
|---|---|
| Error | 26.03% |
| Cost | 20233 |
| Alternative 6 | |
|---|---|
| Error | 38.79% |
| Cost | 12992 |
| Alternative 7 | |
|---|---|
| Error | 58.17% |
| Cost | 6464 |
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)))))))