| Alternative 1 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 58944 |
\[\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right)\\
\left|\cos t_1 \cdot \left(\cos t \cdot ew\right) - \left(eh \cdot \sin t\right) \cdot \sin t_1\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) (* (cos t_1) (- ew)) (* (* 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), (cos(t_1) * -ew), ((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(Float64(-eh) * Float64(tan(t) / ew))) return abs(fma(cos(t), Float64(cos(t_1) * Float64(-ew)), 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[(N[Cos[t$95$1], $MachinePrecision] * (-ew)), $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(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\\
\left|\mathsf{fma}\left(\cos t, \cos t_1 \cdot \left(-ew\right), \left(eh \cdot \sin t\right) \cdot \sin t_1\right)\right|
\end{array}
Initial program 99.8%
Simplified99.8%
[Start]99.8 | \[ \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 [=>]99.8 | \[ \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 [=>]99.8 | \[ \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 [=>]99.8 | \[ \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 [<=]99.8 | \[ \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* [=>]99.8 | \[ \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 [=>]99.8 | \[ \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 [<=]99.8 | \[ \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 simplification99.8%
| Alternative 1 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 58944 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 52544 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 39296 |
| Alternative 4 | |
|---|---|
| Accuracy | 78.6% |
| Cost | 32768 |
| Alternative 5 | |
|---|---|
| Accuracy | 78.6% |
| Cost | 26368 |
| Alternative 6 | |
|---|---|
| Accuracy | 78.4% |
| Cost | 13120 |
| Alternative 7 | |
|---|---|
| Accuracy | 78.4% |
| Cost | 13120 |
| Alternative 8 | |
|---|---|
| Accuracy | 42.1% |
| Cost | 6464 |
herbie shell --seed 2023129
(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)))))))