
(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
(if (<= im 11.0)
(sin re)
(if (<= im 1.35e+154)
(* (* 0.5 re) (+ (exp (- im)) (exp im)))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 11.0) {
tmp = sin(re);
} else if (im <= 1.35e+154) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} 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) :: tmp
if (im <= 11.0d0) then
tmp = sin(re)
else if (im <= 1.35d+154) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
else
tmp = sin(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 11.0) {
tmp = Math.sin(re);
} else if (im <= 1.35e+154) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 11.0: tmp = math.sin(re) elif im <= 1.35e+154: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 11.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 11.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = (0.5 * re) * (exp(-im) + exp(im)); else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 11.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 11:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 11Initial 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.9%
if 11 < 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 69.7%
Simplified69.7%
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%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification69.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (pow im 2.0))))
(if (<= im 11.0)
(* (sin re) (+ t_0 1.0))
(if (<= im 1.35e+154)
(* (* 0.5 re) (+ (exp (- im)) (exp im)))
(* (sin re) t_0)))))
double code(double re, double im) {
double t_0 = 0.5 * pow(im, 2.0);
double tmp;
if (im <= 11.0) {
tmp = sin(re) * (t_0 + 1.0);
} else if (im <= 1.35e+154) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = sin(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 * (im ** 2.0d0)
if (im <= 11.0d0) then
tmp = sin(re) * (t_0 + 1.0d0)
else if (im <= 1.35d+154) then
tmp = (0.5d0 * re) * (exp(-im) + exp(im))
else
tmp = sin(re) * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.pow(im, 2.0);
double tmp;
if (im <= 11.0) {
tmp = Math.sin(re) * (t_0 + 1.0);
} else if (im <= 1.35e+154) {
tmp = (0.5 * re) * (Math.exp(-im) + Math.exp(im));
} else {
tmp = Math.sin(re) * t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.pow(im, 2.0) tmp = 0 if im <= 11.0: tmp = math.sin(re) * (t_0 + 1.0) elif im <= 1.35e+154: tmp = (0.5 * re) * (math.exp(-im) + math.exp(im)) else: tmp = math.sin(re) * t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * (im ^ 2.0)) tmp = 0.0 if (im <= 11.0) tmp = Float64(sin(re) * Float64(t_0 + 1.0)); elseif (im <= 1.35e+154) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(sin(re) * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im ^ 2.0); tmp = 0.0; if (im <= 11.0) tmp = sin(re) * (t_0 + 1.0); elseif (im <= 1.35e+154) tmp = (0.5 * re) * (exp(-im) + exp(im)); else tmp = sin(re) * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 11.0], N[(N[Sin[re], $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot {im}^{2}\\
\mathbf{if}\;im \leq 11:\\
\;\;\;\;\sin re \cdot \left(t\_0 + 1\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot t\_0\\
\end{array}
\end{array}
if im < 11Initial 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 81.8%
Simplified81.8%
if 11 < 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 69.7%
Simplified69.7%
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%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification82.9%
(FPCore (re im)
:precision binary64
(if (<= im 720.0)
(sin re)
(if (<= im 7.8e+142)
(sqrt (pow re -8.0))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = sin(re);
} else if (im <= 7.8e+142) {
tmp = sqrt(pow(re, -8.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) :: tmp
if (im <= 720.0d0) then
tmp = sin(re)
else if (im <= 7.8d+142) then
tmp = sqrt((re ** (-8.0d0)))
else
tmp = sin(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = Math.sin(re);
} else if (im <= 7.8e+142) {
tmp = Math.sqrt(Math.pow(re, -8.0));
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 720.0: tmp = math.sin(re) elif im <= 7.8e+142: tmp = math.sqrt(math.pow(re, -8.0)) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); elseif (im <= 7.8e+142) tmp = sqrt((re ^ -8.0)); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 720.0) tmp = sin(re); elseif (im <= 7.8e+142) tmp = sqrt((re ^ -8.0)); else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 7.8e+142], N[Sqrt[N[Power[re, -8.0], $MachinePrecision]], $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 7.8 \cdot 10^{+142}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 720Initial 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.6%
if 720 < im < 7.8000000000000001e142Initial 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 69.0%
Simplified69.0%
Applied egg-rr14.2%
add-sqr-sqrt14.2%
sqrt-unprod14.2%
exp-to-pow14.2%
exp-to-pow14.8%
pow-prod-up14.8%
metadata-eval14.8%
Applied egg-rr14.8%
if 7.8000000000000001e142 < 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 93.3%
Simplified93.3%
Taylor expanded in im around inf 93.3%
associate-*r*93.3%
*-commutative93.3%
Simplified93.3%
Final simplification62.7%
(FPCore (re im)
:precision binary64
(if (<= im 720.0)
(sin re)
(if (<= im 8e+121)
(sqrt (pow re -8.0))
(+ re (* re (* 0.5 (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = sin(re);
} else if (im <= 8e+121) {
tmp = sqrt(pow(re, -8.0));
} else {
tmp = re + (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 <= 720.0d0) then
tmp = sin(re)
else if (im <= 8d+121) then
tmp = sqrt((re ** (-8.0d0)))
else
tmp = re + (re * (0.5d0 * (im ** 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = Math.sin(re);
} else if (im <= 8e+121) {
tmp = Math.sqrt(Math.pow(re, -8.0));
} else {
tmp = re + (re * (0.5 * Math.pow(im, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 720.0: tmp = math.sin(re) elif im <= 8e+121: tmp = math.sqrt(math.pow(re, -8.0)) else: tmp = re + (re * (0.5 * math.pow(im, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = sin(re); elseif (im <= 8e+121) tmp = sqrt((re ^ -8.0)); else tmp = Float64(re + Float64(re * Float64(0.5 * (im ^ 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 720.0) tmp = sin(re); elseif (im <= 8e+121) tmp = sqrt((re ^ -8.0)); else tmp = re + (re * (0.5 * (im ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8e+121], N[Sqrt[N[Power[re, -8.0], $MachinePrecision]], $MachinePrecision], N[(re + N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 8 \cdot 10^{+121}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\
\mathbf{else}:\\
\;\;\;\;re + re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 720Initial 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.6%
if 720 < im < 8.0000000000000003e121Initial 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 69.2%
Simplified69.2%
Applied egg-rr15.8%
add-sqr-sqrt15.8%
sqrt-unprod15.8%
exp-to-pow15.8%
exp-to-pow16.3%
pow-prod-up16.3%
metadata-eval16.3%
Applied egg-rr16.3%
if 8.0000000000000003e121 < 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 67.4%
Simplified67.4%
Taylor expanded in im around 0 63.2%
associate-*r*63.2%
Simplified63.2%
Final simplification58.8%
(FPCore (re im) :precision binary64 (if (<= im 850.0) (sin re) (if (<= im 8.2e+120) (pow re -4.0) (+ re (* re (* 0.5 (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 850.0) {
tmp = sin(re);
} else if (im <= 8.2e+120) {
tmp = pow(re, -4.0);
} else {
tmp = re + (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 <= 850.0d0) then
tmp = sin(re)
else if (im <= 8.2d+120) then
tmp = re ** (-4.0d0)
else
tmp = re + (re * (0.5d0 * (im ** 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 850.0) {
tmp = Math.sin(re);
} else if (im <= 8.2e+120) {
tmp = Math.pow(re, -4.0);
} else {
tmp = re + (re * (0.5 * Math.pow(im, 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 850.0: tmp = math.sin(re) elif im <= 8.2e+120: tmp = math.pow(re, -4.0) else: tmp = re + (re * (0.5 * math.pow(im, 2.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 850.0) tmp = sin(re); elseif (im <= 8.2e+120) tmp = re ^ -4.0; else tmp = Float64(re + Float64(re * Float64(0.5 * (im ^ 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 850.0) tmp = sin(re); elseif (im <= 8.2e+120) tmp = re ^ -4.0; else tmp = re + (re * (0.5 * (im ^ 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 850.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 8.2e+120], N[Power[re, -4.0], $MachinePrecision], N[(re + N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 850:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 8.2 \cdot 10^{+120}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;re + re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 850Initial 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.6%
if 850 < im < 8.2e120Initial 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 69.2%
Simplified69.2%
Applied egg-rr16.4%
if 8.2e120 < 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 67.4%
Simplified67.4%
Taylor expanded in im around 0 63.2%
associate-*r*63.2%
Simplified63.2%
Final simplification58.8%
(FPCore (re im) :precision binary64 (if (<= im 820.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
double tmp;
if (im <= 820.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 <= 820.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 <= 820.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 820.0: tmp = math.sin(re) else: tmp = math.pow(re, -4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 820.0) tmp = sin(re); else tmp = re ^ -4.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 820.0) tmp = sin(re); else tmp = re ^ -4.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 820.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 820:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\
\end{array}
\end{array}
if im < 820Initial 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.6%
if 820 < 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 68.1%
Simplified68.1%
Applied egg-rr12.6%
Final simplification49.9%
(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.2%
Final simplification47.2%
(FPCore (re im) :precision binary64 (if (<= re 1400000.0) re (/ re (+ re (- re re)))))
double code(double re, double im) {
double tmp;
if (re <= 1400000.0) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1400000.0d0) then
tmp = re
else
tmp = re / (re + (re - re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1400000.0) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1400000.0: tmp = re else: tmp = re / (re + (re - re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 1400000.0) tmp = re; else tmp = Float64(re / Float64(re + Float64(re - re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1400000.0) tmp = re; else tmp = re / (re + (re - re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1400000.0], re, N[(re / N[(re + N[(re - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1400000:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{re}{re + \left(re - re\right)}\\
\end{array}
\end{array}
if re < 1.4e6Initial 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.2%
Simplified73.2%
Taylor expanded in im around 0 32.4%
if 1.4e6 < 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 re around 0 18.5%
Simplified18.5%
Applied egg-rr6.2%
Final simplification25.7%
(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 59.4%
Simplified59.4%
Taylor expanded in im around 0 24.8%
Final simplification24.8%
herbie shell --seed 2024085
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))