| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 58944 |
\[\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|ew \cdot \left(\cos t \cdot \cos t_1\right) - eh \cdot \left(\sin t \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 (fabs (- (* ew (* (cos t) (cos (atan (/ (* (- eh) (tan t)) ew))))) (* (sin t) (* (sin (atan (* -1.0 (/ (* (tan t) eh) ew)))) eh)))))
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) * cos(atan(((-eh * tan(t)) / ew))))) - (sin(t) * (sin(atan((-1.0 * ((tan(t) * eh) / ew)))) * eh))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((ew * cos(t)) * cos(atan(((-eh * tan(t)) / ew)))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew))))))
end function
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((ew * (cos(t) * cos(atan(((-eh * tan(t)) / ew))))) - (sin(t) * (sin(atan(((-1.0d0) * ((tan(t) * eh) / ew)))) * eh))))
end function
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) * Math.cos(Math.atan(((-eh * Math.tan(t)) / ew))))) - (Math.sin(t) * (Math.sin(Math.atan((-1.0 * ((Math.tan(t) * eh) / ew)))) * eh))));
}
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) * math.cos(math.atan(((-eh * math.tan(t)) / ew))))) - (math.sin(t) * (math.sin(math.atan((-1.0 * ((math.tan(t) * eh) / ew)))) * eh))))
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(ew * Float64(cos(t) * cos(atan(Float64(Float64(Float64(-eh) * tan(t)) / ew))))) - Float64(sin(t) * Float64(sin(atan(Float64(-1.0 * Float64(Float64(tan(t) * eh) / ew)))) * eh)))) 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) * cos(atan(((-eh * tan(t)) / ew))))) - (sin(t) * (sin(atan((-1.0 * ((tan(t) * eh) / ew)))) * eh)))); 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[(ew * N[(N[Cos[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[t], $MachinePrecision] * N[(N[Sin[N[ArcTan[N[(-1.0 * N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $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|ew \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right) - \sin t \cdot \left(\sin \tan^{-1} \left(-1 \cdot \frac{\tan t \cdot eh}{ew}\right) \cdot eh\right)\right|
Results
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \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|
\] |
|---|---|
rational_best-simplify-1 [=>]0.1 | \[ \left|\color{blue}{\cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) \cdot \left(ew \cdot \cos t\right)} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right|
\] |
rational_best-simplify-1 [=>]0.1 | \[ \left|\cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) \cdot \color{blue}{\left(\cos t \cdot ew\right)} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right|
\] |
rational_best-simplify-50 [=>]0.1 | \[ \left|\color{blue}{ew \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|
\] |
rational_best-simplify-1 [=>]0.1 | \[ \left|ew \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right) - \color{blue}{\sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) \cdot \left(eh \cdot \sin t\right)}\right|
\] |
rational_best-simplify-1 [=>]0.1 | \[ \left|ew \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right) - \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) \cdot \color{blue}{\left(\sin t \cdot eh\right)}\right|
\] |
rational_best-simplify-50 [=>]0.1 | \[ \left|ew \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right) - \color{blue}{eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right)}\right|
\] |
Taylor expanded in eh around 0 0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 58944 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 52544 |
| Alternative 3 | |
|---|---|
| Error | 4.1 |
| Cost | 46792 |
| Alternative 4 | |
|---|---|
| Error | 5.8 |
| Cost | 46532 |
| Alternative 5 | |
|---|---|
| Error | 6.5 |
| Cost | 46144 |
| Alternative 6 | |
|---|---|
| Error | 13.1 |
| Cost | 46016 |
| Alternative 7 | |
|---|---|
| Error | 13.8 |
| Cost | 39616 |
| Alternative 8 | |
|---|---|
| Error | 29.8 |
| Cost | 33216 |
herbie shell --seed 2023100
(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)))))))