
(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 (* (* 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
(if (<= im 1.02)
(sin re)
(if (<= im 1.35e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 1.02) {
tmp = sin(re);
} else if (im <= 1.35e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = 0.5 * (sin(re) * 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 <= 1.02d0) then
tmp = sin(re)
else if (im <= 1.35d+154) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.02) {
tmp = Math.sin(re);
} else if (im <= 1.35e+154) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.02: tmp = math.sin(re) elif im <= 1.35e+154: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.02) tmp = sin(re); elseif (im <= 1.35e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.02) tmp = sin(re); elseif (im <= 1.35e+154) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = 0.5 * (sin(re) * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.02], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.02:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 1.02Initial 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 62.3%
if 1.02 < im < 1.35000000000000003e154Initial 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 75.8%
Simplified75.8%
if 1.35000000000000003e154 < 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 simplification68.9%
(FPCore (re im)
:precision binary64
(if (<= im 1.02)
(* (sin re) (+ (* 0.5 (pow im 2.0)) 1.0))
(if (<= im 1.35e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 1.02) {
tmp = sin(re) * ((0.5 * pow(im, 2.0)) + 1.0);
} else if (im <= 1.35e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = 0.5 * (sin(re) * 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 <= 1.02d0) then
tmp = sin(re) * ((0.5d0 * (im ** 2.0d0)) + 1.0d0)
else if (im <= 1.35d+154) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.02) {
tmp = Math.sin(re) * ((0.5 * Math.pow(im, 2.0)) + 1.0);
} else if (im <= 1.35e+154) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.02: tmp = math.sin(re) * ((0.5 * math.pow(im, 2.0)) + 1.0) elif im <= 1.35e+154: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.02) tmp = Float64(sin(re) * Float64(Float64(0.5 * (im ^ 2.0)) + 1.0)); elseif (im <= 1.35e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.02) tmp = sin(re) * ((0.5 * (im ^ 2.0)) + 1.0); elseif (im <= 1.35e+154) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = 0.5 * (sin(re) * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.02], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.02:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2} + 1\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 1.02Initial 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 79.4%
Simplified79.4%
if 1.02 < im < 1.35000000000000003e154Initial 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 75.8%
Simplified75.8%
if 1.35000000000000003e154 < 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 simplification81.6%
(FPCore (re im)
:precision binary64
(if (<= im 900.0)
(sin re)
(if (<= im 1.35e+154)
(pow (* (sin re) -2.0) -2.0)
(* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 900.0) {
tmp = sin(re);
} else if (im <= 1.35e+154) {
tmp = pow((sin(re) * -2.0), -2.0);
} else {
tmp = 0.5 * (sin(re) * 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 <= 900.0d0) then
tmp = sin(re)
else if (im <= 1.35d+154) then
tmp = (sin(re) * (-2.0d0)) ** (-2.0d0)
else
tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 900.0) {
tmp = Math.sin(re);
} else if (im <= 1.35e+154) {
tmp = Math.pow((Math.sin(re) * -2.0), -2.0);
} else {
tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 900.0: tmp = math.sin(re) elif im <= 1.35e+154: tmp = math.pow((math.sin(re) * -2.0), -2.0) else: tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 900.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = Float64(sin(re) * -2.0) ^ -2.0; else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 900.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = (sin(re) * -2.0) ^ -2.0; else tmp = 0.5 * (sin(re) * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 900.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[Power[N[(N[Sin[re], $MachinePrecision] * -2.0), $MachinePrecision], -2.0], $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 900:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 900Initial 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 62.3%
if 900 < im < 1.35000000000000003e154Initial 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%
Applied egg-rr13.9%
if 1.35000000000000003e154 < 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 simplification61.0%
(FPCore (re im)
:precision binary64
(if (<= im 900.0)
(sin re)
(if (<= im 4.2e+167)
(pow (* (sin re) -2.0) -2.0)
(* 0.5 (* re (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 900.0) {
tmp = sin(re);
} else if (im <= 4.2e+167) {
tmp = pow((sin(re) * -2.0), -2.0);
} else {
tmp = 0.5 * (re * 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 <= 900.0d0) then
tmp = sin(re)
else if (im <= 4.2d+167) then
tmp = (sin(re) * (-2.0d0)) ** (-2.0d0)
else
tmp = 0.5d0 * (re * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 900.0) {
tmp = Math.sin(re);
} else if (im <= 4.2e+167) {
tmp = Math.pow((Math.sin(re) * -2.0), -2.0);
} else {
tmp = 0.5 * (re * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 900.0: tmp = math.sin(re) elif im <= 4.2e+167: tmp = math.pow((math.sin(re) * -2.0), -2.0) else: tmp = 0.5 * (re * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 900.0) tmp = sin(re); elseif (im <= 4.2e+167) tmp = Float64(sin(re) * -2.0) ^ -2.0; else tmp = Float64(0.5 * Float64(re * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 900.0) tmp = sin(re); elseif (im <= 4.2e+167) tmp = (sin(re) * -2.0) ^ -2.0; else tmp = 0.5 * (re * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 900.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.2e+167], N[Power[N[(N[Sin[re], $MachinePrecision] * -2.0), $MachinePrecision], -2.0], $MachinePrecision], N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 900:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 4.2 \cdot 10^{+167}:\\
\;\;\;\;{\left(\sin re \cdot -2\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 900Initial 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 62.3%
if 900 < im < 4.1999999999999998e167Initial 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%
Applied egg-rr13.5%
if 4.1999999999999998e167 < 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%
Taylor expanded in re around 0 71.9%
Final simplification57.1%
(FPCore (re im) :precision binary64 (if (<= im 920.0) (sin re) (if (<= im 4.2e+167) (/ 0.25 (pow re 2.0)) (* 0.5 (* re (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 920.0) {
tmp = sin(re);
} else if (im <= 4.2e+167) {
tmp = 0.25 / pow(re, 2.0);
} else {
tmp = 0.5 * (re * 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 <= 920.0d0) then
tmp = sin(re)
else if (im <= 4.2d+167) then
tmp = 0.25d0 / (re ** 2.0d0)
else
tmp = 0.5d0 * (re * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 920.0) {
tmp = Math.sin(re);
} else if (im <= 4.2e+167) {
tmp = 0.25 / Math.pow(re, 2.0);
} else {
tmp = 0.5 * (re * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 920.0: tmp = math.sin(re) elif im <= 4.2e+167: tmp = 0.25 / math.pow(re, 2.0) else: tmp = 0.5 * (re * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 920.0) tmp = sin(re); elseif (im <= 4.2e+167) tmp = Float64(0.25 / (re ^ 2.0)); else tmp = Float64(0.5 * Float64(re * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 920.0) tmp = sin(re); elseif (im <= 4.2e+167) tmp = 0.25 / (re ^ 2.0); else tmp = 0.5 * (re * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 920.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.2e+167], N[(0.25 / N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 920:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 4.2 \cdot 10^{+167}:\\
\;\;\;\;\frac{0.25}{{re}^{2}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 920Initial 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 62.3%
if 920 < im < 4.1999999999999998e167Initial 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%
Applied egg-rr13.5%
Taylor expanded in re around 0 13.3%
if 4.1999999999999998e167 < 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%
Taylor expanded in re around 0 71.9%
Final simplification57.0%
(FPCore (re im) :precision binary64 (if (<= im 900.0) (sin re) (/ 0.25 (pow re 2.0))))
double code(double re, double im) {
double tmp;
if (im <= 900.0) {
tmp = sin(re);
} else {
tmp = 0.25 / pow(re, 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 <= 900.0d0) then
tmp = sin(re)
else
tmp = 0.25d0 / (re ** 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 900.0) {
tmp = Math.sin(re);
} else {
tmp = 0.25 / Math.pow(re, 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 900.0: tmp = math.sin(re) else: tmp = 0.25 / math.pow(re, 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 900.0) tmp = sin(re); else tmp = Float64(0.25 / (re ^ 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 900.0) tmp = sin(re); else tmp = 0.25 / (re ^ 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 900.0], N[Sin[re], $MachinePrecision], N[(0.25 / N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 900:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{{re}^{2}}\\
\end{array}
\end{array}
if im < 900Initial 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 62.3%
if 900 < 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%
Applied egg-rr15.2%
Taylor expanded in re around 0 15.1%
Final simplification50.2%
(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 46.9%
Final simplification46.9%
(FPCore (re im) :precision binary64 (if (<= re 3300000000000.0) re 1.0))
double code(double re, double im) {
double tmp;
if (re <= 3300000000000.0) {
tmp = re;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 3300000000000.0d0) then
tmp = re
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 3300000000000.0) {
tmp = re;
} else {
tmp = 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3300000000000.0: tmp = re else: tmp = 1.0 return tmp
function code(re, im) tmp = 0.0 if (re <= 3300000000000.0) tmp = re; else tmp = 1.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3300000000000.0) tmp = re; else tmp = 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3300000000000.0], re, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3300000000000:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if re < 3.3e12Initial 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 72.6%
Simplified72.6%
Taylor expanded in im around 0 28.5%
if 3.3e12 < re 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 77.1%
Simplified77.1%
Applied egg-rr6.8%
Final simplification24.3%
(FPCore (re im) :precision binary64 -4.0)
double code(double re, double im) {
return -4.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -4.0d0
end function
public static double code(double re, double im) {
return -4.0;
}
def code(re, im): return -4.0
function code(re, im) return -4.0 end
function tmp = code(re, im) tmp = -4.0; end
code[re_, im_] := -4.0
\begin{array}{l}
\\
-4
\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 72.4%
Simplified72.4%
Applied egg-rr4.3%
Final simplification4.3%
(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 72.4%
Simplified72.4%
Applied egg-rr4.8%
Final simplification4.8%
(FPCore (re im) :precision binary64 0.125)
double code(double re, double im) {
return 0.125;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.125d0
end function
public static double code(double re, double im) {
return 0.125;
}
def code(re, im): return 0.125
function code(re, im) return 0.125 end
function tmp = code(re, im) tmp = 0.125; end
code[re_, im_] := 0.125
\begin{array}{l}
\\
0.125
\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 72.4%
Simplified72.4%
Applied egg-rr4.0%
Final simplification4.0%
(FPCore (re im) :precision binary64 0.25)
double code(double re, double im) {
return 0.25;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.25d0
end function
public static double code(double re, double im) {
return 0.25;
}
def code(re, im): return 0.25
function code(re, im) return 0.25 end
function tmp = code(re, im) tmp = 0.25; end
code[re_, im_] := 0.25
\begin{array}{l}
\\
0.25
\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 72.4%
Simplified72.4%
Applied egg-rr4.1%
Final simplification4.1%
(FPCore (re im) :precision binary64 0.5)
double code(double re, double im) {
return 0.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0
end function
public static double code(double re, double im) {
return 0.5;
}
def code(re, im): return 0.5
function code(re, im) return 0.5 end
function tmp = code(re, im) tmp = 0.5; end
code[re_, im_] := 0.5
\begin{array}{l}
\\
0.5
\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 72.4%
Simplified72.4%
Applied egg-rr4.3%
Final simplification4.3%
(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 72.4%
Simplified72.4%
Applied egg-rr4.4%
Final simplification4.4%
herbie shell --seed 2024076
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))