
(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) (+ (* 0.5 (exp im)) (* 0.5 (/ 1.0 (exp im))))))
double code(double re, double im) {
return sin(re) * ((0.5 * exp(im)) + (0.5 * (1.0 / 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)) + (0.5d0 * (1.0d0 / exp(im))))
end function
public static double code(double re, double im) {
return Math.sin(re) * ((0.5 * Math.exp(im)) + (0.5 * (1.0 / Math.exp(im))));
}
def code(re, im): return math.sin(re) * ((0.5 * math.exp(im)) + (0.5 * (1.0 / math.exp(im))))
function code(re, im) return Float64(sin(re) * Float64(Float64(0.5 * exp(im)) + Float64(0.5 * Float64(1.0 / exp(im))))) end
function tmp = code(re, im) tmp = sin(re) * ((0.5 * exp(im)) + (0.5 * (1.0 / exp(im)))); end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \left(0.5 \cdot e^{im} + 0.5 \cdot \frac{1}{e^{im}}\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.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%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (* (sin re) (fma 0.5 (exp im) 0.5)))
double code(double re, double im) {
return sin(re) * fma(0.5, exp(im), 0.5);
}
function code(re, im) return Float64(sin(re) * fma(0.5, exp(im), 0.5)) end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, 0.5\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 75.5%
Final simplification75.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (+ (* 0.5 (exp im)) 4.0))))
(if (<= im 125.0)
(sin re)
(if (<= im 1.55e+67)
t_0
(if (<= im 6.3e+105)
(+ (* -0.75 (pow re 3.0)) (* re 4.5))
(if (<= im 1.32e+154) t_0 (* (* (sin re) 0.5) (pow im 2.0))))))))
double code(double re, double im) {
double t_0 = re * ((0.5 * exp(im)) + 4.0);
double tmp;
if (im <= 125.0) {
tmp = sin(re);
} else if (im <= 1.55e+67) {
tmp = t_0;
} else if (im <= 6.3e+105) {
tmp = (-0.75 * pow(re, 3.0)) + (re * 4.5);
} else if (im <= 1.32e+154) {
tmp = t_0;
} else {
tmp = (sin(re) * 0.5) * pow(im, 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 = re * ((0.5d0 * exp(im)) + 4.0d0)
if (im <= 125.0d0) then
tmp = sin(re)
else if (im <= 1.55d+67) then
tmp = t_0
else if (im <= 6.3d+105) then
tmp = ((-0.75d0) * (re ** 3.0d0)) + (re * 4.5d0)
else if (im <= 1.32d+154) then
tmp = t_0
else
tmp = (sin(re) * 0.5d0) * (im ** 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * ((0.5 * Math.exp(im)) + 4.0);
double tmp;
if (im <= 125.0) {
tmp = Math.sin(re);
} else if (im <= 1.55e+67) {
tmp = t_0;
} else if (im <= 6.3e+105) {
tmp = (-0.75 * Math.pow(re, 3.0)) + (re * 4.5);
} else if (im <= 1.32e+154) {
tmp = t_0;
} else {
tmp = (Math.sin(re) * 0.5) * Math.pow(im, 2.0);
}
return tmp;
}
def code(re, im): t_0 = re * ((0.5 * math.exp(im)) + 4.0) tmp = 0 if im <= 125.0: tmp = math.sin(re) elif im <= 1.55e+67: tmp = t_0 elif im <= 6.3e+105: tmp = (-0.75 * math.pow(re, 3.0)) + (re * 4.5) elif im <= 1.32e+154: tmp = t_0 else: tmp = (math.sin(re) * 0.5) * math.pow(im, 2.0) return tmp
function code(re, im) t_0 = Float64(re * Float64(Float64(0.5 * exp(im)) + 4.0)) tmp = 0.0 if (im <= 125.0) tmp = sin(re); elseif (im <= 1.55e+67) tmp = t_0; elseif (im <= 6.3e+105) tmp = Float64(Float64(-0.75 * (re ^ 3.0)) + Float64(re * 4.5)); elseif (im <= 1.32e+154) tmp = t_0; else tmp = Float64(Float64(sin(re) * 0.5) * (im ^ 2.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = re * ((0.5 * exp(im)) + 4.0); tmp = 0.0; if (im <= 125.0) tmp = sin(re); elseif (im <= 1.55e+67) tmp = t_0; elseif (im <= 6.3e+105) tmp = (-0.75 * (re ^ 3.0)) + (re * 4.5); elseif (im <= 1.32e+154) tmp = t_0; else tmp = (sin(re) * 0.5) * (im ^ 2.0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 125.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.55e+67], t$95$0, If[LessEqual[im, 6.3e+105], N[(N[(-0.75 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] + N[(re * 4.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.32e+154], t$95$0, N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 \cdot e^{im} + 4\right)\\
\mathbf{if}\;im \leq 125:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 6.3 \cdot 10^{+105}:\\
\;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\
\mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot {im}^{2}\\
\end{array}
\end{array}
if im < 125Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 68.7%
if 125 < im < 1.54999999999999998e67 or 6.29999999999999953e105 < im < 1.31999999999999998e154Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 94.7%
if 1.54999999999999998e67 < im < 6.29999999999999953e105Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 2.9%
*-commutative2.9%
Simplified2.9%
Taylor expanded in re around 0 67.0%
if 1.31999999999999998e154 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
unpow2100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification74.5%
(FPCore (re im) :precision binary64 (if (<= im 1.6) (sin re) (* (sin re) (+ (* 0.5 (exp im)) 4.0))))
double code(double re, double im) {
double tmp;
if (im <= 1.6) {
tmp = sin(re);
} else {
tmp = sin(re) * ((0.5 * exp(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.6d0) then
tmp = sin(re)
else
tmp = sin(re) * ((0.5d0 * exp(im)) + 4.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.6) {
tmp = Math.sin(re);
} else {
tmp = Math.sin(re) * ((0.5 * Math.exp(im)) + 4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.6: tmp = math.sin(re) else: tmp = math.sin(re) * ((0.5 * math.exp(im)) + 4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.6) tmp = sin(re); else tmp = Float64(sin(re) * Float64(Float64(0.5 * exp(im)) + 4.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.6) tmp = sin(re); else tmp = sin(re) * ((0.5 * exp(im)) + 4.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.6], N[Sin[re], $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.6:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot e^{im} + 4\right)\\
\end{array}
\end{array}
if im < 1.6000000000000001Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 69.0%
if 1.6000000000000001 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in re around inf 100.0%
Final simplification76.0%
(FPCore (re im) :precision binary64 (if (<= im 2.7) (* (* (sin re) 0.5) (fma im im 2.0)) (* (sin re) (+ (* 0.5 (exp im)) 4.0))))
double code(double re, double im) {
double tmp;
if (im <= 2.7) {
tmp = (sin(re) * 0.5) * fma(im, im, 2.0);
} else {
tmp = sin(re) * ((0.5 * exp(im)) + 4.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 2.7) tmp = Float64(Float64(sin(re) * 0.5) * fma(im, im, 2.0)); else tmp = Float64(sin(re) * Float64(Float64(0.5 * exp(im)) + 4.0)); end return tmp end
code[re_, im_] := If[LessEqual[im, 2.7], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot e^{im} + 4\right)\\
\end{array}
\end{array}
if im < 2.7000000000000002Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 83.6%
+-commutative83.6%
unpow283.6%
fma-def83.6%
Simplified83.6%
if 2.7000000000000002 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in re around inf 100.0%
Final simplification87.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (+ (* 0.5 (exp im)) 4.0))))
(if (<= im 125.0)
(sin re)
(if (<= im 1.55e+67)
t_0
(if (<= im 6.3e+105)
(+ (* -0.75 (pow re 3.0)) (* re 4.5))
(if (<= im 3e+154)
t_0
(* (sin re) (+ 4.5 (* im (+ 0.5 (* im 0.25)))))))))))
double code(double re, double im) {
double t_0 = re * ((0.5 * exp(im)) + 4.0);
double tmp;
if (im <= 125.0) {
tmp = sin(re);
} else if (im <= 1.55e+67) {
tmp = t_0;
} else if (im <= 6.3e+105) {
tmp = (-0.75 * pow(re, 3.0)) + (re * 4.5);
} else if (im <= 3e+154) {
tmp = t_0;
} else {
tmp = sin(re) * (4.5 + (im * (0.5 + (im * 0.25))));
}
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 * exp(im)) + 4.0d0)
if (im <= 125.0d0) then
tmp = sin(re)
else if (im <= 1.55d+67) then
tmp = t_0
else if (im <= 6.3d+105) then
tmp = ((-0.75d0) * (re ** 3.0d0)) + (re * 4.5d0)
else if (im <= 3d+154) then
tmp = t_0
else
tmp = sin(re) * (4.5d0 + (im * (0.5d0 + (im * 0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * ((0.5 * Math.exp(im)) + 4.0);
double tmp;
if (im <= 125.0) {
tmp = Math.sin(re);
} else if (im <= 1.55e+67) {
tmp = t_0;
} else if (im <= 6.3e+105) {
tmp = (-0.75 * Math.pow(re, 3.0)) + (re * 4.5);
} else if (im <= 3e+154) {
tmp = t_0;
} else {
tmp = Math.sin(re) * (4.5 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
def code(re, im): t_0 = re * ((0.5 * math.exp(im)) + 4.0) tmp = 0 if im <= 125.0: tmp = math.sin(re) elif im <= 1.55e+67: tmp = t_0 elif im <= 6.3e+105: tmp = (-0.75 * math.pow(re, 3.0)) + (re * 4.5) elif im <= 3e+154: tmp = t_0 else: tmp = math.sin(re) * (4.5 + (im * (0.5 + (im * 0.25)))) return tmp
function code(re, im) t_0 = Float64(re * Float64(Float64(0.5 * exp(im)) + 4.0)) tmp = 0.0 if (im <= 125.0) tmp = sin(re); elseif (im <= 1.55e+67) tmp = t_0; elseif (im <= 6.3e+105) tmp = Float64(Float64(-0.75 * (re ^ 3.0)) + Float64(re * 4.5)); elseif (im <= 3e+154) tmp = t_0; else tmp = Float64(sin(re) * Float64(4.5 + Float64(im * Float64(0.5 + Float64(im * 0.25))))); end return tmp end
function tmp_2 = code(re, im) t_0 = re * ((0.5 * exp(im)) + 4.0); tmp = 0.0; if (im <= 125.0) tmp = sin(re); elseif (im <= 1.55e+67) tmp = t_0; elseif (im <= 6.3e+105) tmp = (-0.75 * (re ^ 3.0)) + (re * 4.5); elseif (im <= 3e+154) tmp = t_0; else tmp = sin(re) * (4.5 + (im * (0.5 + (im * 0.25)))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 125.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.55e+67], t$95$0, If[LessEqual[im, 6.3e+105], N[(N[(-0.75 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] + N[(re * 4.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3e+154], t$95$0, N[(N[Sin[re], $MachinePrecision] * N[(4.5 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 \cdot e^{im} + 4\right)\\
\mathbf{if}\;im \leq 125:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 6.3 \cdot 10^{+105}:\\
\;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\
\mathbf{elif}\;im \leq 3 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 125Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 68.7%
if 125 < im < 1.54999999999999998e67 or 6.29999999999999953e105 < im < 3.00000000000000026e154Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 94.7%
if 1.54999999999999998e67 < im < 6.29999999999999953e105Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 2.9%
*-commutative2.9%
Simplified2.9%
Taylor expanded in re around 0 67.0%
if 3.00000000000000026e154 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
*-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
unpow2100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
Simplified100.0%
Final simplification74.5%
(FPCore (re im)
:precision binary64
(if (<= im 125.0)
(sin re)
(if (or (<= im 1.55e+67) (not (<= im 6.3e+105)))
(* re (+ (* 0.5 (exp im)) 4.0))
(+ (* -0.75 (pow re 3.0)) (* re 4.5)))))
double code(double re, double im) {
double tmp;
if (im <= 125.0) {
tmp = sin(re);
} else if ((im <= 1.55e+67) || !(im <= 6.3e+105)) {
tmp = re * ((0.5 * exp(im)) + 4.0);
} else {
tmp = (-0.75 * pow(re, 3.0)) + (re * 4.5);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 125.0d0) then
tmp = sin(re)
else if ((im <= 1.55d+67) .or. (.not. (im <= 6.3d+105))) then
tmp = re * ((0.5d0 * exp(im)) + 4.0d0)
else
tmp = ((-0.75d0) * (re ** 3.0d0)) + (re * 4.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 125.0) {
tmp = Math.sin(re);
} else if ((im <= 1.55e+67) || !(im <= 6.3e+105)) {
tmp = re * ((0.5 * Math.exp(im)) + 4.0);
} else {
tmp = (-0.75 * Math.pow(re, 3.0)) + (re * 4.5);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 125.0: tmp = math.sin(re) elif (im <= 1.55e+67) or not (im <= 6.3e+105): tmp = re * ((0.5 * math.exp(im)) + 4.0) else: tmp = (-0.75 * math.pow(re, 3.0)) + (re * 4.5) return tmp
function code(re, im) tmp = 0.0 if (im <= 125.0) tmp = sin(re); elseif ((im <= 1.55e+67) || !(im <= 6.3e+105)) tmp = Float64(re * Float64(Float64(0.5 * exp(im)) + 4.0)); else tmp = Float64(Float64(-0.75 * (re ^ 3.0)) + Float64(re * 4.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 125.0) tmp = sin(re); elseif ((im <= 1.55e+67) || ~((im <= 6.3e+105))) tmp = re * ((0.5 * exp(im)) + 4.0); else tmp = (-0.75 * (re ^ 3.0)) + (re * 4.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 125.0], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 1.55e+67], N[Not[LessEqual[im, 6.3e+105]], $MachinePrecision]], N[(re * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.75 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] + N[(re * 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 125:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+67} \lor \neg \left(im \leq 6.3 \cdot 10^{+105}\right):\\
\;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\
\mathbf{else}:\\
\;\;\;\;-0.75 \cdot {re}^{3} + re \cdot 4.5\\
\end{array}
\end{array}
if im < 125Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 68.7%
if 125 < im < 1.54999999999999998e67 or 6.29999999999999953e105 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 82.4%
if 1.54999999999999998e67 < im < 6.29999999999999953e105Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 2.9%
*-commutative2.9%
Simplified2.9%
Taylor expanded in re around 0 67.0%
Final simplification71.4%
(FPCore (re im) :precision binary64 (if (<= im 800.0) (sin re) (if (<= im 8.2e+138) (/ 1.0 (pow re 3.0)) (* re (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 800.0) {
tmp = sin(re);
} else if (im <= 8.2e+138) {
tmp = 1.0 / pow(re, 3.0);
} else {
tmp = re * (0.5 * pow(im, 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 <= 800.0d0) then
tmp = sin(re)
else if (im <= 8.2d+138) then
tmp = 1.0d0 / (re ** 3.0d0)
else
tmp = re * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 800.0) {
tmp = Math.sin(re);
} else if (im <= 8.2e+138) {
tmp = 1.0 / Math.pow(re, 3.0);
} else {
tmp = re * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 800.0: tmp = math.sin(re) elif im <= 8.2e+138: tmp = 1.0 / math.pow(re, 3.0) else: tmp = re * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 800.0) tmp = sin(re); elseif (im <= 8.2e+138) tmp = Float64(1.0 / (re ^ 3.0)); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 800.0) tmp = sin(re); elseif (im <= 8.2e+138) tmp = 1.0 / (re ^ 3.0); else tmp = re * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 800.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8.2e+138], N[(1.0 / N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 800:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 8.2 \cdot 10^{+138}:\\
\;\;\;\;\frac{1}{{re}^{3}}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 800Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 68.7%
if 800 < im < 8.19999999999999961e138Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr39.5%
Taylor expanded in re around 0 38.7%
if 8.19999999999999961e138 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 97.2%
+-commutative97.2%
unpow297.2%
fma-def97.2%
Simplified97.2%
Taylor expanded in re around 0 72.9%
associate-*r*72.9%
*-commutative72.9%
+-commutative72.9%
unpow272.9%
fma-def72.9%
Simplified72.9%
Taylor expanded in im around inf 72.9%
associate-*r*72.9%
Simplified72.9%
Final simplification66.4%
(FPCore (re im) :precision binary64 (if (<= im 125.0) (sin re) (* re (+ (* 0.5 (exp im)) 4.0))))
double code(double re, double im) {
double tmp;
if (im <= 125.0) {
tmp = sin(re);
} else {
tmp = re * ((0.5 * exp(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 <= 125.0d0) then
tmp = sin(re)
else
tmp = re * ((0.5d0 * exp(im)) + 4.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 125.0) {
tmp = Math.sin(re);
} else {
tmp = re * ((0.5 * Math.exp(im)) + 4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 125.0: tmp = math.sin(re) else: tmp = re * ((0.5 * math.exp(im)) + 4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 125.0) tmp = sin(re); else tmp = Float64(re * Float64(Float64(0.5 * exp(im)) + 4.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 125.0) tmp = sin(re); else tmp = re * ((0.5 * exp(im)) + 4.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 125.0], N[Sin[re], $MachinePrecision], N[(re * N[(N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 125:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot e^{im} + 4\right)\\
\end{array}
\end{array}
if im < 125Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 68.7%
if 125 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.2%
Final simplification70.6%
(FPCore (re im)
:precision binary64
(if (<= im 500.0)
(sin re)
(if (<= im 2.1e+138)
(/ 1.0 (pow re 3.0))
(* re (+ 4.5 (* im (+ 0.5 (* im 0.25))))))))
double code(double re, double im) {
double tmp;
if (im <= 500.0) {
tmp = sin(re);
} else if (im <= 2.1e+138) {
tmp = 1.0 / pow(re, 3.0);
} else {
tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
}
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.1d+138) then
tmp = 1.0d0 / (re ** 3.0d0)
else
tmp = re * (4.5d0 + (im * (0.5d0 + (im * 0.25d0))))
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.1e+138) {
tmp = 1.0 / Math.pow(re, 3.0);
} else {
tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 500.0: tmp = math.sin(re) elif im <= 2.1e+138: tmp = 1.0 / math.pow(re, 3.0) else: tmp = re * (4.5 + (im * (0.5 + (im * 0.25)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 500.0) tmp = sin(re); elseif (im <= 2.1e+138) tmp = Float64(1.0 / (re ^ 3.0)); else tmp = Float64(re * Float64(4.5 + Float64(im * Float64(0.5 + Float64(im * 0.25))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 500.0) tmp = sin(re); elseif (im <= 2.1e+138) tmp = 1.0 / (re ^ 3.0); else tmp = re * (4.5 + (im * (0.5 + (im * 0.25)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 500.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.1e+138], N[(1.0 / N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision], N[(re * N[(4.5 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 500:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.1 \cdot 10^{+138}:\\
\;\;\;\;\frac{1}{{re}^{3}}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 500Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 68.7%
if 500 < im < 2.10000000000000007e138Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr39.5%
Taylor expanded in re around 0 38.7%
if 2.10000000000000007e138 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 97.2%
associate-+r+97.2%
+-commutative97.2%
*-commutative97.2%
associate-*r*97.2%
associate-*r*97.2%
distribute-rgt-out97.2%
distribute-lft-out97.2%
unpow297.2%
associate-*r*97.2%
distribute-rgt-out97.2%
Simplified97.2%
Taylor expanded in re around 0 72.9%
Final simplification66.4%
(FPCore (re im) :precision binary64 (if (<= im 9e+17) (sin re) (* re (+ 4.5 (* im (+ 0.5 (* im 0.25)))))))
double code(double re, double im) {
double tmp;
if (im <= 9e+17) {
tmp = sin(re);
} else {
tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 9d+17) then
tmp = sin(re)
else
tmp = re * (4.5d0 + (im * (0.5d0 + (im * 0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 9e+17) {
tmp = Math.sin(re);
} else {
tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 9e+17: tmp = math.sin(re) else: tmp = re * (4.5 + (im * (0.5 + (im * 0.25)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 9e+17) tmp = sin(re); else tmp = Float64(re * Float64(4.5 + Float64(im * Float64(0.5 + Float64(im * 0.25))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 9e+17) tmp = sin(re); else tmp = re * (4.5 + (im * (0.5 + (im * 0.25)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 9e+17], N[Sin[re], $MachinePrecision], N[(re * N[(4.5 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 9 \cdot 10^{+17}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 9e17Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 68.0%
if 9e17 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 59.9%
associate-+r+59.9%
+-commutative59.9%
*-commutative59.9%
associate-*r*59.9%
associate-*r*59.9%
distribute-rgt-out59.9%
distribute-lft-out59.9%
unpow259.9%
associate-*r*59.9%
distribute-rgt-out59.9%
Simplified59.9%
Taylor expanded in re around 0 53.8%
Final simplification64.9%
(FPCore (re im) :precision binary64 (if (<= im 125.0) re (* re (+ 4.5 (* im (+ 0.5 (* im 0.25)))))))
double code(double re, double im) {
double tmp;
if (im <= 125.0) {
tmp = re;
} else {
tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 125.0d0) then
tmp = re
else
tmp = re * (4.5d0 + (im * (0.5d0 + (im * 0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 125.0) {
tmp = re;
} else {
tmp = re * (4.5 + (im * (0.5 + (im * 0.25))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 125.0: tmp = re else: tmp = re * (4.5 + (im * (0.5 + (im * 0.25)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 125.0) tmp = re; else tmp = Float64(re * Float64(4.5 + Float64(im * Float64(0.5 + Float64(im * 0.25))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 125.0) tmp = re; else tmp = re * (4.5 + (im * (0.5 + (im * 0.25)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 125.0], re, N[(re * N[(4.5 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 125:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(4.5 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\
\end{array}
\end{array}
if im < 125Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 83.2%
+-commutative83.2%
unpow283.2%
fma-def83.2%
Simplified83.2%
Taylor expanded in re around 0 48.3%
associate-*r*48.3%
*-commutative48.3%
+-commutative48.3%
unpow248.3%
fma-def48.3%
Simplified48.3%
Taylor expanded in im around 0 34.6%
if 125 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 57.9%
associate-+r+57.9%
+-commutative57.9%
*-commutative57.9%
associate-*r*57.9%
associate-*r*57.9%
distribute-rgt-out57.9%
distribute-lft-out57.9%
unpow257.9%
associate-*r*57.9%
distribute-rgt-out57.9%
Simplified57.9%
Taylor expanded in re around 0 52.0%
Final simplification38.5%
(FPCore (re im) :precision binary64 (if (<= im 600.0) re (* re (+ 4.5 (* 0.5 im)))))
double code(double re, double im) {
double tmp;
if (im <= 600.0) {
tmp = re;
} else {
tmp = re * (4.5 + (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 <= 600.0d0) then
tmp = re
else
tmp = re * (4.5d0 + (0.5d0 * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 600.0) {
tmp = re;
} else {
tmp = re * (4.5 + (0.5 * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 600.0: tmp = re else: tmp = re * (4.5 + (0.5 * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 600.0) tmp = re; else tmp = Float64(re * Float64(4.5 + Float64(0.5 * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 600.0) tmp = re; else tmp = re * (4.5 + (0.5 * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 600.0], re, N[(re * N[(4.5 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 600:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(4.5 + 0.5 \cdot im\right)\\
\end{array}
\end{array}
if im < 600Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 83.2%
+-commutative83.2%
unpow283.2%
fma-def83.2%
Simplified83.2%
Taylor expanded in re around 0 48.3%
associate-*r*48.3%
*-commutative48.3%
+-commutative48.3%
unpow248.3%
fma-def48.3%
Simplified48.3%
Taylor expanded in im around 0 34.6%
if 600 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.2%
Taylor expanded in im around 0 20.2%
associate-*r*20.2%
*-commutative20.2%
distribute-rgt-out20.2%
Simplified20.2%
Final simplification31.4%
(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%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 77.5%
+-commutative77.5%
unpow277.5%
fma-def77.5%
Simplified77.5%
Taylor expanded in re around 0 49.2%
associate-*r*49.2%
*-commutative49.2%
+-commutative49.2%
unpow249.2%
fma-def49.2%
Simplified49.2%
Taylor expanded in im around 0 27.6%
Final simplification27.6%
herbie shell --seed 2023318
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))