
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
Initial program 100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.9998845436550344) (not (<= (exp re) 1.0005))) (exp re) (cos im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.9998845436550344) || !(exp(re) <= 1.0005)) {
tmp = exp(re);
} else {
tmp = cos(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.9998845436550344d0) .or. (.not. (exp(re) <= 1.0005d0))) then
tmp = exp(re)
else
tmp = cos(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 0.9998845436550344) || !(Math.exp(re) <= 1.0005)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.9998845436550344) or not (math.exp(re) <= 1.0005): tmp = math.exp(re) else: tmp = math.cos(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.9998845436550344) || !(exp(re) <= 1.0005)) tmp = exp(re); else tmp = cos(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.9998845436550344) || ~((exp(re) <= 1.0005))) tmp = exp(re); else tmp = cos(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.9998845436550344], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.0005]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Cos[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.9998845436550344 \lor \neg \left(e^{re} \leq 1.0005\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.99988454365503443 or 1.00049999999999994 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 86.8%
if 0.99988454365503443 < (exp.f64 re) < 1.00049999999999994Initial program 100.0%
Taylor expanded in re around 0 99.5%
Final simplification93.5%
(FPCore (re im)
:precision binary64
(if (<= re -0.000112)
(exp re)
(if (<= re 0.0005)
(* (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))
(if (<= re 1.05e+103)
(exp re)
(*
(cos im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))))
double code(double re, double im) {
double tmp;
if (re <= -0.000112) {
tmp = exp(re);
} else if (re <= 0.0005) {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else if (re <= 1.05e+103) {
tmp = exp(re);
} else {
tmp = cos(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.000112d0)) then
tmp = exp(re)
else if (re <= 0.0005d0) then
tmp = cos(im) * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
else if (re <= 1.05d+103) then
tmp = exp(re)
else
tmp = cos(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.000112) {
tmp = Math.exp(re);
} else if (re <= 0.0005) {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else if (re <= 1.05e+103) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.000112: tmp = math.exp(re) elif re <= 0.0005: tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))) elif re <= 1.05e+103: tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.000112) tmp = exp(re); elseif (re <= 0.0005) tmp = Float64(cos(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); elseif (re <= 1.05e+103) tmp = exp(re); else tmp = Float64(cos(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.000112) tmp = exp(re); elseif (re <= 0.0005) tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))); elseif (re <= 1.05e+103) tmp = exp(re); else tmp = cos(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.000112], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.0005], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.05e+103], N[Exp[re], $MachinePrecision], N[(N[Cos[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.000112:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.0005:\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\mathbf{elif}\;re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos 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 < -1.11999999999999998e-4 or 5.0000000000000001e-4 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 90.2%
if -1.11999999999999998e-4 < re < 5.0000000000000001e-4Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification96.9%
(FPCore (re im) :precision binary64 (if (or (<= re -0.000115) (and (not (<= re 0.0005)) (<= re 4.1e+145))) (exp re) (* (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.000115) || (!(re <= 0.0005) && (re <= 4.1e+145))) {
tmp = exp(re);
} else {
tmp = cos(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.000115d0)) .or. (.not. (re <= 0.0005d0)) .and. (re <= 4.1d+145)) then
tmp = exp(re)
else
tmp = cos(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.000115) || (!(re <= 0.0005) && (re <= 4.1e+145))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.000115) or (not (re <= 0.0005) and (re <= 4.1e+145)): tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.000115) || (!(re <= 0.0005) && (re <= 4.1e+145))) tmp = exp(re); else tmp = Float64(cos(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.000115) || (~((re <= 0.0005)) && (re <= 4.1e+145))) tmp = exp(re); else tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.000115], And[N[Not[LessEqual[re, 0.0005]], $MachinePrecision], LessEqual[re, 4.1e+145]]], N[Exp[re], $MachinePrecision], N[(N[Cos[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.000115 \lor \neg \left(re \leq 0.0005\right) \land re \leq 4.1 \cdot 10^{+145}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -1.15e-4 or 5.0000000000000001e-4 < re < 4.1000000000000001e145Initial program 100.0%
Taylor expanded in im around 0 91.0%
if -1.15e-4 < re < 5.0000000000000001e-4 or 4.1000000000000001e145 < re Initial program 100.0%
Taylor expanded in re around 0 99.4%
*-commutative99.4%
Simplified99.4%
Final simplification96.5%
(FPCore (re im) :precision binary64 (if (or (<= re -1.25e-5) (not (<= re 4e-5))) (exp re) (* (cos im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -1.25e-5) || !(re <= 4e-5)) {
tmp = exp(re);
} else {
tmp = cos(im) * (re + 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 <= (-1.25d-5)) .or. (.not. (re <= 4d-5))) then
tmp = exp(re)
else
tmp = cos(im) * (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -1.25e-5) || !(re <= 4e-5)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -1.25e-5) or not (re <= 4e-5): tmp = math.exp(re) else: tmp = math.cos(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -1.25e-5) || !(re <= 4e-5)) tmp = exp(re); else tmp = Float64(cos(im) * Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -1.25e-5) || ~((re <= 4e-5))) tmp = exp(re); else tmp = cos(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -1.25e-5], N[Not[LessEqual[re, 4e-5]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.25 \cdot 10^{-5} \lor \neg \left(re \leq 4 \cdot 10^{-5}\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -1.25000000000000006e-5 or 4.00000000000000033e-5 < re Initial program 100.0%
Taylor expanded in im around 0 86.8%
if -1.25000000000000006e-5 < re < 4.00000000000000033e-5Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Final simplification93.7%
(FPCore (re im)
:precision binary64
(if (<= re 0.0007)
(cos im)
(if (<= re 4.7e+95)
(+ 1.0 (* -0.5 (* im im)))
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (re <= 0.0007) {
tmp = cos(im);
} else if (re <= 4.7e+95) {
tmp = 1.0 + (-0.5 * (im * im));
} else {
tmp = 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.0007d0) then
tmp = cos(im)
else if (re <= 4.7d+95) then
tmp = 1.0d0 + ((-0.5d0) * (im * im))
else
tmp = 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.0007) {
tmp = Math.cos(im);
} else if (re <= 4.7e+95) {
tmp = 1.0 + (-0.5 * (im * im));
} else {
tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.0007: tmp = math.cos(im) elif re <= 4.7e+95: tmp = 1.0 + (-0.5 * (im * im)) else: tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.0007) tmp = cos(im); elseif (re <= 4.7e+95) tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); else tmp = 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.0007) tmp = cos(im); elseif (re <= 4.7e+95) tmp = 1.0 + (-0.5 * (im * im)); else tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.0007], N[Cos[im], $MachinePrecision], If[LessEqual[re, 4.7e+95], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.0007:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 4.7 \cdot 10^{+95}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if re < 6.99999999999999993e-4Initial program 100.0%
Taylor expanded in re around 0 69.0%
if 6.99999999999999993e-4 < re < 4.69999999999999972e95Initial program 100.0%
Taylor expanded in re around 0 4.9%
Taylor expanded in im around 0 31.4%
unpow231.4%
Applied egg-rr31.4%
if 4.69999999999999972e95 < re Initial program 100.0%
Taylor expanded in im around 0 80.0%
Taylor expanded in re around 0 77.8%
*-commutative97.8%
Simplified77.8%
(FPCore (re im) :precision binary64 (if (<= im 1.06e+218) (+ 1.0 (* re (+ 1.0 (* re 0.5)))) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (im <= 1.06e+218) {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.06d+218) then
tmp = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
else
tmp = 1.0d0 + ((-0.5d0) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.06e+218) {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.06e+218: tmp = 1.0 + (re * (1.0 + (re * 0.5))) else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.06e+218) tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))); else tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.06e+218) tmp = 1.0 + (re * (1.0 + (re * 0.5))); else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.06e+218], N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.06 \cdot 10^{+218}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if im < 1.06e218Initial program 100.0%
Taylor expanded in im around 0 77.1%
Taylor expanded in re around 0 47.7%
*-commutative68.1%
Simplified47.7%
if 1.06e218 < im Initial program 100.0%
Taylor expanded in re around 0 45.2%
Taylor expanded in im around 0 14.1%
unpow214.1%
Applied egg-rr14.1%
(FPCore (re im) :precision binary64 (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))
double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0)))))
end function
public static double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))));
}
def code(re, im): return 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))
function code(re, im) return Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666)))))) end
function tmp = code(re, im) tmp = 1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))); end
code[re_, im_] := N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 74.7%
Taylor expanded in re around 0 47.2%
*-commutative69.6%
Simplified47.2%
(FPCore (re im) :precision binary64 (if (<= re 0.0007) 1.0 (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (re <= 0.0007) {
tmp = 1.0;
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 0.0007d0) then
tmp = 1.0d0
else
tmp = 1.0d0 + ((-0.5d0) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.0007) {
tmp = 1.0;
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.0007: tmp = 1.0 else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.0007) tmp = 1.0; else tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.0007) tmp = 1.0; else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.0007], 1.0, N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.0007:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if re < 6.99999999999999993e-4Initial program 100.0%
Taylor expanded in im around 0 75.3%
Taylor expanded in re around 0 44.7%
if 6.99999999999999993e-4 < re Initial program 100.0%
Taylor expanded in re around 0 3.7%
Taylor expanded in im around 0 16.8%
unpow216.8%
Applied egg-rr16.8%
(FPCore (re im) :precision binary64 (+ re 1.0))
double code(double re, double im) {
return re + 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re + 1.0d0
end function
public static double code(double re, double im) {
return re + 1.0;
}
def code(re, im): return re + 1.0
function code(re, im) return Float64(re + 1.0) end
function tmp = code(re, im) tmp = re + 1.0; end
code[re_, im_] := N[(re + 1.0), $MachinePrecision]
\begin{array}{l}
\\
re + 1
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 54.9%
distribute-rgt1-in54.9%
Simplified54.9%
Taylor expanded in im around 0 35.5%
+-commutative35.5%
Simplified35.5%
(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%
Taylor expanded in im around 0 74.7%
Taylor expanded in re around 0 35.2%
herbie shell --seed 2024191
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))