math.sin on complex, imaginary part

?

Percentage Accurate: 54.5% → 99.7%
Time: 15.4s
Precision: binary64
Cost: 53001

?

\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
\[\begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -5 \lor \neg \left(t_0 \leq 5 \cdot 10^{-11}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left(\left(-0.16666666666666666 \cdot {im}^{3} + -0.0001984126984126984 \cdot {im}^{7}\right) + -0.008333333333333333 \cdot {im}^{5}\right) - im\right)\\ \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -5.0) (not (<= t_0 5e-11)))
     (* (* 0.5 (cos re)) t_0)
     (*
      (cos re)
      (-
       (+
        (+
         (* -0.16666666666666666 (pow im 3.0))
         (* -0.0001984126984126984 (pow im 7.0)))
        (* -0.008333333333333333 (pow im 5.0)))
       im)))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -5.0) || !(t_0 <= 5e-11)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((((-0.16666666666666666 * pow(im, 3.0)) + (-0.0001984126984126984 * pow(im, 7.0))) + (-0.008333333333333333 * pow(im, 5.0))) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    if ((t_0 <= (-5.0d0)) .or. (.not. (t_0 <= 5d-11))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = cos(re) * (((((-0.16666666666666666d0) * (im ** 3.0d0)) + ((-0.0001984126984126984d0) * (im ** 7.0d0))) + ((-0.008333333333333333d0) * (im ** 5.0d0))) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -5.0) || !(t_0 <= 5e-11)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * ((((-0.16666666666666666 * Math.pow(im, 3.0)) + (-0.0001984126984126984 * Math.pow(im, 7.0))) + (-0.008333333333333333 * Math.pow(im, 5.0))) - im);
	}
	return tmp;
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -5.0) or not (t_0 <= 5e-11):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * ((((-0.16666666666666666 * math.pow(im, 3.0)) + (-0.0001984126984126984 * math.pow(im, 7.0))) + (-0.008333333333333333 * math.pow(im, 5.0))) - im)
	return tmp
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
end
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= -5.0) || !(t_0 <= 5e-11))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) + Float64(-0.0001984126984126984 * (im ^ 7.0))) + Float64(-0.008333333333333333 * (im ^ 5.0))) - im));
	end
	return tmp
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -5.0) || ~((t_0 <= 5e-11)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((((-0.16666666666666666 * (im ^ 3.0)) + (-0.0001984126984126984 * (im ^ 7.0))) + (-0.008333333333333333 * (im ^ 5.0))) - im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5.0], N[Not[LessEqual[t$95$0, 5e-11]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0001984126984126984 * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -5 \lor \neg \left(t_0 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(\left(\left(-0.16666666666666666 \cdot {im}^{3} + -0.0001984126984126984 \cdot {im}^{7}\right) + -0.008333333333333333 \cdot {im}^{5}\right) - im\right)\\


\end{array}

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original54.5%
Target99.8%
Herbie99.7%
\[\begin{array}{l} \mathbf{if}\;\left|im\right| < 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -5 or 5.00000000000000018e-11 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      Step-by-step derivation

      [Start]100.0

      \[ \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]

      sub0-neg [=>]100.0

      \[ \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]

    if -5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.00000000000000018e-11

    1. Initial program 9.1%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Simplified9.1%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      Step-by-step derivation

      [Start]9.1

      \[ \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]

      sub0-neg [=>]9.1

      \[ \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Taylor expanded in im around 0 99.8%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \left(-1 \cdot \left(\cos re \cdot im\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right)\right)} \]
    4. Simplified99.8%

      \[\leadsto \color{blue}{\cos re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right)} \]
      Step-by-step derivation

      [Start]99.8

      \[ -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \left(-1 \cdot \left(\cos re \cdot im\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right)\right) \]

      associate-+r+ [=>]99.8

      \[ \color{blue}{\left(-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right)} \]

      +-commutative [=>]99.8

      \[ \color{blue}{\left(-1 \cdot \left(\cos re \cdot im\right) + -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right)\right)} + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      mul-1-neg [=>]99.8

      \[ \left(\color{blue}{\left(-\cos re \cdot im\right)} + -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      *-commutative [=>]99.8

      \[ \left(\left(-\color{blue}{im \cdot \cos re}\right) + -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      distribute-lft-neg-in [=>]99.8

      \[ \left(\color{blue}{\left(-im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      *-commutative [=>]99.8

      \[ \left(\left(-im\right) \cdot \cos re + -0.16666666666666666 \cdot \color{blue}{\left({im}^{3} \cdot \cos re\right)}\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      associate-*r* [=>]99.8

      \[ \left(\left(-im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re}\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      distribute-rgt-out [=>]99.8

      \[ \color{blue}{\cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right)} + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      *-commutative [=>]99.8

      \[ \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\color{blue}{\left(\cos re \cdot {im}^{5}\right) \cdot -0.008333333333333333} + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      associate-*l* [=>]99.8

      \[ \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\color{blue}{\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)} + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]

      *-commutative [=>]99.8

      \[ \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\left(\cos re \cdot {im}^{7}\right) \cdot -0.0001984126984126984}\right) \]

      associate-*l* [=>]99.8

      \[ \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\cos re \cdot \left({im}^{7} \cdot -0.0001984126984126984\right)}\right) \]

      distribute-lft-out [=>]99.8

      \[ \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \color{blue}{\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333 + {im}^{7} \cdot -0.0001984126984126984\right)} \]
    5. Taylor expanded in re around inf 99.8%

      \[\leadsto \color{blue}{\cos re \cdot \left(\left(-0.008333333333333333 \cdot {im}^{5} + \left(-0.16666666666666666 \cdot {im}^{3} + -0.0001984126984126984 \cdot {im}^{7}\right)\right) - im\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -5 \lor \neg \left(e^{-im} - e^{im} \leq 5 \cdot 10^{-11}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left(\left(-0.16666666666666666 \cdot {im}^{3} + -0.0001984126984126984 \cdot {im}^{7}\right) + -0.008333333333333333 \cdot {im}^{5}\right) - im\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.7%
Cost53001
\[\begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -5 \lor \neg \left(t_0 \leq 5 \cdot 10^{-11}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left(-0.0001984126984126984 \cdot {im}^{7} + -0.008333333333333333 \cdot {im}^{5}\right) + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right)\\ \end{array} \]
Alternative 2
Accuracy99.7%
Cost45961
\[\begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -0.02 \lor \neg \left(t_0 \leq 5 \cdot 10^{-11}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \]
Alternative 3
Accuracy94.7%
Cost13842
\[\begin{array}{l} \mathbf{if}\;im \leq -4 \cdot 10^{+132} \lor \neg \left(im \leq -0.55 \lor \neg \left(im \leq 2.3\right) \land im \leq 5.7 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \]
Alternative 4
Accuracy38.6%
Cost13640
\[\begin{array}{l} \mathbf{if}\;\cos re \leq -0.05:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;\cos re \leq 0.94:\\ \;\;\;\;-3 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]
Alternative 5
Accuracy86.8%
Cost13580
\[\begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := -0.16666666666666666 \cdot {im}^{3} - im\\ \mathbf{if}\;im \leq -0.55:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.0155:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+193}:\\ \;\;\;\;t_1 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Accuracy77.6%
Cost7824
\[\begin{array}{l} t_0 := -0.16666666666666666 \cdot {im}^{3}\\ t_1 := t_0 - im\\ t_2 := t_1 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{if}\;im \leq -1.45 \cdot 10^{+84}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.15:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 4.1 \cdot 10^{+14}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+193}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Accuracy76.0%
Cost7432
\[\begin{array}{l} t_0 := -0.16666666666666666 \cdot {im}^{3}\\ t_1 := t_0 - im\\ \mathbf{if}\;im \leq -1.45 \cdot 10^{+84}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -2400:\\ \;\;\;\;t_1 \cdot \left(-0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 8.5 \cdot 10^{-8}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Accuracy54.0%
Cost7184
\[\begin{array}{l} t_0 := -0.16666666666666666 \cdot {im}^{3}\\ \mathbf{if}\;im \leq -1.45 \cdot 10^{+84}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -2.1 \cdot 10^{-14}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 15500:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 9 \cdot 10^{+73}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Accuracy75.9%
Cost7180
\[\begin{array}{l} t_0 := -0.16666666666666666 \cdot {im}^{3}\\ \mathbf{if}\;im \leq -1.45 \cdot 10^{+84}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -7400:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 8.5 \cdot 10^{-8}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \]
Alternative 10
Accuracy76.0%
Cost7052
\[\begin{array}{l} t_0 := -0.16666666666666666 \cdot {im}^{3}\\ \mathbf{if}\;im \leq -1.45 \cdot 10^{+84}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -780:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;im \leq 2.2:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Accuracy33.4%
Cost972
\[\begin{array}{l} t_0 := -3 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{if}\;re \leq -1.5 \cdot 10^{+153}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;re \leq 3.8 \cdot 10^{+153}:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 1.35 \cdot 10^{+212}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Accuracy33.7%
Cost585
\[\begin{array}{l} \mathbf{if}\;im \leq -780 \lor \neg \left(im \leq 5300\right):\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]
Alternative 13
Accuracy33.9%
Cost584
\[\begin{array}{l} \mathbf{if}\;im \leq -1.15:\\ \;\;\;\;1.5 + \left(re \cdot re\right) \cdot -0.75\\ \mathbf{elif}\;im \leq 3600:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]
Alternative 14
Accuracy28.8%
Cost128
\[-im \]
Alternative 15
Accuracy2.9%
Cost64
\[-3 \]
Alternative 16
Accuracy2.9%
Cost64
\[-2 \]
Alternative 17
Accuracy2.9%
Cost64
\[-0.25 \]
Alternative 18
Accuracy2.9%
Cost64
\[-0.015625 \]
Alternative 19
Accuracy3.5%
Cost64
\[0 \]

Error

Reproduce?

herbie shell --seed 2023159 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"
  :precision binary64

  :herbie-target
  (if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))

  (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))