Average Error: 0.1 → 0.1
Time: 19.4s
Precision: binary64
Cost: 58752
\[\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| \]
\[\left|\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\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
 (fabs
  (fma
   ew
   (/ (sin t) (hypot 1.0 (/ eh (* ew (tan t)))))
   (* eh (* (cos t) (sin (atan (/ (/ eh ew) (tan t)))))))))
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) {
	return fabs(fma(ew, (sin(t) / hypot(1.0, (eh / (ew * tan(t))))), (eh * (cos(t) * sin(atan(((eh / ew) / tan(t))))))));
}
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)
	return abs(fma(ew, Float64(sin(t) / hypot(1.0, Float64(eh / Float64(ew * tan(t))))), Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh / ew) / tan(t))))))))
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_] := N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $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|
\left|\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right|

Error

Derivation

  1. Initial program 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| \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right|} \]
    Proof
    (fabs.f64 (fma.f64 ew (*.f64 (sin.f64 t) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (*.f64 eh (*.f64 (cos.f64 t) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (sin.f64 t) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))))): 1 points increase in error, 0 points decrease in error
    (fabs.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 ew (*.f64 (sin.f64 t) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))))): 1 points increase in error, 0 points decrease in error
    (fabs.f64 (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 ew (sin.f64 t)) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))))): 1 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.1

    \[\leadsto \left|\mathsf{fma}\left(ew, \color{blue}{\frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
  4. Final simplification0.1

    \[\leadsto \left|\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]

Alternatives

Alternative 1
Error0.1
Cost52480
\[\left|\frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, \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| \]
Alternative 2
Error0.7
Cost52416
\[\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right| \]
Alternative 3
Error1.1
Cost45504
\[\left|\mathsf{fma}\left(ew, \sin t, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
Alternative 4
Error9.4
Cost32968
\[\begin{array}{l} t_1 := \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{if}\;eh \leq -12322402.271103933:\\ \;\;\;\;t_1\\ \mathbf{elif}\;eh \leq 1.6520206599387364 \cdot 10^{-32}:\\ \;\;\;\;\left|ew \cdot \sin t + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error9.5
Cost32840
\[\begin{array}{l} t_1 := \frac{eh}{ew \cdot \tan t}\\ t_2 := \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t_1\right|\\ \mathbf{if}\;eh \leq -12322402.271103933:\\ \;\;\;\;t_2\\ \mathbf{elif}\;eh \leq 1.6520206599387364 \cdot 10^{-32}:\\ \;\;\;\;\left|eh + ew \cdot \frac{\sin t}{\mathsf{hypot}\left(1, t_1\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error13.6
Cost26368
\[\left|eh + ew \cdot \frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}\right| \]
Alternative 7
Error30.3
Cost26304
\[\left|eh + t \cdot \left(ew \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right| \]
Alternative 8
Error37.2
Cost6464
\[\left|eh\right| \]

Error

Reproduce

herbie shell --seed 2022297 
(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))))))))