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

Error

Derivation

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

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

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

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

Alternatives

Alternative 1
Error0.1
Cost52672
\[\left|\frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)} \cdot \left(ew \cdot \cos t\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\tan t \cdot \left(-eh\right)}{ew}\right)\right| \]
Alternative 2
Error0.9
Cost39296
\[\left|ew \cdot \cos t - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\tan t \cdot \left(-eh\right)}{ew}\right)\right| \]
Alternative 3
Error13.4
Cost39232
\[\left|\mathsf{fma}\left(ew, 1, \left(eh \cdot \sin t\right) \cdot \left(-\sin \tan^{-1} \left(-\frac{\tan t}{\frac{ew}{eh}}\right)\right)\right)\right| \]
Alternative 4
Error13.4
Cost32832
\[\left|\mathsf{fma}\left(ew, 1, \left(eh \cdot \sin t\right) \cdot \left(-\sin \tan^{-1} \left(\frac{t \cdot \left(-eh\right)}{ew}\right)\right)\right)\right| \]
Alternative 5
Error13.5
Cost19584
\[\left|\mathsf{fma}\left(ew, 1, eh \cdot \left(-\sin t\right)\right)\right| \]
Alternative 6
Error13.5
Cost19520
\[\left|\mathsf{fma}\left(ew, 1, eh \cdot \sin t\right)\right| \]

Error

Reproduce

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