
(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-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
(let* ((t_0 (* (+ (exp (- im)) (exp im)) (* 0.5 re))))
(if (<= im 0.042)
(* (sin re) (+ (* 0.5 (pow im 2.0)) 1.0))
(if (<= im 7.8e+56)
t_0
(if (<= im 2.15e+73)
(*
re
(*
(pow im 4.0)
(+ (* (pow re 2.0) -0.006944444444444444) 0.041666666666666664)))
(if (<= im 1.15e+77)
t_0
(* 0.041666666666666664 (* (sin re) (pow im 4.0)))))))))
double code(double re, double im) {
double t_0 = (exp(-im) + exp(im)) * (0.5 * re);
double tmp;
if (im <= 0.042) {
tmp = sin(re) * ((0.5 * pow(im, 2.0)) + 1.0);
} else if (im <= 7.8e+56) {
tmp = t_0;
} else if (im <= 2.15e+73) {
tmp = re * (pow(im, 4.0) * ((pow(re, 2.0) * -0.006944444444444444) + 0.041666666666666664));
} else if (im <= 1.15e+77) {
tmp = t_0;
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (exp(-im) + exp(im)) * (0.5d0 * re)
if (im <= 0.042d0) then
tmp = sin(re) * ((0.5d0 * (im ** 2.0d0)) + 1.0d0)
else if (im <= 7.8d+56) then
tmp = t_0
else if (im <= 2.15d+73) then
tmp = re * ((im ** 4.0d0) * (((re ** 2.0d0) * (-0.006944444444444444d0)) + 0.041666666666666664d0))
else if (im <= 1.15d+77) then
tmp = t_0
else
tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
double tmp;
if (im <= 0.042) {
tmp = Math.sin(re) * ((0.5 * Math.pow(im, 2.0)) + 1.0);
} else if (im <= 7.8e+56) {
tmp = t_0;
} else if (im <= 2.15e+73) {
tmp = re * (Math.pow(im, 4.0) * ((Math.pow(re, 2.0) * -0.006944444444444444) + 0.041666666666666664));
} else if (im <= 1.15e+77) {
tmp = t_0;
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): t_0 = (math.exp(-im) + math.exp(im)) * (0.5 * re) tmp = 0 if im <= 0.042: tmp = math.sin(re) * ((0.5 * math.pow(im, 2.0)) + 1.0) elif im <= 7.8e+56: tmp = t_0 elif im <= 2.15e+73: tmp = re * (math.pow(im, 4.0) * ((math.pow(re, 2.0) * -0.006944444444444444) + 0.041666666666666664)) elif im <= 1.15e+77: tmp = t_0 else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) t_0 = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)) tmp = 0.0 if (im <= 0.042) tmp = Float64(sin(re) * Float64(Float64(0.5 * (im ^ 2.0)) + 1.0)); elseif (im <= 7.8e+56) tmp = t_0; elseif (im <= 2.15e+73) tmp = Float64(re * Float64((im ^ 4.0) * Float64(Float64((re ^ 2.0) * -0.006944444444444444) + 0.041666666666666664))); elseif (im <= 1.15e+77) tmp = t_0; else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) t_0 = (exp(-im) + exp(im)) * (0.5 * re); tmp = 0.0; if (im <= 0.042) tmp = sin(re) * ((0.5 * (im ^ 2.0)) + 1.0); elseif (im <= 7.8e+56) tmp = t_0; elseif (im <= 2.15e+73) tmp = re * ((im ^ 4.0) * (((re ^ 2.0) * -0.006944444444444444) + 0.041666666666666664)); elseif (im <= 1.15e+77) tmp = t_0; else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.042], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7.8e+56], t$95$0, If[LessEqual[im, 2.15e+73], N[(re * N[(N[Power[im, 4.0], $MachinePrecision] * N[(N[(N[Power[re, 2.0], $MachinePrecision] * -0.006944444444444444), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.15e+77], t$95$0, N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{if}\;im \leq 0.042:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\mathbf{elif}\;im \leq 7.8 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 2.15 \cdot 10^{+73}:\\
\;\;\;\;re \cdot \left({im}^{4} \cdot \left({re}^{2} \cdot -0.006944444444444444 + 0.041666666666666664\right)\right)\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 0.0420000000000000026Initial 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 85.1%
Simplified85.1%
if 0.0420000000000000026 < im < 7.79999999999999989e56 or 2.15000000000000007e73 < im < 1.14999999999999997e77Initial 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 re around 0 73.7%
Simplified73.7%
if 7.79999999999999989e56 < im < 2.15000000000000007e73Initial 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 6.9%
Simplified6.9%
Taylor expanded in im around inf 6.9%
Taylor expanded in re around 0 72.8%
*-commutative72.8%
associate-*l*72.8%
*-commutative72.8%
distribute-lft-out72.8%
Simplified72.8%
if 1.14999999999999997e77 < 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%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification86.5%
(FPCore (re im)
:precision binary64
(if (<= im 0.0019)
(sin re)
(if (<= im 1.15e+77)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 0.0019) {
tmp = sin(re);
} else if (im <= 1.15e+77) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.0019d0) then
tmp = sin(re)
else if (im <= 1.15d+77) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.0019) {
tmp = Math.sin(re);
} else if (im <= 1.15e+77) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.0019: tmp = math.sin(re) elif im <= 1.15e+77: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.0019) tmp = sin(re); elseif (im <= 1.15e+77) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.0019) tmp = sin(re); elseif (im <= 1.15e+77) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.0019], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.15e+77], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0019:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 0.0019Initial 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 64.0%
if 0.0019 < im < 1.14999999999999997e77Initial 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 re around 0 61.5%
Simplified61.5%
if 1.14999999999999997e77 < 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%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification70.1%
(FPCore (re im)
:precision binary64
(if (<= im 0.095)
(* (sin re) (+ (* 0.5 (pow im 2.0)) 1.0))
(if (<= im 1.15e+77)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 0.095) {
tmp = sin(re) * ((0.5 * pow(im, 2.0)) + 1.0);
} else if (im <= 1.15e+77) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 0.095d0) then
tmp = sin(re) * ((0.5d0 * (im ** 2.0d0)) + 1.0d0)
else if (im <= 1.15d+77) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 0.095) {
tmp = Math.sin(re) * ((0.5 * Math.pow(im, 2.0)) + 1.0);
} else if (im <= 1.15e+77) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 0.095: tmp = math.sin(re) * ((0.5 * math.pow(im, 2.0)) + 1.0) elif im <= 1.15e+77: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 0.095) tmp = Float64(sin(re) * Float64(Float64(0.5 * (im ^ 2.0)) + 1.0)); elseif (im <= 1.15e+77) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 0.095) tmp = sin(re) * ((0.5 * (im ^ 2.0)) + 1.0); elseif (im <= 1.15e+77) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 0.095], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.15e+77], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.095:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 0.095000000000000001Initial 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 85.1%
Simplified85.1%
if 0.095000000000000001 < im < 1.14999999999999997e77Initial 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 re around 0 61.5%
Simplified61.5%
if 1.14999999999999997e77 < 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%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification85.3%
(FPCore (re im)
:precision binary64
(if (<= im 620.0)
(sin re)
(if (<= im 3.2e+76)
(log1p (expm1 re))
(* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
double tmp;
if (im <= 620.0) {
tmp = sin(re);
} else if (im <= 3.2e+76) {
tmp = log1p(expm1(re));
} else {
tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 620.0) {
tmp = Math.sin(re);
} else if (im <= 3.2e+76) {
tmp = Math.log1p(Math.expm1(re));
} else {
tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 620.0: tmp = math.sin(re) elif im <= 3.2e+76: tmp = math.log1p(math.expm1(re)) else: tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 620.0) tmp = sin(re); elseif (im <= 3.2e+76) tmp = log1p(expm1(re)); else tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 620.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.2e+76], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 620:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 3.2 \cdot 10^{+76}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\
\end{array}
\end{array}
if im < 620Initial 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 63.7%
if 620 < im < 3.19999999999999976e76Initial 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 re around 0 58.3%
Simplified58.3%
Applied egg-rr25.9%
if 3.19999999999999976e76 < 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 97.9%
Simplified97.9%
Taylor expanded in im around inf 97.9%
Final simplification66.3%
(FPCore (re im) :precision binary64 (if (<= im 21.0) (sin re) (* re (* (pow im 4.0) 0.041666666666666664))))
double code(double re, double im) {
double tmp;
if (im <= 21.0) {
tmp = sin(re);
} else {
tmp = re * (pow(im, 4.0) * 0.041666666666666664);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 21.0d0) then
tmp = sin(re)
else
tmp = re * ((im ** 4.0d0) * 0.041666666666666664d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 21.0) {
tmp = Math.sin(re);
} else {
tmp = re * (Math.pow(im, 4.0) * 0.041666666666666664);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 21.0: tmp = math.sin(re) else: tmp = re * (math.pow(im, 4.0) * 0.041666666666666664) return tmp
function code(re, im) tmp = 0.0 if (im <= 21.0) tmp = sin(re); else tmp = Float64(re * Float64((im ^ 4.0) * 0.041666666666666664)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 21.0) tmp = sin(re); else tmp = re * ((im ^ 4.0) * 0.041666666666666664); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 21.0], N[Sin[re], $MachinePrecision], N[(re * N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 21:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left({im}^{4} \cdot 0.041666666666666664\right)\\
\end{array}
\end{array}
if im < 21Initial 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 64.0%
if 21 < 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 65.4%
Simplified65.4%
Taylor expanded in im around inf 65.4%
Taylor expanded in re around 0 44.5%
*-commutative44.5%
*-commutative44.5%
associate-*r*44.5%
Simplified44.5%
Final simplification58.6%
(FPCore (re im) :precision binary64 (if (<= im 650.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = sin(re);
} else {
tmp = pow(re, -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 <= 650.0d0) then
tmp = sin(re)
else
tmp = re ** (-4.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 650.0: tmp = math.sin(re) else: tmp = math.pow(re, -4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 650.0) tmp = sin(re); else tmp = re ^ -4.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 650.0) tmp = sin(re); else tmp = re ^ -4.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 650:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\
\end{array}
\end{array}
if im < 650Initial 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 63.7%
if 650 < 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 re around 0 60.0%
Simplified60.0%
Applied egg-rr18.5%
Final simplification51.4%
(FPCore (re im) :precision binary64 (sin re))
double code(double re, double im) {
return sin(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re)
end function
public static double code(double re, double im) {
return Math.sin(re);
}
def code(re, im): return math.sin(re)
function code(re, im) return sin(re) end
function tmp = code(re, im) tmp = sin(re); end
code[re_, im_] := N[Sin[re], $MachinePrecision]
\begin{array}{l}
\\
\sin re
\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 47.1%
Final simplification47.1%
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
return 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0
end function
public static double code(double re, double im) {
return 1.0;
}
def code(re, im): return 1.0
function code(re, im) return 1.0 end
function tmp = code(re, im) tmp = 1.0; end
code[re_, im_] := 1.0
\begin{array}{l}
\\
1
\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 84.9%
Simplified84.9%
Applied egg-rr4.1%
+-inverses4.1%
+-rgt-identity4.1%
*-inverses4.1%
Simplified4.1%
Final simplification4.1%
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
return re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re
end function
public static double code(double re, double im) {
return re;
}
def code(re, im): return re
function code(re, im) return re end
function tmp = code(re, im) tmp = re; end
code[re_, im_] := re
\begin{array}{l}
\\
re
\end{array}
Initial program 100.0%
distribute-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 re around 0 62.4%
Simplified62.4%
Taylor expanded in im around 0 26.7%
Final simplification26.7%
herbie shell --seed 2024071
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))