Average Error: 0.0 → 0.0
Time: 11.1s
Precision: binary64
Cost: 13248
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
\[0.5 \cdot \left(\left(2 \cdot \cosh im\right) \cdot \sin re\right) \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
(FPCore (re im) :precision binary64 (* 0.5 (* (* 2.0 (cosh im)) (sin re))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
double code(double re, double im) {
	return 0.5 * ((2.0 * cosh(im)) * sin(re));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(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
    code = 0.5d0 * ((2.0d0 * cosh(im)) * sin(re))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
public static double code(double re, double im) {
	return 0.5 * ((2.0 * Math.cosh(im)) * Math.sin(re));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
def code(re, im):
	return 0.5 * ((2.0 * math.cosh(im)) * math.sin(re))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im)))
end
function code(re, im)
	return Float64(0.5 * Float64(Float64(2.0 * cosh(im)) * sin(re)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
end
function tmp = code(re, im)
	tmp = 0.5 * ((2.0 * cosh(im)) * sin(re));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[re_, im_] := N[(0.5 * N[(N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
0.5 \cdot \left(\left(2 \cdot \cosh im\right) \cdot \sin re\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    Proof

    [Start]0.0

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

    *-commutative [=>]0.0

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

    associate-*l* [=>]0.0

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

    +-commutative [=>]0.0

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

    distribute-lft-in [=>]0.0

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

    fma-def [=>]0.0

    \[ \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, 0.5 \cdot e^{0 - im}\right)} \]

    exp-diff [=>]0.0

    \[ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, 0.5 \cdot \color{blue}{\frac{e^{0}}{e^{im}}}\right) \]

    associate-*r/ [=>]0.0

    \[ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{0.5 \cdot e^{0}}{e^{im}}}\right) \]

    exp-0 [=>]0.0

    \[ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5 \cdot \color{blue}{1}}{e^{im}}\right) \]

    metadata-eval [=>]0.0

    \[ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{0.5}}{e^{im}}\right) \]
  3. Applied egg-rr0.0

    \[\leadsto \color{blue}{\sin re \cdot \frac{0.5}{e^{im}} + \sin re \cdot \left(0.5 \cdot e^{im}\right)} \]
  4. Taylor expanded in re around inf 0.0

    \[\leadsto \color{blue}{0.5 \cdot \left(e^{im} \cdot \sin re\right) + 0.5 \cdot \frac{\sin re}{e^{im}}} \]
  5. Simplified0.0

    \[\leadsto \color{blue}{0.5 \cdot \left(e^{im} \cdot \sin re + \frac{\sin re}{e^{im}}\right)} \]
    Proof

    [Start]0.0

    \[ 0.5 \cdot \left(e^{im} \cdot \sin re\right) + 0.5 \cdot \frac{\sin re}{e^{im}} \]

    *-commutative [=>]0.0

    \[ \color{blue}{\left(e^{im} \cdot \sin re\right) \cdot 0.5} + 0.5 \cdot \frac{\sin re}{e^{im}} \]

    *-commutative [<=]0.0

    \[ \color{blue}{\left(\sin re \cdot e^{im}\right)} \cdot 0.5 + 0.5 \cdot \frac{\sin re}{e^{im}} \]

    *-commutative [=>]0.0

    \[ \left(\sin re \cdot e^{im}\right) \cdot 0.5 + \color{blue}{\frac{\sin re}{e^{im}} \cdot 0.5} \]

    distribute-rgt-in [<=]0.0

    \[ \color{blue}{0.5 \cdot \left(\sin re \cdot e^{im} + \frac{\sin re}{e^{im}}\right)} \]

    *-commutative [=>]0.0

    \[ 0.5 \cdot \left(\color{blue}{e^{im} \cdot \sin re} + \frac{\sin re}{e^{im}}\right) \]
  6. Applied egg-rr10.5

    \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin re \cdot \left(e^{im} + e^{-im}\right)\right)\right)} \]
  7. Applied egg-rr0.0

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(2 \cdot \cosh im\right) \cdot \sin re\right)} \]
  8. Final simplification0.0

    \[\leadsto 0.5 \cdot \left(\left(2 \cdot \cosh im\right) \cdot \sin re\right) \]

Alternatives

Alternative 1
Error0.6
Cost19656
\[\begin{array}{l} \mathbf{if}\;\sin re \leq -0.0005:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;\sin re \leq 10^{-43}:\\ \;\;\;\;\cosh im \cdot re\\ \mathbf{else}:\\ \;\;\;\;\sin re\\ \end{array} \]
Alternative 2
Error0.7
Cost6976
\[\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right) \]
Alternative 3
Error1.0
Cost6464
\[\sin re \]
Alternative 4
Error31.4
Cost576
\[re + 0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) \]
Alternative 5
Error31.6
Cost64
\[re \]

Error

Reproduce

herbie shell --seed 2023016 
(FPCore (re im)
  :name "math.sin on complex, real part"
  :precision binary64
  (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))