
(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 18 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%
+-commutative100.0%
distribute-rgt-in100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
*-commutative100.0%
fma-define100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.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%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (<= im 1150000.0)
(*
(* (sin re) 0.5)
(+
(- 1.0 im)
(+ 1.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))
(if (<= im 1.16e+77)
(* (+ (exp im) 1.0) (* re 0.5))
(* (sin re) (* 0.041666666666666664 (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 1150000.0) {
tmp = (sin(re) * 0.5) * ((1.0 - im) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
} else if (im <= 1.16e+77) {
tmp = (exp(im) + 1.0) * (re * 0.5);
} else {
tmp = sin(re) * (0.041666666666666664 * 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 <= 1150000.0d0) then
tmp = (sin(re) * 0.5d0) * ((1.0d0 - im) + (1.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))))
else if (im <= 1.16d+77) then
tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
else
tmp = sin(re) * (0.041666666666666664d0 * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1150000.0) {
tmp = (Math.sin(re) * 0.5) * ((1.0 - im) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))));
} else if (im <= 1.16e+77) {
tmp = (Math.exp(im) + 1.0) * (re * 0.5);
} else {
tmp = Math.sin(re) * (0.041666666666666664 * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1150000.0: tmp = (math.sin(re) * 0.5) * ((1.0 - im) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))) elif im <= 1.16e+77: tmp = (math.exp(im) + 1.0) * (re * 0.5) else: tmp = math.sin(re) * (0.041666666666666664 * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1150000.0) tmp = Float64(Float64(sin(re) * 0.5) * Float64(Float64(1.0 - im) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))))); elseif (im <= 1.16e+77) tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5)); else tmp = Float64(sin(re) * Float64(0.041666666666666664 * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1150000.0) tmp = (sin(re) * 0.5) * ((1.0 - im) + (1.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))); elseif (im <= 1.16e+77) tmp = (exp(im) + 1.0) * (re * 0.5); else tmp = sin(re) * (0.041666666666666664 * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1150000.0], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.16e+77], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.041666666666666664 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1150000:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\right)\\
\mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 1.15e6Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.7%
neg-mul-169.7%
unsub-neg69.7%
Simplified69.7%
Taylor expanded in im around 0 68.4%
*-commutative68.4%
Simplified68.4%
if 1.15e6 < im < 1.1600000000000001e77Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 73.9%
*-commutative73.9%
Simplified73.9%
if 1.1600000000000001e77 < im Initial program 100.0%
+-commutative100.0%
distribute-rgt-in100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
*-commutative100.0%
fma-define100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 94.5%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification75.1%
(FPCore (re im) :precision binary64 (* (* (sin re) 0.5) (+ (exp im) (- 1.0 im))))
double code(double re, double im) {
return (sin(re) * 0.5) * (exp(im) + (1.0 - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (sin(re) * 0.5d0) * (exp(im) + (1.0d0 - im))
end function
public static double code(double re, double im) {
return (Math.sin(re) * 0.5) * (Math.exp(im) + (1.0 - im));
}
def code(re, im): return (math.sin(re) * 0.5) * (math.exp(im) + (1.0 - im))
function code(re, im) return Float64(Float64(sin(re) * 0.5) * Float64(exp(im) + Float64(1.0 - im))) end
function tmp = code(re, im) tmp = (sin(re) * 0.5) * (exp(im) + (1.0 - im)); end
code[re_, im_] := N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[(1.0 - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sin re \cdot 0.5\right) \cdot \left(e^{im} + \left(1 - im\right)\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 78.4%
neg-mul-178.4%
unsub-neg78.4%
Simplified78.4%
Final simplification78.4%
(FPCore (re im) :precision binary64 (* (* (sin re) 0.5) (+ (exp im) 1.0)))
double code(double re, double im) {
return (sin(re) * 0.5) * (exp(im) + 1.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (sin(re) * 0.5d0) * (exp(im) + 1.0d0)
end function
public static double code(double re, double im) {
return (Math.sin(re) * 0.5) * (Math.exp(im) + 1.0);
}
def code(re, im): return (math.sin(re) * 0.5) * (math.exp(im) + 1.0)
function code(re, im) return Float64(Float64(sin(re) * 0.5) * Float64(exp(im) + 1.0)) end
function tmp = code(re, im) tmp = (sin(re) * 0.5) * (exp(im) + 1.0); end
code[re_, im_] := N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sin re \cdot 0.5\right) \cdot \left(e^{im} + 1\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 78.4%
neg-mul-178.4%
unsub-neg78.4%
Simplified78.4%
Taylor expanded in im around 0 77.5%
Final simplification77.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (sin re) 0.5))
(t_1 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))
(if (<= im 1150000.0)
(* t_0 (+ (- 1.0 im) (+ 1.0 t_1)))
(if (<= im 1.02e+103)
(* (+ (exp im) 1.0) (* re 0.5))
(* t_0 (+ t_1 2.0))))))
double code(double re, double im) {
double t_0 = sin(re) * 0.5;
double t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double tmp;
if (im <= 1150000.0) {
tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
} else if (im <= 1.02e+103) {
tmp = (exp(im) + 1.0) * (re * 0.5);
} else {
tmp = t_0 * (t_1 + 2.0);
}
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 = sin(re) * 0.5d0
t_1 = im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))
if (im <= 1150000.0d0) then
tmp = t_0 * ((1.0d0 - im) + (1.0d0 + t_1))
else if (im <= 1.02d+103) then
tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
else
tmp = t_0 * (t_1 + 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.sin(re) * 0.5;
double t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))));
double tmp;
if (im <= 1150000.0) {
tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
} else if (im <= 1.02e+103) {
tmp = (Math.exp(im) + 1.0) * (re * 0.5);
} else {
tmp = t_0 * (t_1 + 2.0);
}
return tmp;
}
def code(re, im): t_0 = math.sin(re) * 0.5 t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))) tmp = 0 if im <= 1150000.0: tmp = t_0 * ((1.0 - im) + (1.0 + t_1)) elif im <= 1.02e+103: tmp = (math.exp(im) + 1.0) * (re * 0.5) else: tmp = t_0 * (t_1 + 2.0) return tmp
function code(re, im) t_0 = Float64(sin(re) * 0.5) t_1 = Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) tmp = 0.0 if (im <= 1150000.0) tmp = Float64(t_0 * Float64(Float64(1.0 - im) + Float64(1.0 + t_1))); elseif (im <= 1.02e+103) tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5)); else tmp = Float64(t_0 * Float64(t_1 + 2.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = sin(re) * 0.5; t_1 = im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))); tmp = 0.0; if (im <= 1150000.0) tmp = t_0 * ((1.0 - im) + (1.0 + t_1)); elseif (im <= 1.02e+103) tmp = (exp(im) + 1.0) * (re * 0.5); else tmp = t_0 * (t_1 + 2.0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 1150000.0], N[(t$95$0 * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.02e+103], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$1 + 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin re \cdot 0.5\\
t_1 := im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;im \leq 1150000:\\
\;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + t\_1\right)\right)\\
\mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 + 2\right)\\
\end{array}
\end{array}
if im < 1.15e6Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.7%
neg-mul-169.7%
unsub-neg69.7%
Simplified69.7%
Taylor expanded in im around 0 68.4%
*-commutative68.4%
Simplified68.4%
if 1.15e6 < im < 1.01999999999999991e103Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 75.0%
*-commutative75.0%
Simplified75.0%
if 1.01999999999999991e103 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification74.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (sin re) 0.5)))
(if (<= im 1150000.0)
(* t_0 (+ (- 1.0 im) (+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 1.02e+103)
(* (+ (exp im) 1.0) (* re 0.5))
(*
t_0
(+ (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) 2.0))))))
double code(double re, double im) {
double t_0 = sin(re) * 0.5;
double tmp;
if (im <= 1150000.0) {
tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1.02e+103) {
tmp = (exp(im) + 1.0) * (re * 0.5);
} else {
tmp = t_0 * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
}
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 = sin(re) * 0.5d0
if (im <= 1150000.0d0) then
tmp = t_0 * ((1.0d0 - im) + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 1.02d+103) then
tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
else
tmp = t_0 * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) + 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.sin(re) * 0.5;
double tmp;
if (im <= 1150000.0) {
tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1.02e+103) {
tmp = (Math.exp(im) + 1.0) * (re * 0.5);
} else {
tmp = t_0 * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
}
return tmp;
}
def code(re, im): t_0 = math.sin(re) * 0.5 tmp = 0 if im <= 1150000.0: tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 1.02e+103: tmp = (math.exp(im) + 1.0) * (re * 0.5) else: tmp = t_0 * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0) return tmp
function code(re, im) t_0 = Float64(sin(re) * 0.5) tmp = 0.0 if (im <= 1150000.0) tmp = Float64(t_0 * Float64(Float64(1.0 - im) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (im <= 1.02e+103) tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5)); else tmp = Float64(t_0 * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) + 2.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = sin(re) * 0.5; tmp = 0.0; if (im <= 1150000.0) tmp = t_0 * ((1.0 - im) + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 1.02e+103) tmp = (exp(im) + 1.0) * (re * 0.5); else tmp = t_0 * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[im, 1150000.0], N[(t$95$0 * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.02e+103], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin re \cdot 0.5\\
\mathbf{if}\;im \leq 1150000:\\
\;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\
\end{array}
\end{array}
if im < 1.15e6Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.7%
neg-mul-169.7%
unsub-neg69.7%
Simplified69.7%
Taylor expanded in im around 0 85.9%
if 1.15e6 < im < 1.01999999999999991e103Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 75.0%
*-commutative75.0%
Simplified75.0%
if 1.01999999999999991e103 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification87.2%
(FPCore (re im)
:precision binary64
(if (<= im 1150000.0)
(* 0.5 (* (sin re) (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im)))
(if (<= im 1.02e+103)
(* (+ (exp im) 1.0) (* re 0.5))
(*
(* (sin re) 0.5)
(+ (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 1150000.0) {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
} else if (im <= 1.02e+103) {
tmp = (exp(im) + 1.0) * (re * 0.5);
} else {
tmp = (sin(re) * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1150000.0d0) then
tmp = 0.5d0 * (sin(re) * ((2.0d0 + (im * (1.0d0 + (0.5d0 * im)))) - im))
else if (im <= 1.02d+103) then
tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
else
tmp = (sin(re) * 0.5d0) * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) + 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1150000.0) {
tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
} else if (im <= 1.02e+103) {
tmp = (Math.exp(im) + 1.0) * (re * 0.5);
} else {
tmp = (Math.sin(re) * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1150000.0: tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)) elif im <= 1.02e+103: tmp = (math.exp(im) + 1.0) * (re * 0.5) else: tmp = (math.sin(re) * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 1150000.0) tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im))); elseif (im <= 1.02e+103) tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5)); else tmp = Float64(Float64(sin(re) * 0.5) * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) + 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1150000.0) tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)); elseif (im <= 1.02e+103) tmp = (exp(im) + 1.0) * (re * 0.5); else tmp = (sin(re) * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1150000.0], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.02e+103], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1150000:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\
\mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\
\end{array}
\end{array}
if im < 1.15e6Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.7%
neg-mul-169.7%
unsub-neg69.7%
Simplified69.7%
Taylor expanded in im around 0 85.9%
Taylor expanded in re around inf 85.9%
if 1.15e6 < im < 1.01999999999999991e103Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 75.0%
*-commutative75.0%
Simplified75.0%
if 1.01999999999999991e103 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification87.2%
(FPCore (re im) :precision binary64 (if (or (<= im 1150000.0) (not (<= im 1.5e+147))) (* 0.5 (* (sin re) (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im))) (* (+ (exp im) 1.0) (* re 0.5))))
double code(double re, double im) {
double tmp;
if ((im <= 1150000.0) || !(im <= 1.5e+147)) {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
} else {
tmp = (exp(im) + 1.0) * (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 <= 1150000.0d0) .or. (.not. (im <= 1.5d+147))) then
tmp = 0.5d0 * (sin(re) * ((2.0d0 + (im * (1.0d0 + (0.5d0 * im)))) - im))
else
tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 1150000.0) || !(im <= 1.5e+147)) {
tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
} else {
tmp = (Math.exp(im) + 1.0) * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 1150000.0) or not (im <= 1.5e+147): tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)) else: tmp = (math.exp(im) + 1.0) * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if ((im <= 1150000.0) || !(im <= 1.5e+147)) tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im))); else tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 1150000.0) || ~((im <= 1.5e+147))) tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)); else tmp = (exp(im) + 1.0) * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 1150000.0], N[Not[LessEqual[im, 1.5e+147]], $MachinePrecision]], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1150000 \lor \neg \left(im \leq 1.5 \cdot 10^{+147}\right):\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if im < 1.15e6 or 1.49999999999999997e147 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 74.6%
neg-mul-174.6%
unsub-neg74.6%
Simplified74.6%
Taylor expanded in im around 0 87.8%
Taylor expanded in re around inf 87.8%
if 1.15e6 < im < 1.49999999999999997e147Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 71.1%
*-commutative71.1%
Simplified71.1%
Final simplification85.3%
(FPCore (re im)
:precision binary64
(if (<= im 1150000.0)
(sin re)
(if (<= im 1.5e+147)
(* (+ (exp im) 1.0) (* re 0.5))
(* (* (sin re) 0.5) (+ 2.0 (* im (+ 1.0 (* 0.5 im))))))))
double code(double re, double im) {
double tmp;
if (im <= 1150000.0) {
tmp = sin(re);
} else if (im <= 1.5e+147) {
tmp = (exp(im) + 1.0) * (re * 0.5);
} else {
tmp = (sin(re) * 0.5) * (2.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1150000.0d0) then
tmp = sin(re)
else if (im <= 1.5d+147) then
tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
else
tmp = (sin(re) * 0.5d0) * (2.0d0 + (im * (1.0d0 + (0.5d0 * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1150000.0) {
tmp = Math.sin(re);
} else if (im <= 1.5e+147) {
tmp = (Math.exp(im) + 1.0) * (re * 0.5);
} else {
tmp = (Math.sin(re) * 0.5) * (2.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1150000.0: tmp = math.sin(re) elif im <= 1.5e+147: tmp = (math.exp(im) + 1.0) * (re * 0.5) else: tmp = (math.sin(re) * 0.5) * (2.0 + (im * (1.0 + (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1150000.0) tmp = sin(re); elseif (im <= 1.5e+147) tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5)); else tmp = Float64(Float64(sin(re) * 0.5) * Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1150000.0) tmp = sin(re); elseif (im <= 1.5e+147) tmp = (exp(im) + 1.0) * (re * 0.5); else tmp = (sin(re) * 0.5) * (2.0 + (im * (1.0 + (0.5 * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1150000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.5e+147], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1150000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.5 \cdot 10^{+147}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1.15e6Initial program 100.0%
+-commutative100.0%
distribute-rgt-in100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
*-commutative100.0%
fma-define100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 69.2%
if 1.15e6 < im < 1.49999999999999997e147Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 71.1%
*-commutative71.1%
Simplified71.1%
if 1.49999999999999997e147 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around 0 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification73.3%
(FPCore (re im) :precision binary64 (if (<= im 1150000.0) (sin re) (* (+ (exp im) 1.0) (* re 0.5))))
double code(double re, double im) {
double tmp;
if (im <= 1150000.0) {
tmp = sin(re);
} else {
tmp = (exp(im) + 1.0) * (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 <= 1150000.0d0) then
tmp = sin(re)
else
tmp = (exp(im) + 1.0d0) * (re * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1150000.0) {
tmp = Math.sin(re);
} else {
tmp = (Math.exp(im) + 1.0) * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1150000.0: tmp = math.sin(re) else: tmp = (math.exp(im) + 1.0) * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (im <= 1150000.0) tmp = sin(re); else tmp = Float64(Float64(exp(im) + 1.0) * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1150000.0) tmp = sin(re); else tmp = (exp(im) + 1.0) * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1150000.0], N[Sin[re], $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1150000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if im < 1.15e6Initial program 100.0%
+-commutative100.0%
distribute-rgt-in100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
*-commutative100.0%
fma-define100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 69.2%
if 1.15e6 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 74.0%
*-commutative74.0%
Simplified74.0%
Final simplification70.5%
(FPCore (re im)
:precision binary64
(if (<= im 500.0)
(sin re)
(if (<= im 2.7e+54)
(* re (+ 2.0 (* -0.3333333333333333 (* re re))))
(*
(* re 0.5)
(+ (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 500.0) {
tmp = sin(re);
} else if (im <= 2.7e+54) {
tmp = re * (2.0 + (-0.3333333333333333 * (re * re)));
} else {
tmp = (re * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 500.0d0) then
tmp = sin(re)
else if (im <= 2.7d+54) then
tmp = re * (2.0d0 + ((-0.3333333333333333d0) * (re * re)))
else
tmp = (re * 0.5d0) * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) + 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 500.0) {
tmp = Math.sin(re);
} else if (im <= 2.7e+54) {
tmp = re * (2.0 + (-0.3333333333333333 * (re * re)));
} else {
tmp = (re * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 500.0: tmp = math.sin(re) elif im <= 2.7e+54: tmp = re * (2.0 + (-0.3333333333333333 * (re * re))) else: tmp = (re * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 500.0) tmp = sin(re); elseif (im <= 2.7e+54) tmp = Float64(re * Float64(2.0 + Float64(-0.3333333333333333 * Float64(re * re)))); else tmp = Float64(Float64(re * 0.5) * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) + 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 500.0) tmp = sin(re); elseif (im <= 2.7e+54) tmp = re * (2.0 + (-0.3333333333333333 * (re * re))); else tmp = (re * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 500.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.7e+54], N[(re * N[(2.0 + N[(-0.3333333333333333 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re * 0.5), $MachinePrecision] * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 500:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.7 \cdot 10^{+54}:\\
\;\;\;\;re \cdot \left(2 + -0.3333333333333333 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot 0.5\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)\\
\end{array}
\end{array}
if im < 500Initial program 100.0%
+-commutative100.0%
distribute-rgt-in100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
*-commutative100.0%
fma-define100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 69.2%
if 500 < im < 2.70000000000000011e54Initial program 100.0%
+-commutative100.0%
distribute-rgt-in100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
*-commutative100.0%
fma-define100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Applied egg-rr2.6%
count-22.6%
Simplified2.6%
Taylor expanded in re around 0 30.6%
unpow230.6%
Applied egg-rr30.6%
if 2.70000000000000011e54 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 76.8%
*-commutative76.8%
Simplified76.8%
Taylor expanded in im around 0 63.1%
*-commutative81.3%
Simplified63.1%
Final simplification65.3%
(FPCore (re im) :precision binary64 (* (* re 0.5) (+ (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) 2.0)))
double code(double re, double im) {
return (re * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (re * 0.5d0) * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) + 2.0d0)
end function
public static double code(double re, double im) {
return (re * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0);
}
def code(re, im): return (re * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0)
function code(re, im) return Float64(Float64(re * 0.5) * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) + 2.0)) end
function tmp = code(re, im) tmp = (re * 0.5) * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) + 2.0); end
code[re_, im_] := N[(N[(re * 0.5), $MachinePrecision] * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(re \cdot 0.5\right) \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) + 2\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 78.4%
neg-mul-178.4%
unsub-neg78.4%
Simplified78.4%
Taylor expanded in im around 0 77.5%
Taylor expanded in re around 0 46.6%
*-commutative46.6%
Simplified46.6%
Taylor expanded in im around 0 42.0%
*-commutative66.4%
Simplified42.0%
Final simplification42.0%
(FPCore (re im) :precision binary64 (* 0.5 (* re (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im))))
double code(double re, double im) {
return 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (re * ((2.0d0 + (im * (1.0d0 + (0.5d0 * im)))) - im))
end function
public static double code(double re, double im) {
return 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
}
def code(re, im): return 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im))
function code(re, im) return Float64(0.5 * Float64(re * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im))) end
function tmp = code(re, im) tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im)); end
code[re_, im_] := N[(0.5 * N[(re * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 78.4%
neg-mul-178.4%
unsub-neg78.4%
Simplified78.4%
Taylor expanded in im around 0 75.4%
Taylor expanded in re around 0 50.0%
(FPCore (re im) :precision binary64 (* (* re 0.5) (+ 2.0 (* im (+ 1.0 (* 0.5 im))))))
double code(double re, double im) {
return (re * 0.5) * (2.0 + (im * (1.0 + (0.5 * im))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (re * 0.5d0) * (2.0d0 + (im * (1.0d0 + (0.5d0 * im))))
end function
public static double code(double re, double im) {
return (re * 0.5) * (2.0 + (im * (1.0 + (0.5 * im))));
}
def code(re, im): return (re * 0.5) * (2.0 + (im * (1.0 + (0.5 * im))))
function code(re, im) return Float64(Float64(re * 0.5) * Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))) end
function tmp = code(re, im) tmp = (re * 0.5) * (2.0 + (im * (1.0 + (0.5 * im)))); end
code[re_, im_] := N[(N[(re * 0.5), $MachinePrecision] * N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(re \cdot 0.5\right) \cdot \left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 78.4%
neg-mul-178.4%
unsub-neg78.4%
Simplified78.4%
Taylor expanded in im around 0 77.5%
Taylor expanded in re around 0 46.6%
*-commutative46.6%
Simplified46.6%
Taylor expanded in im around 0 49.7%
*-commutative74.9%
Simplified49.7%
Final simplification49.7%
(FPCore (re im) :precision binary64 (* (* re 0.5) (+ im 2.0)))
double code(double re, double im) {
return (re * 0.5) * (im + 2.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (re * 0.5d0) * (im + 2.0d0)
end function
public static double code(double re, double im) {
return (re * 0.5) * (im + 2.0);
}
def code(re, im): return (re * 0.5) * (im + 2.0)
function code(re, im) return Float64(Float64(re * 0.5) * Float64(im + 2.0)) end
function tmp = code(re, im) tmp = (re * 0.5) * (im + 2.0); end
code[re_, im_] := N[(N[(re * 0.5), $MachinePrecision] * N[(im + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(re \cdot 0.5\right) \cdot \left(im + 2\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 78.4%
neg-mul-178.4%
unsub-neg78.4%
Simplified78.4%
Taylor expanded in im around 0 77.5%
Taylor expanded in re around 0 46.6%
*-commutative46.6%
Simplified46.6%
Taylor expanded in im around 0 30.8%
Final simplification30.8%
(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%
+-commutative100.0%
distribute-rgt-in100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
*-commutative100.0%
fma-define100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in im around 0 50.2%
Taylor expanded in re around 0 26.7%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 100.0%
+-commutative100.0%
distribute-rgt-in100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
*-commutative100.0%
fma-define100.0%
exp-diff100.0%
associate-*l/100.0%
exp-0100.0%
metadata-eval100.0%
Simplified100.0%
Applied egg-rr2.8%
fma-undefine2.8%
*-commutative2.8%
associate-*r*2.8%
metadata-eval2.8%
+-commutative2.8%
metadata-eval2.8%
distribute-lft-neg-in2.8%
*-commutative2.8%
sub-neg2.8%
+-inverses2.8%
Simplified2.8%
herbie shell --seed 2024132
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))