
(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 10 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 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-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(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\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
(if (<= im 2.0)
(sin re)
(if (<= im 1.28e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(+ re (* (* 0.5 (sin re)) (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 2.0) {
tmp = sin(re);
} else if (im <= 1.28e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = re + ((0.5 * sin(re)) * (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 <= 2.0d0) then
tmp = sin(re)
else if (im <= 1.28d+154) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = re + ((0.5d0 * sin(re)) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.0) {
tmp = Math.sin(re);
} else if (im <= 1.28e+154) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = re + ((0.5 * Math.sin(re)) * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.0: tmp = math.sin(re) elif im <= 1.28e+154: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = re + ((0.5 * math.sin(re)) * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.0) tmp = sin(re); elseif (im <= 1.28e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(re + Float64(Float64(0.5 * sin(re)) * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.0) tmp = sin(re); elseif (im <= 1.28e+154) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = re + ((0.5 * sin(re)) * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.28e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(re + N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;re + \left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 2Initial 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 65.5%
if 2 < im < 1.2800000000000001e154Initial program 100.0%
distribute-lft-in99.9%
*-commutative99.9%
cancel-sign-sub99.9%
distribute-lft-neg-out99.9%
*-commutative99.9%
distribute-rgt-neg-out99.9%
neg-mul-199.9%
associate-*r*99.9%
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 re around 0 75.0%
if 1.2800000000000001e154 < 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%
Simplified100.0%
Taylor expanded in re around 0 100.0%
Final simplification70.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (sin re)) (* im im))))
(if (<= im 2.0)
(+ (sin re) t_0)
(if (<= im 1.28e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(+ re t_0)))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * (im * im);
double tmp;
if (im <= 2.0) {
tmp = sin(re) + t_0;
} else if (im <= 1.28e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = re + t_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 = (0.5d0 * sin(re)) * (im * im)
if (im <= 2.0d0) then
tmp = sin(re) + t_0
else if (im <= 1.28d+154) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = re + t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 * Math.sin(re)) * (im * im);
double tmp;
if (im <= 2.0) {
tmp = Math.sin(re) + t_0;
} else if (im <= 1.28e+154) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = re + t_0;
}
return tmp;
}
def code(re, im): t_0 = (0.5 * math.sin(re)) * (im * im) tmp = 0 if im <= 2.0: tmp = math.sin(re) + t_0 elif im <= 1.28e+154: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = re + t_0 return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * Float64(im * im)) tmp = 0.0 if (im <= 2.0) tmp = Float64(sin(re) + t_0); elseif (im <= 1.28e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(re + t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * sin(re)) * (im * im); tmp = 0.0; if (im <= 2.0) tmp = sin(re) + t_0; elseif (im <= 1.28e+154) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = re + t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 2.0], N[(N[Sin[re], $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[im, 1.28e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(re + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\
\mathbf{if}\;im \leq 2:\\
\;\;\;\;\sin re + t_0\\
\mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;re + t_0\\
\end{array}
\end{array}
if im < 2Initial 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%
Simplified83.2%
if 2 < im < 1.2800000000000001e154Initial program 100.0%
distribute-lft-in99.9%
*-commutative99.9%
cancel-sign-sub99.9%
distribute-lft-neg-out99.9%
*-commutative99.9%
distribute-rgt-neg-out99.9%
neg-mul-199.9%
associate-*r*99.9%
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 re around 0 75.0%
if 1.2800000000000001e154 < 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%
Simplified100.0%
Taylor expanded in re around 0 100.0%
Final simplification84.7%
(FPCore (re im)
:precision binary64
(if (<= im 42000000.0)
(sin re)
(if (<= im 8.5e+55)
(+ re (* (* im im) (* 0.5 (+ re (* -0.16666666666666666 (pow re 3.0))))))
(if (<= im 1.28e+154)
(log1p (expm1 re))
(+ re (* (* 0.5 (sin re)) (* im im)))))))
double code(double re, double im) {
double tmp;
if (im <= 42000000.0) {
tmp = sin(re);
} else if (im <= 8.5e+55) {
tmp = re + ((im * im) * (0.5 * (re + (-0.16666666666666666 * pow(re, 3.0)))));
} else if (im <= 1.28e+154) {
tmp = log1p(expm1(re));
} else {
tmp = re + ((0.5 * sin(re)) * (im * im));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 42000000.0) {
tmp = Math.sin(re);
} else if (im <= 8.5e+55) {
tmp = re + ((im * im) * (0.5 * (re + (-0.16666666666666666 * Math.pow(re, 3.0)))));
} else if (im <= 1.28e+154) {
tmp = Math.log1p(Math.expm1(re));
} else {
tmp = re + ((0.5 * Math.sin(re)) * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 42000000.0: tmp = math.sin(re) elif im <= 8.5e+55: tmp = re + ((im * im) * (0.5 * (re + (-0.16666666666666666 * math.pow(re, 3.0))))) elif im <= 1.28e+154: tmp = math.log1p(math.expm1(re)) else: tmp = re + ((0.5 * math.sin(re)) * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 42000000.0) tmp = sin(re); elseif (im <= 8.5e+55) tmp = Float64(re + Float64(Float64(im * im) * Float64(0.5 * Float64(re + Float64(-0.16666666666666666 * (re ^ 3.0)))))); elseif (im <= 1.28e+154) tmp = log1p(expm1(re)); else tmp = Float64(re + Float64(Float64(0.5 * sin(re)) * Float64(im * im))); end return tmp end
code[re_, im_] := If[LessEqual[im, 42000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8.5e+55], N[(re + N[(N[(im * im), $MachinePrecision] * N[(0.5 * N[(re + N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.28e+154], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], N[(re + N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 42000000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 8.5 \cdot 10^{+55}:\\
\;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\right)\\
\mathbf{elif}\;im \leq 1.28 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re + \left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 4.2e7Initial 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 65.2%
if 4.2e7 < im < 8.50000000000000002e55Initial 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 3.3%
Simplified3.3%
Taylor expanded in re around 0 1.9%
Taylor expanded in re around 0 50.9%
if 8.50000000000000002e55 < im < 1.2800000000000001e154Initial 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 re around 0 84.6%
Applied egg-rr24.4%
if 1.2800000000000001e154 < 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%
Simplified100.0%
Taylor expanded in re around 0 100.0%
Final simplification67.3%
(FPCore (re im)
:precision binary64
(if (<= im 42000000.0)
(sin re)
(if (<= im 1.35e+154)
(+ re (* (* im im) (* 0.5 (+ re (* -0.16666666666666666 (pow re 3.0))))))
(+ re (* (* 0.5 (sin re)) (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 42000000.0) {
tmp = sin(re);
} else if (im <= 1.35e+154) {
tmp = re + ((im * im) * (0.5 * (re + (-0.16666666666666666 * pow(re, 3.0)))));
} else {
tmp = re + ((0.5 * sin(re)) * (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 <= 42000000.0d0) then
tmp = sin(re)
else if (im <= 1.35d+154) then
tmp = re + ((im * im) * (0.5d0 * (re + ((-0.16666666666666666d0) * (re ** 3.0d0)))))
else
tmp = re + ((0.5d0 * sin(re)) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 42000000.0) {
tmp = Math.sin(re);
} else if (im <= 1.35e+154) {
tmp = re + ((im * im) * (0.5 * (re + (-0.16666666666666666 * Math.pow(re, 3.0)))));
} else {
tmp = re + ((0.5 * Math.sin(re)) * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 42000000.0: tmp = math.sin(re) elif im <= 1.35e+154: tmp = re + ((im * im) * (0.5 * (re + (-0.16666666666666666 * math.pow(re, 3.0))))) else: tmp = re + ((0.5 * math.sin(re)) * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 42000000.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = Float64(re + Float64(Float64(im * im) * Float64(0.5 * Float64(re + Float64(-0.16666666666666666 * (re ^ 3.0)))))); else tmp = Float64(re + Float64(Float64(0.5 * sin(re)) * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 42000000.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = re + ((im * im) * (0.5 * (re + (-0.16666666666666666 * (re ^ 3.0))))); else tmp = re + ((0.5 * sin(re)) * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 42000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(re + N[(N[(im * im), $MachinePrecision] * N[(0.5 * N[(re + N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re + N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 42000000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re + \left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 4.2e7Initial 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 65.2%
if 4.2e7 < im < 1.35000000000000003e154Initial 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 4.0%
Simplified4.0%
Taylor expanded in re around 0 3.5%
Taylor expanded in re around 0 23.1%
if 1.35000000000000003e154 < 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%
Simplified100.0%
Taylor expanded in re around 0 100.0%
Final simplification66.6%
(FPCore (re im)
:precision binary64
(if (<= im 880.0)
(sin re)
(if (<= im 6.5e+131)
(pow re -512.0)
(+ re (* (* 0.5 (sin re)) (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 880.0) {
tmp = sin(re);
} else if (im <= 6.5e+131) {
tmp = pow(re, -512.0);
} else {
tmp = re + ((0.5 * sin(re)) * (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 <= 880.0d0) then
tmp = sin(re)
else if (im <= 6.5d+131) then
tmp = re ** (-512.0d0)
else
tmp = re + ((0.5d0 * sin(re)) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 880.0) {
tmp = Math.sin(re);
} else if (im <= 6.5e+131) {
tmp = Math.pow(re, -512.0);
} else {
tmp = re + ((0.5 * Math.sin(re)) * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 880.0: tmp = math.sin(re) elif im <= 6.5e+131: tmp = math.pow(re, -512.0) else: tmp = re + ((0.5 * math.sin(re)) * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 880.0) tmp = sin(re); elseif (im <= 6.5e+131) tmp = re ^ -512.0; else tmp = Float64(re + Float64(Float64(0.5 * sin(re)) * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 880.0) tmp = sin(re); elseif (im <= 6.5e+131) tmp = re ^ -512.0; else tmp = re + ((0.5 * sin(re)) * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 880.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 6.5e+131], N[Power[re, -512.0], $MachinePrecision], N[(re + N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 880:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 6.5 \cdot 10^{+131}:\\
\;\;\;\;{re}^{-512}\\
\mathbf{else}:\\
\;\;\;\;re + \left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 880Initial 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 65.2%
if 880 < im < 6.5e131Initial 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 re around 0 70.6%
Applied egg-rr24.4%
if 6.5e131 < 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 94.5%
Simplified94.5%
Taylor expanded in re around 0 94.5%
Final simplification66.5%
(FPCore (re im) :precision binary64 (if (<= im 1050.0) (sin re) (if (<= im 1.6e+74) (pow re -512.0) (+ re (* (* im im) (* 0.5 re))))))
double code(double re, double im) {
double tmp;
if (im <= 1050.0) {
tmp = sin(re);
} else if (im <= 1.6e+74) {
tmp = pow(re, -512.0);
} else {
tmp = re + ((im * im) * (0.5 * re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1050.0d0) then
tmp = sin(re)
else if (im <= 1.6d+74) then
tmp = re ** (-512.0d0)
else
tmp = re + ((im * im) * (0.5d0 * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1050.0) {
tmp = Math.sin(re);
} else if (im <= 1.6e+74) {
tmp = Math.pow(re, -512.0);
} else {
tmp = re + ((im * im) * (0.5 * re));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1050.0: tmp = math.sin(re) elif im <= 1.6e+74: tmp = math.pow(re, -512.0) else: tmp = re + ((im * im) * (0.5 * re)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1050.0) tmp = sin(re); elseif (im <= 1.6e+74) tmp = re ^ -512.0; else tmp = Float64(re + Float64(Float64(im * im) * Float64(0.5 * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1050.0) tmp = sin(re); elseif (im <= 1.6e+74) tmp = re ^ -512.0; else tmp = re + ((im * im) * (0.5 * re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1050.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.6e+74], N[Power[re, -512.0], $MachinePrecision], N[(re + N[(N[(im * im), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1050:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.6 \cdot 10^{+74}:\\
\;\;\;\;{re}^{-512}\\
\mathbf{else}:\\
\;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 1050Initial 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 65.2%
if 1050 < im < 1.59999999999999997e74Initial 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 re around 0 70.0%
Applied egg-rr30.6%
if 1.59999999999999997e74 < 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 79.6%
Simplified79.6%
Taylor expanded in re around 0 79.6%
Taylor expanded in re around 0 55.3%
Final simplification62.3%
(FPCore (re im) :precision binary64 (if (<= im 5.1e+51) (sin re) (+ re (* (* im im) (* 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 5.1e+51) {
tmp = sin(re);
} else {
tmp = re + ((im * im) * (0.5 * re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 5.1d+51) then
tmp = sin(re)
else
tmp = re + ((im * im) * (0.5d0 * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.1e+51) {
tmp = Math.sin(re);
} else {
tmp = re + ((im * im) * (0.5 * re));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.1e+51: tmp = math.sin(re) else: tmp = re + ((im * im) * (0.5 * re)) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.1e+51) tmp = sin(re); else tmp = Float64(re + Float64(Float64(im * im) * Float64(0.5 * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.1e+51) tmp = sin(re); else tmp = re + ((im * im) * (0.5 * re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.1e+51], N[Sin[re], $MachinePrecision], N[(re + N[(N[(im * im), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.1 \cdot 10^{+51}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re + \left(im \cdot im\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 5.1000000000000001e51Initial 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 63.8%
if 5.1000000000000001e51 < 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 71.5%
Simplified71.5%
Taylor expanded in re around 0 71.5%
Taylor expanded in re around 0 49.7%
Final simplification61.2%
(FPCore (re im) :precision binary64 (+ re (* (* im im) (* 0.5 re))))
double code(double re, double im) {
return re + ((im * im) * (0.5 * re));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re + ((im * im) * (0.5d0 * re))
end function
public static double code(double re, double im) {
return re + ((im * im) * (0.5 * re));
}
def code(re, im): return re + ((im * im) * (0.5 * re))
function code(re, im) return Float64(re + Float64(Float64(im * im) * Float64(0.5 * re))) end
function tmp = code(re, im) tmp = re + ((im * im) * (0.5 * re)); end
code[re_, im_] := N[(re + N[(N[(im * im), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re + \left(im \cdot im\right) \cdot \left(0.5 \cdot re\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%
Taylor expanded in im around 0 79.2%
Simplified79.2%
Taylor expanded in re around 0 53.0%
Taylor expanded in re around 0 47.5%
Final simplification47.5%
(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 re around 0 59.1%
Taylor expanded in im around 0 26.6%
Final simplification26.6%
herbie shell --seed 2023279
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))