| Alternative 1 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 39296 |
\[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(eh \cdot \left(-\frac{\tan t}{ew}\right)\right) - eh \cdot \sin t\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 (fabs (- (* (* ew (cos t)) (/ 1.0 (hypot 1.0 (* (/ eh ew) (tan t))))) (* eh (* (sin t) (sin (atan (* eh (- (/ (tan t) ew))))))))))
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) {
return fabs((((ew * cos(t)) * (1.0 / hypot(1.0, ((eh / ew) * tan(t))))) - (eh * (sin(t) * sin(atan((eh * -(tan(t) / ew))))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) * Math.cos(Math.atan(((-eh * Math.tan(t)) / ew)))) - ((eh * Math.sin(t)) * Math.sin(Math.atan(((-eh * Math.tan(t)) / ew))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) * (1.0 / Math.hypot(1.0, ((eh / ew) * Math.tan(t))))) - (eh * (Math.sin(t) * Math.sin(Math.atan((eh * -(Math.tan(t) / ew))))))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) * math.cos(math.atan(((-eh * math.tan(t)) / ew)))) - ((eh * math.sin(t)) * math.sin(math.atan(((-eh * math.tan(t)) / ew))))))
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) * (1.0 / math.hypot(1.0, ((eh / ew) * math.tan(t))))) - (eh * (math.sin(t) * math.sin(math.atan((eh * -(math.tan(t) / ew))))))))
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) return abs(Float64(Float64(Float64(ew * cos(t)) * Float64(1.0 / hypot(1.0, Float64(Float64(eh / ew) * tan(t))))) - Float64(eh * Float64(sin(t) * sin(atan(Float64(eh * Float64(-Float64(tan(t) / ew))))))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) * cos(atan(((-eh * tan(t)) / ew)))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew)))))); end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) * (1.0 / hypot(1.0, ((eh / ew) * tan(t))))) - (eh * (sin(t) * sin(atan((eh * -(tan(t) / ew)))))))); 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_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eh * 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]
\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|
\left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{ew} \cdot \tan t\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \left(-\frac{\tan t}{ew}\right)\right)\right)\right|
Results
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|}
\] |
fabs-neg [<=]99.8 | \[ \color{blue}{\left|-\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)\right|}
\] |
sub-neg [=>]99.8 | \[ \left|-\color{blue}{\left(\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)}\right|
\] |
+-commutative [=>]99.8 | \[ \left|-\color{blue}{\left(\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)}\right|
\] |
distribute-neg-in [=>]99.8 | \[ \left|\color{blue}{\left(-\left(-\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)\right) + \left(-\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)}\right|
\] |
Applied egg-rr99.8%
[Start]99.8 | \[ \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right) - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
|---|---|
cos-atan [=>]99.8 | \[ \left|\left(ew \cdot \cos t\right) \cdot \color{blue}{\frac{1}{\sqrt{1 + \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right) \cdot \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)}}} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
hypot-1-def [=>]99.8 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\color{blue}{\mathsf{hypot}\left(1, \left(-eh\right) \cdot \frac{\tan t}{ew}\right)}} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
add-sqr-sqrt [=>]50.1 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{-eh} \cdot \sqrt{-eh}\right)} \cdot \frac{\tan t}{ew}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
sqrt-unprod [=>]93.6 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\sqrt{\left(-eh\right) \cdot \left(-eh\right)}} \cdot \frac{\tan t}{ew}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
sqr-neg [=>]93.6 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \sqrt{\color{blue}{eh \cdot eh}} \cdot \frac{\tan t}{ew}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
sqrt-unprod [<=]49.7 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\left(\sqrt{eh} \cdot \sqrt{eh}\right)} \cdot \frac{\tan t}{ew}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
add-sqr-sqrt [<=]99.8 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{eh} \cdot \frac{\tan t}{ew}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
Simplified99.8%
[Start]99.8 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
|---|---|
associate-*r/ [=>]99.8 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\frac{eh \cdot \tan t}{ew}}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
associate-*l/ [<=]99.8 | \[ \left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \color{blue}{\frac{eh}{ew} \cdot \tan t}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right|
\] |
Final simplification99.8%
| Alternative 1 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 39296 |
| Alternative 2 | |
|---|---|
| Accuracy | 90.9% |
| Cost | 33161 |
| Alternative 3 | |
|---|---|
| Accuracy | 87.4% |
| Cost | 33033 |
| Alternative 4 | |
|---|---|
| Accuracy | 61.3% |
| Cost | 32576 |
| Alternative 5 | |
|---|---|
| Accuracy | 60.9% |
| Cost | 26240 |
| Alternative 6 | |
|---|---|
| Accuracy | 61.0% |
| Cost | 26240 |
| Alternative 7 | |
|---|---|
| Accuracy | 42.0% |
| Cost | 26048 |
| Alternative 8 | |
|---|---|
| Accuracy | 40.8% |
| Cost | 19712 |
| Alternative 9 | |
|---|---|
| Accuracy | 41.7% |
| Cost | 19712 |
| Alternative 10 | |
|---|---|
| Accuracy | 40.8% |
| Cost | 19648 |
| Alternative 11 | |
|---|---|
| Accuracy | 40.0% |
| Cost | 13312 |
| Alternative 12 | |
|---|---|
| Accuracy | 40.0% |
| Cost | 13312 |
herbie shell --seed 2023137
(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)))))))