
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
(FPCore (re im) :precision binary64 (* (/ (exp (+ 1.0 re)) E) (sin im)))
double code(double re, double im) {
return (exp((1.0 + re)) / ((double) M_E)) * sin(im);
}
public static double code(double re, double im) {
return (Math.exp((1.0 + re)) / Math.E) * Math.sin(im);
}
def code(re, im): return (math.exp((1.0 + re)) / math.e) * math.sin(im)
function code(re, im) return Float64(Float64(exp(Float64(1.0 + re)) / exp(1)) * sin(im)) end
function tmp = code(re, im) tmp = (exp((1.0 + re)) / 2.71828182845904523536) * sin(im); end
code[re_, im_] := N[(N[(N[Exp[N[(1.0 + re), $MachinePrecision]], $MachinePrecision] / E), $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{1 + re}}{e} \cdot \sin im
\end{array}
Initial program 100.0%
expm1-log1p-u78.0%
expm1-undefine78.0%
exp-diff78.0%
log1p-undefine78.0%
rem-exp-log100.0%
exp-1-e100.0%
Applied egg-rr100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.99998) (not (<= (exp re) 1.01))) (* im (exp re)) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.99998) || !(exp(re) <= 1.01)) {
tmp = im * exp(re);
} else {
tmp = sin(im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) <= 0.99998d0) .or. (.not. (exp(re) <= 1.01d0))) then
tmp = im * exp(re)
else
tmp = sin(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 0.99998) || !(Math.exp(re) <= 1.01)) {
tmp = im * Math.exp(re);
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.99998) or not (math.exp(re) <= 1.01): tmp = im * math.exp(re) else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.99998) || !(exp(re) <= 1.01)) tmp = Float64(im * exp(re)); else tmp = sin(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.99998) || ~((exp(re) <= 1.01))) tmp = im * exp(re); else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.99998], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.01]], $MachinePrecision]], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99998 \lor \neg \left(e^{re} \leq 1.01\right):\\
\;\;\;\;im \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.99997999999999998 or 1.01000000000000001 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 86.7%
if 0.99997999999999998 < (exp.f64 re) < 1.01000000000000001Initial program 100.0%
Taylor expanded in re around 0 98.8%
Final simplification93.2%
(FPCore (re im) :precision binary64 (* (sin im) (exp re)))
double code(double re, double im) {
return sin(im) * exp(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(im) * exp(re)
end function
public static double code(double re, double im) {
return Math.sin(im) * Math.exp(re);
}
def code(re, im): return math.sin(im) * math.exp(re)
function code(re, im) return Float64(sin(im) * exp(re)) end
function tmp = code(re, im) tmp = sin(im) * exp(re); end
code[re_, im_] := N[(N[Sin[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin im \cdot e^{re}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.41) (and (not (<= re 0.014)) (<= re 3.9e+87)))
(* im (exp re))
(*
(sin im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.41) || (!(re <= 0.014) && (re <= 3.9e+87))) {
tmp = im * exp(re);
} else {
tmp = sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.41d0)) .or. (.not. (re <= 0.014d0)) .and. (re <= 3.9d+87)) then
tmp = im * exp(re)
else
tmp = sin(im) * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.41) || (!(re <= 0.014) && (re <= 3.9e+87))) {
tmp = im * Math.exp(re);
} else {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.41) or (not (re <= 0.014) and (re <= 3.9e+87)): tmp = im * math.exp(re) else: tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.41) || (!(re <= 0.014) && (re <= 3.9e+87))) tmp = Float64(im * exp(re)); else tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.41) || (~((re <= 0.014)) && (re <= 3.9e+87))) tmp = im * exp(re); else tmp = sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.41], And[N[Not[LessEqual[re, 0.014]], $MachinePrecision], LessEqual[re, 3.9e+87]]], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.41 \lor \neg \left(re \leq 0.014\right) \land re \leq 3.9 \cdot 10^{+87}:\\
\;\;\;\;im \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if re < -0.409999999999999976 or 0.0140000000000000003 < re < 3.9000000000000002e87Initial program 100.0%
Taylor expanded in im around 0 96.1%
if -0.409999999999999976 < re < 0.0140000000000000003 or 3.9000000000000002e87 < re Initial program 100.0%
Taylor expanded in re around 0 98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.0%
(FPCore (re im) :precision binary64 (if (or (<= re -0.38) (and (not (<= re 0.015)) (<= re 1.9e+154))) (* im (exp re)) (* (sin im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.38) || (!(re <= 0.015) && (re <= 1.9e+154))) {
tmp = im * exp(re);
} else {
tmp = sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.38d0)) .or. (.not. (re <= 0.015d0)) .and. (re <= 1.9d+154)) then
tmp = im * exp(re)
else
tmp = sin(im) * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.38) || (!(re <= 0.015) && (re <= 1.9e+154))) {
tmp = im * Math.exp(re);
} else {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.38) or (not (re <= 0.015) and (re <= 1.9e+154)): tmp = im * math.exp(re) else: tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.38) || (!(re <= 0.015) && (re <= 1.9e+154))) tmp = Float64(im * exp(re)); else tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.38) || (~((re <= 0.015)) && (re <= 1.9e+154))) tmp = im * exp(re); else tmp = sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.38], And[N[Not[LessEqual[re, 0.015]], $MachinePrecision], LessEqual[re, 1.9e+154]]], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.38 \lor \neg \left(re \leq 0.015\right) \land re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;im \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.38 or 0.014999999999999999 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 92.4%
if -0.38 < re < 0.014999999999999999 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.1%
*-commutative99.1%
Simplified99.1%
Final simplification96.7%
(FPCore (re im) :precision binary64 (if (or (<= re -0.38) (not (<= re 4.2e-5))) (* im (exp re)) (* (sin im) (+ 1.0 re))))
double code(double re, double im) {
double tmp;
if ((re <= -0.38) || !(re <= 4.2e-5)) {
tmp = im * exp(re);
} else {
tmp = sin(im) * (1.0 + re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.38d0)) .or. (.not. (re <= 4.2d-5))) then
tmp = im * exp(re)
else
tmp = sin(im) * (1.0d0 + re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.38) || !(re <= 4.2e-5)) {
tmp = im * Math.exp(re);
} else {
tmp = Math.sin(im) * (1.0 + re);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.38) or not (re <= 4.2e-5): tmp = im * math.exp(re) else: tmp = math.sin(im) * (1.0 + re) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.38) || !(re <= 4.2e-5)) tmp = Float64(im * exp(re)); else tmp = Float64(sin(im) * Float64(1.0 + re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.38) || ~((re <= 4.2e-5))) tmp = im * exp(re); else tmp = sin(im) * (1.0 + re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.38], N[Not[LessEqual[re, 4.2e-5]], $MachinePrecision]], N[(im * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.38 \lor \neg \left(re \leq 4.2 \cdot 10^{-5}\right):\\
\;\;\;\;im \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(1 + re\right)\\
\end{array}
\end{array}
if re < -0.38 or 4.19999999999999977e-5 < re Initial program 100.0%
Taylor expanded in im around 0 88.1%
if -0.38 < re < 4.19999999999999977e-5Initial program 99.9%
Taylor expanded in re around 0 98.6%
distribute-rgt1-in98.6%
Simplified98.6%
Final simplification93.8%
(FPCore (re im)
:precision binary64
(if (<= re -60.0)
(* re (+ (+ 1.0 im) -1.0))
(if (<= re 2.2e-6)
(sin im)
(* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (re <= -60.0) {
tmp = re * ((1.0 + im) + -1.0);
} else if (re <= 2.2e-6) {
tmp = sin(im);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-60.0d0)) then
tmp = re * ((1.0d0 + im) + (-1.0d0))
else if (re <= 2.2d-6) then
tmp = sin(im)
else
tmp = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -60.0) {
tmp = re * ((1.0 + im) + -1.0);
} else if (re <= 2.2e-6) {
tmp = Math.sin(im);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -60.0: tmp = re * ((1.0 + im) + -1.0) elif re <= 2.2e-6: tmp = math.sin(im) else: tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (re <= -60.0) tmp = Float64(re * Float64(Float64(1.0 + im) + -1.0)); elseif (re <= 2.2e-6) tmp = sin(im); else tmp = Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -60.0) tmp = re * ((1.0 + im) + -1.0); elseif (re <= 2.2e-6) tmp = sin(im); else tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -60.0], N[(re * N[(N[(1.0 + im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 2.2e-6], N[Sin[im], $MachinePrecision], N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -60:\\
\;\;\;\;re \cdot \left(\left(1 + im\right) + -1\right)\\
\mathbf{elif}\;re \leq 2.2 \cdot 10^{-6}:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if re < -60Initial program 100.0%
Taylor expanded in re around 0 3.0%
distribute-rgt1-in3.0%
Simplified3.0%
expm1-log1p-u3.0%
expm1-undefine59.0%
log1p-undefine59.0%
rem-exp-log59.0%
Applied egg-rr59.0%
Taylor expanded in re around inf 59.0%
Taylor expanded in im around 0 58.9%
+-commutative58.9%
Simplified58.9%
if -60 < re < 2.2000000000000001e-6Initial program 99.9%
Taylor expanded in re around 0 96.7%
if 2.2000000000000001e-6 < re Initial program 100.0%
Taylor expanded in re around 0 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in im around 0 57.5%
Final simplification79.3%
(FPCore (re im) :precision binary64 (if (<= re -0.14) (* re (+ (+ 1.0 im) -1.0)) (* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (re <= -0.14) {
tmp = re * ((1.0 + im) + -1.0);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-0.14d0)) then
tmp = re * ((1.0d0 + im) + (-1.0d0))
else
tmp = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.14) {
tmp = re * ((1.0 + im) + -1.0);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.14: tmp = re * ((1.0 + im) + -1.0) else: tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.14) tmp = Float64(re * Float64(Float64(1.0 + im) + -1.0)); else tmp = Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.14) tmp = re * ((1.0 + im) + -1.0); else tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.14], N[(re * N[(N[(1.0 + im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.14:\\
\;\;\;\;re \cdot \left(\left(1 + im\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if re < -0.14000000000000001Initial program 99.9%
Taylor expanded in re around 0 3.8%
distribute-rgt1-in3.8%
Simplified3.8%
expm1-log1p-u3.8%
expm1-undefine56.9%
log1p-undefine56.9%
rem-exp-log56.9%
Applied egg-rr56.9%
Taylor expanded in re around inf 56.1%
Taylor expanded in im around 0 56.1%
+-commutative56.1%
Simplified56.1%
if -0.14000000000000001 < re Initial program 100.0%
Taylor expanded in re around 0 90.8%
*-commutative90.8%
Simplified90.8%
Taylor expanded in im around 0 49.8%
Final simplification51.3%
(FPCore (re im) :precision binary64 (if (<= re -55.0) (* re (+ (+ 1.0 im) -1.0)) (* im (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if (re <= -55.0) {
tmp = re * ((1.0 + im) + -1.0);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-55.0d0)) then
tmp = re * ((1.0d0 + im) + (-1.0d0))
else
tmp = im * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -55.0) {
tmp = re * ((1.0 + im) + -1.0);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -55.0: tmp = re * ((1.0 + im) + -1.0) else: tmp = im * (1.0 + (re * (1.0 + (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -55.0) tmp = Float64(re * Float64(Float64(1.0 + im) + -1.0)); else tmp = Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -55.0) tmp = re * ((1.0 + im) + -1.0); else tmp = im * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -55.0], N[(re * N[(N[(1.0 + im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -55:\\
\;\;\;\;re \cdot \left(\left(1 + im\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -55Initial program 100.0%
Taylor expanded in re around 0 3.0%
distribute-rgt1-in3.0%
Simplified3.0%
expm1-log1p-u3.0%
expm1-undefine59.0%
log1p-undefine59.0%
rem-exp-log59.0%
Applied egg-rr59.0%
Taylor expanded in re around inf 59.0%
Taylor expanded in im around 0 58.9%
+-commutative58.9%
Simplified58.9%
if -55 < re Initial program 100.0%
Taylor expanded in im around 0 55.5%
Taylor expanded in re around 0 44.3%
*-commutative82.6%
Simplified44.3%
Final simplification47.5%
(FPCore (re im) :precision binary64 (if (<= re -0.14) (* re (+ (+ 1.0 im) -1.0)) (* im (+ 1.0 re))))
double code(double re, double im) {
double tmp;
if (re <= -0.14) {
tmp = re * ((1.0 + im) + -1.0);
} else {
tmp = im * (1.0 + re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-0.14d0)) then
tmp = re * ((1.0d0 + im) + (-1.0d0))
else
tmp = im * (1.0d0 + re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.14) {
tmp = re * ((1.0 + im) + -1.0);
} else {
tmp = im * (1.0 + re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.14: tmp = re * ((1.0 + im) + -1.0) else: tmp = im * (1.0 + re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.14) tmp = Float64(re * Float64(Float64(1.0 + im) + -1.0)); else tmp = Float64(im * Float64(1.0 + re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.14) tmp = re * ((1.0 + im) + -1.0); else tmp = im * (1.0 + re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.14], N[(re * N[(N[(1.0 + im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(im * N[(1.0 + re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.14:\\
\;\;\;\;re \cdot \left(\left(1 + im\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(1 + re\right)\\
\end{array}
\end{array}
if re < -0.14000000000000001Initial program 99.9%
Taylor expanded in re around 0 3.8%
distribute-rgt1-in3.8%
Simplified3.8%
expm1-log1p-u3.8%
expm1-undefine56.9%
log1p-undefine56.9%
rem-exp-log56.9%
Applied egg-rr56.9%
Taylor expanded in re around inf 56.1%
Taylor expanded in im around 0 56.1%
+-commutative56.1%
Simplified56.1%
if -0.14000000000000001 < re Initial program 100.0%
Taylor expanded in re around 0 70.6%
distribute-rgt1-in70.6%
Simplified70.6%
Taylor expanded in im around 0 38.0%
Final simplification42.1%
(FPCore (re im) :precision binary64 (if (<= im 3.4e+98) im (* re im)))
double code(double re, double im) {
double tmp;
if (im <= 3.4e+98) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3.4d+98) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.4e+98) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.4e+98: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (im <= 3.4e+98) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.4e+98) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.4e+98], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.4 \cdot 10^{+98}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if im < 3.39999999999999972e98Initial program 100.0%
Taylor expanded in re around 0 53.3%
Taylor expanded in im around 0 32.3%
if 3.39999999999999972e98 < im Initial program 99.9%
Taylor expanded in im around 0 26.7%
Taylor expanded in re around 0 11.9%
Taylor expanded in re around inf 12.5%
Final simplification28.3%
(FPCore (re im) :precision binary64 (* im (+ 1.0 re)))
double code(double re, double im) {
return im * (1.0 + re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (1.0d0 + re)
end function
public static double code(double re, double im) {
return im * (1.0 + re);
}
def code(re, im): return im * (1.0 + re)
function code(re, im) return Float64(im * Float64(1.0 + re)) end
function tmp = code(re, im) tmp = im * (1.0 + re); end
code[re_, im_] := N[(im * N[(1.0 + re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(1 + re\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 55.4%
distribute-rgt1-in55.4%
Simplified55.4%
Taylor expanded in im around 0 30.0%
Final simplification30.0%
(FPCore (re im) :precision binary64 im)
double code(double re, double im) {
return im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im
end function
public static double code(double re, double im) {
return im;
}
def code(re, im): return im
function code(re, im) return im end
function tmp = code(re, im) tmp = im; end
code[re_, im_] := im
\begin{array}{l}
\\
im
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 54.7%
Taylor expanded in im around 0 26.3%
herbie shell --seed 2024165
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))