| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 19656 |
\[\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}
\]
(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)
Results
Initial program 0.0
Simplified0.0
[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)
\] |
Applied egg-rr0.0
Taylor expanded in re around inf 0.0
Simplified0.0
[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)
\] |
Applied egg-rr10.5
Applied egg-rr0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 19656 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 6976 |
| Alternative 3 | |
|---|---|
| Error | 1.0 |
| Cost | 6464 |
| Alternative 4 | |
|---|---|
| Error | 31.4 |
| Cost | 576 |
| Alternative 5 | |
|---|---|
| Error | 31.6 |
| Cost | 64 |
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))))