| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 52416 |
\[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right) + \cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|
\]
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ eh (* ew (tan t)))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (cos t) (* eh (sin t_1)))))))
double code(double eh, double ew, double t) {
return fabs((((ew * sin(t)) * cos(atan(((eh / ew) / tan(t))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))));
}
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * tan(t))));
return fabs((((ew * sin(t)) * cos(t_1)) + (cos(t) * (eh * sin(t_1)))));
}
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 * sin(t)) * cos(atan(((eh / ew) / tan(t))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))))
end function
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan((eh / (ew * tan(t))))
code = abs((((ew * sin(t)) * cos(t_1)) + (cos(t) * (eh * sin(t_1)))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.sin(t)) * Math.cos(Math.atan(((eh / ew) / Math.tan(t))))) + ((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t)))))));
}
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((eh / (ew * Math.tan(t))));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + (Math.cos(t) * (eh * Math.sin(t_1)))));
}
def code(eh, ew, t): return math.fabs((((ew * math.sin(t)) * math.cos(math.atan(((eh / ew) / math.tan(t))))) + ((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))))
def code(eh, ew, t): t_1 = math.atan((eh / (ew * math.tan(t)))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + (math.cos(t) * (eh * math.sin(t_1)))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))))) end
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * tan(t)))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(cos(t) * Float64(eh * sin(t_1))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * sin(t)) * cos(atan(((eh / ew) / tan(t))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))))); end
function tmp = code(eh, ew, t) t_1 = atan((eh / (ew * tan(t)))); tmp = abs((((ew * sin(t)) * cos(t_1)) + (cos(t) * (eh * sin(t_1))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * N[(eh * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t_1 + \cos t \cdot \left(eh \cdot \sin t_1\right)\right|
\end{array}
Results
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\] |
|---|---|
rational_best-simplify-9 [<=]0.1 | \[ \left|\color{blue}{\left(\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right) - 0}\right|
\] |
rational_best-simplify-9 [=>]0.1 | \[ \left|\color{blue}{\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)}\right|
\] |
rational_best-simplify-1 [=>]0.1 | \[ \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \color{blue}{\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right)}\right|
\] |
rational_best-simplify-53 [=>]0.1 | \[ \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)} + \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right)\right|
\] |
rational_best-simplify-50 [=>]0.1 | \[ \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right) + \color{blue}{\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right|
\] |
rational_best-simplify-53 [=>]0.1 | \[ \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right) + \cos t \cdot \left(eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right|
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 52416 |
| Alternative 2 | |
|---|---|
| Error | 1.3 |
| Cost | 46408 |
| Alternative 3 | |
|---|---|
| Error | 0.8 |
| Cost | 46400 |
| Alternative 4 | |
|---|---|
| Error | 6.1 |
| Cost | 46016 |
| Alternative 5 | |
|---|---|
| Error | 6.1 |
| Cost | 46016 |
| Alternative 6 | |
|---|---|
| Error | 21.9 |
| Cost | 39616 |
herbie shell --seed 2023099
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))