
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
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
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); 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]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
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
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); 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]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (sin re) (fma 0.5 (exp im) (/ 0.5 (exp im)))))
double code(double re, double im) {
return sin(re) * fma(0.5, exp(im), (0.5 / exp(im)));
}
function code(re, im) return Float64(sin(re) * fma(0.5, exp(im), Float64(0.5 / exp(im)))) end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision] + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)
\end{array}
Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (* (* (sin re) 0.5) (+ (exp im) (exp (- im)))))
double code(double re, double im) {
return (sin(re) * 0.5) * (exp(im) + exp(-im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (sin(re) * 0.5d0) * (exp(im) + exp(-im))
end function
public static double code(double re, double im) {
return (Math.sin(re) * 0.5) * (Math.exp(im) + Math.exp(-im));
}
def code(re, im): return (math.sin(re) * 0.5) * (math.exp(im) + math.exp(-im))
function code(re, im) return Float64(Float64(sin(re) * 0.5) * Float64(exp(im) + exp(Float64(-im)))) end
function tmp = code(re, im) tmp = (sin(re) * 0.5) * (exp(im) + exp(-im)); end
code[re_, im_] := N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sin re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\right)
\end{array}
Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (* (sin re) (+ 0.5 (* 0.5 (exp im)))))
double code(double re, double im) {
return sin(re) * (0.5 + (0.5 * exp(im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re) * (0.5d0 + (0.5d0 * exp(im)))
end function
public static double code(double re, double im) {
return Math.sin(re) * (0.5 + (0.5 * Math.exp(im)));
}
def code(re, im): return math.sin(re) * (0.5 + (0.5 * math.exp(im)))
function code(re, im) return Float64(sin(re) * Float64(0.5 + Float64(0.5 * exp(im)))) end
function tmp = code(re, im) tmp = sin(re) * (0.5 + (0.5 * exp(im))); end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)
\end{array}
Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 73.9%
Taylor expanded in re around inf 73.9%
*-commutative73.9%
Simplified73.9%
Final simplification73.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (+ 0.5 (* 0.5 (exp im))))))
(if (<= im 4.8)
(* (* (sin re) 0.5) (+ 2.0 (* im im)))
(if (<= im 3.1e+30)
t_0
(if (<= im 1.7e+40)
(* (* im im) (+ (* (pow re 3.0) -0.08333333333333333) (* re 0.5)))
(if (<= im 1.28e+103)
t_0
(*
(sin re)
(+ 1.0 (* im (+ 0.5 (* (* im im) 0.08333333333333333)))))))))))
double code(double re, double im) {
double t_0 = re * (0.5 + (0.5 * exp(im)));
double tmp;
if (im <= 4.8) {
tmp = (sin(re) * 0.5) * (2.0 + (im * im));
} else if (im <= 3.1e+30) {
tmp = t_0;
} else if (im <= 1.7e+40) {
tmp = (im * im) * ((pow(re, 3.0) * -0.08333333333333333) + (re * 0.5));
} else if (im <= 1.28e+103) {
tmp = t_0;
} else {
tmp = sin(re) * (1.0 + (im * (0.5 + ((im * im) * 0.08333333333333333))));
}
return tmp;
}
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 = re * (0.5d0 + (0.5d0 * exp(im)))
if (im <= 4.8d0) then
tmp = (sin(re) * 0.5d0) * (2.0d0 + (im * im))
else if (im <= 3.1d+30) then
tmp = t_0
else if (im <= 1.7d+40) then
tmp = (im * im) * (((re ** 3.0d0) * (-0.08333333333333333d0)) + (re * 0.5d0))
else if (im <= 1.28d+103) then
tmp = t_0
else
tmp = sin(re) * (1.0d0 + (im * (0.5d0 + ((im * im) * 0.08333333333333333d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (0.5 + (0.5 * Math.exp(im)));
double tmp;
if (im <= 4.8) {
tmp = (Math.sin(re) * 0.5) * (2.0 + (im * im));
} else if (im <= 3.1e+30) {
tmp = t_0;
} else if (im <= 1.7e+40) {
tmp = (im * im) * ((Math.pow(re, 3.0) * -0.08333333333333333) + (re * 0.5));
} else if (im <= 1.28e+103) {
tmp = t_0;
} else {
tmp = Math.sin(re) * (1.0 + (im * (0.5 + ((im * im) * 0.08333333333333333))));
}
return tmp;
}
def code(re, im): t_0 = re * (0.5 + (0.5 * math.exp(im))) tmp = 0 if im <= 4.8: tmp = (math.sin(re) * 0.5) * (2.0 + (im * im)) elif im <= 3.1e+30: tmp = t_0 elif im <= 1.7e+40: tmp = (im * im) * ((math.pow(re, 3.0) * -0.08333333333333333) + (re * 0.5)) elif im <= 1.28e+103: tmp = t_0 else: tmp = math.sin(re) * (1.0 + (im * (0.5 + ((im * im) * 0.08333333333333333)))) return tmp
function code(re, im) t_0 = Float64(re * Float64(0.5 + Float64(0.5 * exp(im)))) tmp = 0.0 if (im <= 4.8) tmp = Float64(Float64(sin(re) * 0.5) * Float64(2.0 + Float64(im * im))); elseif (im <= 3.1e+30) tmp = t_0; elseif (im <= 1.7e+40) tmp = Float64(Float64(im * im) * Float64(Float64((re ^ 3.0) * -0.08333333333333333) + Float64(re * 0.5))); elseif (im <= 1.28e+103) tmp = t_0; else tmp = Float64(sin(re) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.08333333333333333))))); end return tmp end
function tmp_2 = code(re, im) t_0 = re * (0.5 + (0.5 * exp(im))); tmp = 0.0; if (im <= 4.8) tmp = (sin(re) * 0.5) * (2.0 + (im * im)); elseif (im <= 3.1e+30) tmp = t_0; elseif (im <= 1.7e+40) tmp = (im * im) * (((re ^ 3.0) * -0.08333333333333333) + (re * 0.5)); elseif (im <= 1.28e+103) tmp = t_0; else tmp = sin(re) * (1.0 + (im * (0.5 + ((im * im) * 0.08333333333333333)))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 4.8], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.1e+30], t$95$0, If[LessEqual[im, 1.7e+40], N[(N[(im * im), $MachinePrecision] * N[(N[(N[Power[re, 3.0], $MachinePrecision] * -0.08333333333333333), $MachinePrecision] + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.28e+103], t$95$0, N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\
\mathbf{if}\;im \leq 4.8:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{elif}\;im \leq 3.1 \cdot 10^{+30}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.7 \cdot 10^{+40}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left({re}^{3} \cdot -0.08333333333333333 + re \cdot 0.5\right)\\
\mathbf{elif}\;im \leq 1.28 \cdot 10^{+103}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\\
\end{array}
\end{array}
if im < 4.79999999999999982Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 83.5%
unpow283.5%
Simplified83.5%
if 4.79999999999999982 < im < 3.0999999999999998e30 or 1.69999999999999994e40 < im < 1.28e103Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 80.0%
if 3.0999999999999998e30 < im < 1.69999999999999994e40Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
unpow23.5%
Simplified3.5%
Taylor expanded in im around inf 3.5%
*-commutative3.5%
associate-*l*3.5%
*-commutative3.5%
unpow23.5%
Simplified3.5%
Taylor expanded in re around 0 40.6%
unpow240.6%
associate-*r*40.6%
unpow240.6%
associate-*r*40.6%
distribute-rgt-out80.6%
*-commutative80.6%
*-commutative80.6%
Simplified80.6%
if 1.28e103 < im Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
associate-+l+100.0%
*-commutative100.0%
unpow3100.0%
unpow2100.0%
associate-*r*100.0%
unpow2100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
unpow2100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification85.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (+ 0.5 (* 0.5 (exp im)))))
(t_1 (* (* (sin re) 0.5) (+ 2.0 (* im im)))))
(if (<= im 4.8)
t_1
(if (<= im 3.1e+30)
t_0
(if (<= im 1.7e+41)
(* (* im im) (+ (* (pow re 3.0) -0.08333333333333333) (* re 0.5)))
(if (<= im 1.3e+152) t_0 t_1))))))
double code(double re, double im) {
double t_0 = re * (0.5 + (0.5 * exp(im)));
double t_1 = (sin(re) * 0.5) * (2.0 + (im * im));
double tmp;
if (im <= 4.8) {
tmp = t_1;
} else if (im <= 3.1e+30) {
tmp = t_0;
} else if (im <= 1.7e+41) {
tmp = (im * im) * ((pow(re, 3.0) * -0.08333333333333333) + (re * 0.5));
} else if (im <= 1.3e+152) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = re * (0.5d0 + (0.5d0 * exp(im)))
t_1 = (sin(re) * 0.5d0) * (2.0d0 + (im * im))
if (im <= 4.8d0) then
tmp = t_1
else if (im <= 3.1d+30) then
tmp = t_0
else if (im <= 1.7d+41) then
tmp = (im * im) * (((re ** 3.0d0) * (-0.08333333333333333d0)) + (re * 0.5d0))
else if (im <= 1.3d+152) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (0.5 + (0.5 * Math.exp(im)));
double t_1 = (Math.sin(re) * 0.5) * (2.0 + (im * im));
double tmp;
if (im <= 4.8) {
tmp = t_1;
} else if (im <= 3.1e+30) {
tmp = t_0;
} else if (im <= 1.7e+41) {
tmp = (im * im) * ((Math.pow(re, 3.0) * -0.08333333333333333) + (re * 0.5));
} else if (im <= 1.3e+152) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = re * (0.5 + (0.5 * math.exp(im))) t_1 = (math.sin(re) * 0.5) * (2.0 + (im * im)) tmp = 0 if im <= 4.8: tmp = t_1 elif im <= 3.1e+30: tmp = t_0 elif im <= 1.7e+41: tmp = (im * im) * ((math.pow(re, 3.0) * -0.08333333333333333) + (re * 0.5)) elif im <= 1.3e+152: tmp = t_0 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(re * Float64(0.5 + Float64(0.5 * exp(im)))) t_1 = Float64(Float64(sin(re) * 0.5) * Float64(2.0 + Float64(im * im))) tmp = 0.0 if (im <= 4.8) tmp = t_1; elseif (im <= 3.1e+30) tmp = t_0; elseif (im <= 1.7e+41) tmp = Float64(Float64(im * im) * Float64(Float64((re ^ 3.0) * -0.08333333333333333) + Float64(re * 0.5))); elseif (im <= 1.3e+152) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = re * (0.5 + (0.5 * exp(im))); t_1 = (sin(re) * 0.5) * (2.0 + (im * im)); tmp = 0.0; if (im <= 4.8) tmp = t_1; elseif (im <= 3.1e+30) tmp = t_0; elseif (im <= 1.7e+41) tmp = (im * im) * (((re ^ 3.0) * -0.08333333333333333) + (re * 0.5)); elseif (im <= 1.3e+152) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 4.8], t$95$1, If[LessEqual[im, 3.1e+30], t$95$0, If[LessEqual[im, 1.7e+41], N[(N[(im * im), $MachinePrecision] * N[(N[(N[Power[re, 3.0], $MachinePrecision] * -0.08333333333333333), $MachinePrecision] + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.3e+152], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\
t_1 := \left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{if}\;im \leq 4.8:\\
\;\;\;\;t_1\\
\mathbf{elif}\;im \leq 3.1 \cdot 10^{+30}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 1.7 \cdot 10^{+41}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left({re}^{3} \cdot -0.08333333333333333 + re \cdot 0.5\right)\\
\mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if im < 4.79999999999999982 or 1.3e152 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 85.1%
unpow285.1%
Simplified85.1%
if 4.79999999999999982 < im < 3.0999999999999998e30 or 1.69999999999999999e41 < im < 1.3e152Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 79.2%
if 3.0999999999999998e30 < im < 1.69999999999999999e41Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 3.5%
unpow23.5%
Simplified3.5%
Taylor expanded in im around inf 3.5%
*-commutative3.5%
associate-*l*3.5%
*-commutative3.5%
unpow23.5%
Simplified3.5%
Taylor expanded in re around 0 40.6%
unpow240.6%
associate-*r*40.6%
unpow240.6%
associate-*r*40.6%
distribute-rgt-out80.6%
*-commutative80.6%
*-commutative80.6%
Simplified80.6%
Final simplification84.4%
(FPCore (re im) :precision binary64 (if (or (<= im 3.5) (not (<= im 1.3e+152))) (* (* (sin re) 0.5) (+ 2.0 (* im im))) (* re (+ 0.5 (* 0.5 (exp im))))))
double code(double re, double im) {
double tmp;
if ((im <= 3.5) || !(im <= 1.3e+152)) {
tmp = (sin(re) * 0.5) * (2.0 + (im * im));
} else {
tmp = re * (0.5 + (0.5 * exp(im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 3.5d0) .or. (.not. (im <= 1.3d+152))) then
tmp = (sin(re) * 0.5d0) * (2.0d0 + (im * im))
else
tmp = re * (0.5d0 + (0.5d0 * exp(im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 3.5) || !(im <= 1.3e+152)) {
tmp = (Math.sin(re) * 0.5) * (2.0 + (im * im));
} else {
tmp = re * (0.5 + (0.5 * Math.exp(im)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 3.5) or not (im <= 1.3e+152): tmp = (math.sin(re) * 0.5) * (2.0 + (im * im)) else: tmp = re * (0.5 + (0.5 * math.exp(im))) return tmp
function code(re, im) tmp = 0.0 if ((im <= 3.5) || !(im <= 1.3e+152)) tmp = Float64(Float64(sin(re) * 0.5) * Float64(2.0 + Float64(im * im))); else tmp = Float64(re * Float64(0.5 + Float64(0.5 * exp(im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 3.5) || ~((im <= 1.3e+152))) tmp = (sin(re) * 0.5) * (2.0 + (im * im)); else tmp = re * (0.5 + (0.5 * exp(im))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 3.5], N[Not[LessEqual[im, 1.3e+152]], $MachinePrecision]], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.5 \lor \neg \left(im \leq 1.3 \cdot 10^{+152}\right):\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\
\end{array}
\end{array}
if im < 3.5 or 1.3e152 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 85.1%
unpow285.1%
Simplified85.1%
if 3.5 < im < 1.3e152Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 69.0%
Final simplification83.3%
(FPCore (re im)
:precision binary64
(if (<= im 1.7e+40)
(sin re)
(if (<= im 1.3e+152)
(* 0.041666666666666664 (* re (pow im 4.0)))
(* (sin re) (* 0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 1.7e+40) {
tmp = sin(re);
} else if (im <= 1.3e+152) {
tmp = 0.041666666666666664 * (re * pow(im, 4.0));
} else {
tmp = sin(re) * (0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.7d+40) then
tmp = sin(re)
else if (im <= 1.3d+152) then
tmp = 0.041666666666666664d0 * (re * (im ** 4.0d0))
else
tmp = sin(re) * (0.5d0 * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.7e+40) {
tmp = Math.sin(re);
} else if (im <= 1.3e+152) {
tmp = 0.041666666666666664 * (re * Math.pow(im, 4.0));
} else {
tmp = Math.sin(re) * (0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.7e+40: tmp = math.sin(re) elif im <= 1.3e+152: tmp = 0.041666666666666664 * (re * math.pow(im, 4.0)) else: tmp = math.sin(re) * (0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.7e+40) tmp = sin(re); elseif (im <= 1.3e+152) tmp = Float64(0.041666666666666664 * Float64(re * (im ^ 4.0))); else tmp = Float64(sin(re) * Float64(0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.7e+40) tmp = sin(re); elseif (im <= 1.3e+152) tmp = 0.041666666666666664 * (re * (im ^ 4.0)); else tmp = sin(re) * (0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.7e+40], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.3e+152], N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.7 \cdot 10^{+40}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1.69999999999999994e40Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 64.0%
if 1.69999999999999994e40 < im < 1.3e152Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around 0 80.0%
distribute-lft-out80.0%
+-commutative80.0%
rec-exp80.0%
Simplified80.0%
Taylor expanded in im around 0 70.7%
unpow270.7%
Simplified70.7%
Taylor expanded in im around inf 70.7%
if 1.3e152 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 94.6%
unpow294.6%
Simplified94.6%
Taylor expanded in im around inf 94.6%
*-commutative94.6%
associate-*l*94.6%
*-commutative94.6%
unpow294.6%
Simplified94.6%
Final simplification68.4%
(FPCore (re im)
:precision binary64
(if (<= im 5.5)
(sin re)
(if (<= im 1.3e+152)
(* re (+ 0.5 (* 0.5 (exp im))))
(* (sin re) (* 0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 5.5) {
tmp = sin(re);
} else if (im <= 1.3e+152) {
tmp = re * (0.5 + (0.5 * exp(im)));
} else {
tmp = sin(re) * (0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 5.5d0) then
tmp = sin(re)
else if (im <= 1.3d+152) then
tmp = re * (0.5d0 + (0.5d0 * exp(im)))
else
tmp = sin(re) * (0.5d0 * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.5) {
tmp = Math.sin(re);
} else if (im <= 1.3e+152) {
tmp = re * (0.5 + (0.5 * Math.exp(im)));
} else {
tmp = Math.sin(re) * (0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.5: tmp = math.sin(re) elif im <= 1.3e+152: tmp = re * (0.5 + (0.5 * math.exp(im))) else: tmp = math.sin(re) * (0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.5) tmp = sin(re); elseif (im <= 1.3e+152) tmp = Float64(re * Float64(0.5 + Float64(0.5 * exp(im)))); else tmp = Float64(sin(re) * Float64(0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.5) tmp = sin(re); elseif (im <= 1.3e+152) tmp = re * (0.5 + (0.5 * exp(im))); else tmp = sin(re) * (0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.5], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.3e+152], N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.5:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\
\;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 5.5Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 66.8%
if 5.5 < im < 1.3e152Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 69.0%
if 1.3e152 < im Initial program 100.0%
sub0-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 94.6%
unpow294.6%
Simplified94.6%
Taylor expanded in im around inf 94.6%
*-commutative94.6%
associate-*l*94.6%
*-commutative94.6%
unpow294.6%
Simplified94.6%
Final simplification70.5%
(FPCore (re im) :precision binary64 (if (<= im 1.7e+40) (sin re) (* 0.041666666666666664 (* re (pow im 4.0)))))
double code(double re, double im) {
double tmp;
if (im <= 1.7e+40) {
tmp = sin(re);
} else {
tmp = 0.041666666666666664 * (re * pow(im, 4.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.7d+40) then
tmp = sin(re)
else
tmp = 0.041666666666666664d0 * (re * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.7e+40) {
tmp = Math.sin(re);
} else {
tmp = 0.041666666666666664 * (re * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.7e+40: tmp = math.sin(re) else: tmp = 0.041666666666666664 * (re * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.7e+40) tmp = sin(re); else tmp = Float64(0.041666666666666664 * Float64(re * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.7e+40) tmp = sin(re); else tmp = 0.041666666666666664 * (re * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.7e+40], N[Sin[re], $MachinePrecision], N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.7 \cdot 10^{+40}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 1.69999999999999994e40Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 64.0%
if 1.69999999999999994e40 < im Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around 0 76.9%
distribute-lft-out76.9%
+-commutative76.9%
rec-exp76.9%
Simplified76.9%
Taylor expanded in im around 0 73.3%
unpow273.3%
Simplified73.3%
Taylor expanded in im around inf 73.3%
Final simplification65.9%
(FPCore (re im) :precision binary64 (if (<= im 1.7e+40) (sin re) (* re (+ 1.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333)))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.7e+40) {
tmp = sin(re);
} else {
tmp = re * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.7d+40) then
tmp = sin(re)
else
tmp = re * (1.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.7e+40) {
tmp = Math.sin(re);
} else {
tmp = re * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.7e+40: tmp = math.sin(re) else: tmp = re * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.7e+40) tmp = sin(re); else tmp = Float64(re * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.7e+40) tmp = sin(re); else tmp = re * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.7e+40], N[Sin[re], $MachinePrecision], N[(re * N[(1.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.7 \cdot 10^{+40}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.69999999999999994e40Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 64.0%
if 1.69999999999999994e40 < im Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 79.9%
+-commutative79.9%
associate-+l+79.9%
*-commutative79.9%
unpow379.9%
unpow279.9%
associate-*r*79.9%
unpow279.9%
associate-*r*79.9%
distribute-rgt-out79.9%
distribute-lft-out79.9%
unpow279.9%
associate-*r*79.9%
distribute-rgt-out79.9%
*-commutative79.9%
Simplified79.9%
Taylor expanded in re around 0 69.6%
Final simplification65.1%
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* im (+ 0.5 (* im (+ 0.25 (* im 0.08333333333333333))))))))
double code(double re, double im) {
return re * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * (1.0d0 + (im * (0.5d0 + (im * (0.25d0 + (im * 0.08333333333333333d0))))))
end function
public static double code(double re, double im) {
return re * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))));
}
def code(re, im): return re * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333))))))
function code(re, im) return Float64(re * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * Float64(0.25 + Float64(im * 0.08333333333333333))))))) end
function tmp = code(re, im) tmp = re * (1.0 + (im * (0.5 + (im * (0.25 + (im * 0.08333333333333333)))))); end
code[re_, im_] := N[(re * N[(1.0 + N[(im * N[(0.5 + N[(im * N[(0.25 + N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\right)
\end{array}
Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 73.9%
Taylor expanded in im around 0 65.8%
+-commutative65.8%
associate-+l+65.8%
*-commutative65.8%
unpow365.8%
unpow265.8%
associate-*r*65.8%
unpow265.8%
associate-*r*65.8%
distribute-rgt-out65.8%
distribute-lft-out65.8%
unpow265.8%
associate-*r*65.8%
distribute-rgt-out65.8%
*-commutative65.8%
Simplified65.8%
Taylor expanded in re around 0 42.6%
Final simplification42.6%
(FPCore (re im) :precision binary64 (if (<= im 1.4) re (* (* im im) (* re 0.5))))
double code(double re, double im) {
double tmp;
if (im <= 1.4) {
tmp = re;
} else {
tmp = (im * im) * (re * 0.5);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.4d0) then
tmp = re
else
tmp = (im * im) * (re * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.4) {
tmp = re;
} else {
tmp = (im * im) * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.4: tmp = re else: tmp = (im * im) * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.4) tmp = re; else tmp = Float64(Float64(im * im) * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.4) tmp = re; else tmp = (im * im) * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.4], re, N[(N[(im * im), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.4:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if im < 1.3999999999999999Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around 0 50.5%
distribute-lft-out50.5%
+-commutative50.5%
rec-exp50.5%
Simplified50.5%
Taylor expanded in im around 0 28.7%
if 1.3999999999999999 < im Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around 0 72.1%
Taylor expanded in im around 0 47.2%
unpow247.2%
Simplified47.2%
Taylor expanded in im around inf 47.2%
unpow247.2%
associate-*r*47.2%
*-commutative47.2%
*-commutative47.2%
Simplified47.2%
Final simplification33.1%
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* 0.5 (* im im)))))
double code(double re, double im) {
return re * (1.0 + (0.5 * (im * im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * (1.0d0 + (0.5d0 * (im * im)))
end function
public static double code(double re, double im) {
return re * (1.0 + (0.5 * (im * im)));
}
def code(re, im): return re * (1.0 + (0.5 * (im * im)))
function code(re, im) return Float64(re * Float64(1.0 + Float64(0.5 * Float64(im * im)))) end
function tmp = code(re, im) tmp = re * (1.0 + (0.5 * (im * im))); end
code[re_, im_] := N[(re * N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)
\end{array}
Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around 0 55.6%
Taylor expanded in im around 0 43.1%
unpow243.1%
Simplified43.1%
Final simplification43.1%
(FPCore (re im) :precision binary64 (+ re (* (* im im) (* re 0.5))))
double code(double re, double im) {
return re + ((im * im) * (re * 0.5));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re + ((im * im) * (re * 0.5d0))
end function
public static double code(double re, double im) {
return re + ((im * im) * (re * 0.5));
}
def code(re, im): return re + ((im * im) * (re * 0.5))
function code(re, im) return Float64(re + Float64(Float64(im * im) * Float64(re * 0.5))) end
function tmp = code(re, im) tmp = re + ((im * im) * (re * 0.5)); end
code[re_, im_] := N[(re + N[(N[(im * im), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re + \left(im \cdot im\right) \cdot \left(re \cdot 0.5\right)
\end{array}
Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around 0 55.6%
Taylor expanded in im around 0 43.1%
unpow243.1%
Simplified43.1%
+-commutative43.1%
distribute-rgt-in43.1%
*-commutative43.1%
associate-*l*43.1%
*-un-lft-identity43.1%
Applied egg-rr43.1%
Final simplification43.1%
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
return re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re
end function
public static double code(double re, double im) {
return re;
}
def code(re, im): return re
function code(re, im) return re end
function tmp = code(re, im) tmp = re; end
code[re_, im_] := re
\begin{array}{l}
\\
re
\end{array}
Initial program 100.0%
distribute-lft-in100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-def100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around 0 55.6%
distribute-lft-out55.6%
+-commutative55.6%
rec-exp55.6%
Simplified55.6%
Taylor expanded in im around 0 22.5%
Final simplification22.5%
herbie shell --seed 2023230
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))