\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
Test:
math.cos on complex, imaginary part
Bits:
128 bits
Bits error versus re
Bits error versus im
Time: 10.5 s
Input Error: 20.6
Output Error: 1.7
Log:
Profile: 🕒
\((\left({im}^3\right) * \frac{1}{3} + \left((\left({im}^{5}\right) * \frac{1}{60} + \left(im \cdot 2\right))_*\right))_* \cdot \left(\sin re \cdot \left(-0.5\right)\right)\)
  1. Started with
    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
    20.6
  2. Applied taylor to get
    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leadsto \left(0.5 \cdot \sin re\right) \cdot \left(-\left(\frac{1}{60} \cdot {im}^{5} + \left(2 \cdot im + \frac{1}{3} \cdot {im}^{3}\right)\right)\right)\]
    1.7
  3. Taylor expanded around 0 to get
    \[\left(0.5 \cdot \sin re\right) \cdot \color{red}{\left(-\left(\frac{1}{60} \cdot {im}^{5} + \left(2 \cdot im + \frac{1}{3} \cdot {im}^{3}\right)\right)\right)} \leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-\left(\frac{1}{60} \cdot {im}^{5} + \left(2 \cdot im + \frac{1}{3} \cdot {im}^{3}\right)\right)\right)}\]
    1.7
  4. Applied simplify to get
    \[\color{red}{\left(0.5 \cdot \sin re\right) \cdot \left(-\left(\frac{1}{60} \cdot {im}^{5} + \left(2 \cdot im + \frac{1}{3} \cdot {im}^{3}\right)\right)\right)} \leadsto \color{blue}{(\left({im}^3\right) * \frac{1}{3} + \left((\left({im}^{5}\right) * \frac{1}{60} + \left(im \cdot 2\right))_*\right))_* \cdot \left(\sin re \cdot \left(-0.5\right)\right)}\]
    1.7

  5. Removed slow pow expressions

Original test:


(lambda ((re default) (im default))
  #:name "math.cos on complex, imaginary part"
  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))
  #:target
  (if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))