
(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 10 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%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.9999998) (not (<= (exp re) 2.0))) (exp re) (cos im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.9999998) || !(exp(re) <= 2.0)) {
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.9999998d0) .or. (.not. (exp(re) <= 2.0d0))) 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.9999998) || !(Math.exp(re) <= 2.0)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.9999998) or not (math.exp(re) <= 2.0): tmp = math.exp(re) else: tmp = math.cos(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.9999998) || !(exp(re) <= 2.0)) tmp = exp(re); else tmp = cos(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.9999998) || ~((exp(re) <= 2.0))) tmp = exp(re); else tmp = cos(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.9999998], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 2.0]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Cos[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.9999998 \lor \neg \left(e^{re} \leq 2\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.999999799999999994 or 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 78.2%
if 0.999999799999999994 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 98.3%
Final simplification87.8%
(FPCore (re im)
:precision binary64
(if (<= re -0.0058)
(exp re)
(if (<= re 0.0115)
(* (cos im) (+ (+ re 1.0) (* 0.5 (* re re))))
(if (<= re 1e+103)
(exp re)
(* (cos im) (+ (+ re 1.0) (* (* re 0.16666666666666666) (* re re))))))))
double code(double re, double im) {
double tmp;
if (re <= -0.0058) {
tmp = exp(re);
} else if (re <= 0.0115) {
tmp = cos(im) * ((re + 1.0) + (0.5 * (re * re)));
} else if (re <= 1e+103) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + ((re * 0.16666666666666666) * (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 <= (-0.0058d0)) then
tmp = exp(re)
else if (re <= 0.0115d0) then
tmp = cos(im) * ((re + 1.0d0) + (0.5d0 * (re * re)))
else if (re <= 1d+103) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + ((re * 0.16666666666666666d0) * (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.0058) {
tmp = Math.exp(re);
} else if (re <= 0.0115) {
tmp = Math.cos(im) * ((re + 1.0) + (0.5 * (re * re)));
} else if (re <= 1e+103) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + ((re * 0.16666666666666666) * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.0058: tmp = math.exp(re) elif re <= 0.0115: tmp = math.cos(im) * ((re + 1.0) + (0.5 * (re * re))) elif re <= 1e+103: tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + ((re * 0.16666666666666666) * (re * re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.0058) tmp = exp(re); elseif (re <= 0.0115) tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re)))); elseif (re <= 1e+103) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * 0.16666666666666666) * Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.0058) tmp = exp(re); elseif (re <= 0.0115) tmp = cos(im) * ((re + 1.0) + (0.5 * (re * re))); elseif (re <= 1e+103) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + ((re * 0.16666666666666666) * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.0058], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.0115], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1e+103], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * 0.16666666666666666), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0058:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.0115:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\mathbf{elif}\;re \leq 10^{+103}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + \left(re \cdot 0.16666666666666666\right) \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < -0.0058 or 0.0115 < re < 1e103Initial program 100.0%
Taylor expanded in im around 0 89.7%
if -0.0058 < re < 0.0115Initial program 100.0%
Taylor expanded in re around 0 99.7%
distribute-rgt-in99.7%
*-commutative99.7%
associate-+r+99.7%
distribute-rgt1-in99.7%
*-commutative99.7%
*-commutative99.7%
associate-*l*99.7%
associate-*r*99.7%
distribute-rgt-out99.7%
associate-*l*99.7%
distribute-lft-out99.7%
Simplified99.7%
Taylor expanded in re around 0 99.6%
if 1e103 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt-in100.0%
*-commutative100.0%
associate-+r+100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
associate-*l*100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification96.3%
(FPCore (re im)
:precision binary64
(if (<= re -0.18)
(exp re)
(if (<= re 0.013)
(*
(cos im)
(+ (+ re 1.0) (* (+ (* re 0.16666666666666666) 0.5) (* re re))))
(if (<= re 1e+103)
(exp re)
(* (cos im) (+ (+ re 1.0) (* (* re 0.16666666666666666) (* re re))))))))
double code(double re, double im) {
double tmp;
if (re <= -0.18) {
tmp = exp(re);
} else if (re <= 0.013) {
tmp = cos(im) * ((re + 1.0) + (((re * 0.16666666666666666) + 0.5) * (re * re)));
} else if (re <= 1e+103) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + ((re * 0.16666666666666666) * (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 <= (-0.18d0)) then
tmp = exp(re)
else if (re <= 0.013d0) then
tmp = cos(im) * ((re + 1.0d0) + (((re * 0.16666666666666666d0) + 0.5d0) * (re * re)))
else if (re <= 1d+103) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + ((re * 0.16666666666666666d0) * (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.18) {
tmp = Math.exp(re);
} else if (re <= 0.013) {
tmp = Math.cos(im) * ((re + 1.0) + (((re * 0.16666666666666666) + 0.5) * (re * re)));
} else if (re <= 1e+103) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + ((re * 0.16666666666666666) * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.18: tmp = math.exp(re) elif re <= 0.013: tmp = math.cos(im) * ((re + 1.0) + (((re * 0.16666666666666666) + 0.5) * (re * re))) elif re <= 1e+103: tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + ((re * 0.16666666666666666) * (re * re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.18) tmp = exp(re); elseif (re <= 0.013) tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(Float64(Float64(re * 0.16666666666666666) + 0.5) * Float64(re * re)))); elseif (re <= 1e+103) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * 0.16666666666666666) * Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.18) tmp = exp(re); elseif (re <= 0.013) tmp = cos(im) * ((re + 1.0) + (((re * 0.16666666666666666) + 0.5) * (re * re))); elseif (re <= 1e+103) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + ((re * 0.16666666666666666) * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.18], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.013], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1e+103], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * 0.16666666666666666), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.18:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.013:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + \left(re \cdot 0.16666666666666666 + 0.5\right) \cdot \left(re \cdot re\right)\right)\\
\mathbf{elif}\;re \leq 10^{+103}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + \left(re \cdot 0.16666666666666666\right) \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < -0.17999999999999999 or 0.0129999999999999994 < re < 1e103Initial program 100.0%
Taylor expanded in im around 0 89.7%
if -0.17999999999999999 < re < 0.0129999999999999994Initial program 100.0%
Taylor expanded in re around 0 99.7%
distribute-rgt-in99.7%
*-commutative99.7%
associate-+r+99.7%
distribute-rgt1-in99.7%
*-commutative99.7%
*-commutative99.7%
associate-*l*99.7%
associate-*r*99.7%
distribute-rgt-out99.7%
associate-*l*99.7%
distribute-lft-out99.7%
Simplified99.7%
fma-undefine99.7%
Applied egg-rr99.7%
if 1e103 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt-in100.0%
*-commutative100.0%
associate-+r+100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
associate-*l*100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification96.4%
(FPCore (re im) :precision binary64 (if (or (<= re -0.0035) (and (not (<= re 0.0125)) (<= re 3.75e+152))) (exp re) (* (cos im) (+ (+ re 1.0) (* 0.5 (* re re))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0035) || (!(re <= 0.0125) && (re <= 3.75e+152))) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + (0.5 * (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 <= (-0.0035d0)) .or. (.not. (re <= 0.0125d0)) .and. (re <= 3.75d+152)) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + (0.5d0 * (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.0035) || (!(re <= 0.0125) && (re <= 3.75e+152))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + (0.5 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0035) or (not (re <= 0.0125) and (re <= 3.75e+152)): tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + (0.5 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0035) || (!(re <= 0.0125) && (re <= 3.75e+152))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.0035) || (~((re <= 0.0125)) && (re <= 3.75e+152))) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + (0.5 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.0035], And[N[Not[LessEqual[re, 0.0125]], $MachinePrecision], LessEqual[re, 3.75e+152]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0035 \lor \neg \left(re \leq 0.0125\right) \land re \leq 3.75 \cdot 10^{+152}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < -0.00350000000000000007 or 0.012500000000000001 < re < 3.75000000000000023e152Initial program 100.0%
Taylor expanded in im around 0 87.2%
if -0.00350000000000000007 < re < 0.012500000000000001 or 3.75000000000000023e152 < re Initial program 100.0%
Taylor expanded in re around 0 99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-+r+99.8%
distribute-rgt1-in99.8%
*-commutative99.8%
*-commutative99.8%
associate-*l*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
associate-*l*99.8%
distribute-lft-out99.8%
Simplified99.8%
Taylor expanded in re around 0 99.2%
Final simplification94.8%
(FPCore (re im) :precision binary64 (if (or (<= re -2.3e-7) (not (<= re 0.008))) (exp re) (* (cos im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -2.3e-7) || !(re <= 0.008)) {
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 <= (-2.3d-7)) .or. (.not. (re <= 0.008d0))) 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 <= -2.3e-7) || !(re <= 0.008)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -2.3e-7) or not (re <= 0.008): tmp = math.exp(re) else: tmp = math.cos(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -2.3e-7) || !(re <= 0.008)) 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 <= -2.3e-7) || ~((re <= 0.008))) tmp = exp(re); else tmp = cos(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -2.3e-7], N[Not[LessEqual[re, 0.008]], $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 -2.3 \cdot 10^{-7} \lor \neg \left(re \leq 0.008\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -2.29999999999999995e-7 or 0.0080000000000000002 < re Initial program 100.0%
Taylor expanded in im around 0 78.2%
if -2.29999999999999995e-7 < re < 0.0080000000000000002Initial program 100.0%
Taylor expanded in re around 0 99.4%
distribute-rgt1-in99.4%
Simplified99.4%
Final simplification88.4%
(FPCore (re im) :precision binary64 (if (<= re 3.7e+98) (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= 3.7e+98) {
tmp = cos(im);
} else {
tmp = 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 <= 3.7d+98) then
tmp = cos(im)
else
tmp = 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 <= 3.7e+98) {
tmp = Math.cos(im);
} else {
tmp = 1.0 + (re * (1.0 + (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.7e+98: tmp = math.cos(im) else: tmp = 1.0 + (re * (1.0 + (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if (re <= 3.7e+98) tmp = cos(im); else tmp = 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 <= 3.7e+98) tmp = cos(im); else tmp = 1.0 + (re * (1.0 + (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.7e+98], N[Cos[im], $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.7 \cdot 10^{+98}:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 3.6999999999999999e98Initial program 100.0%
Taylor expanded in re around 0 59.6%
if 3.6999999999999999e98 < re Initial program 100.0%
Taylor expanded in re around 0 78.7%
+-commutative78.7%
fma-define78.7%
associate-*r*78.7%
distribute-rgt1-in78.7%
*-commutative78.7%
Simplified78.7%
Taylor expanded in im around 0 9.0%
Taylor expanded in im around 0 44.7%
Final simplification56.8%
(FPCore (re im) :precision binary64 (+ 1.0 (* re (+ 1.0 (* re 0.5)))))
double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * 0.5)));
}
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)))
end function
public static double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * 0.5)));
}
def code(re, im): return 1.0 + (re * (1.0 + (re * 0.5)))
function code(re, im) return Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) end
function tmp = code(re, im) tmp = 1.0 + (re * (1.0 + (re * 0.5))); end
code[re_, im_] := N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + re \cdot \left(1 + re \cdot 0.5\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 63.8%
+-commutative63.8%
fma-define63.8%
associate-*r*63.8%
distribute-rgt1-in63.8%
*-commutative63.8%
Simplified63.8%
Taylor expanded in im around 0 29.2%
Taylor expanded in im around 0 36.0%
Final simplification36.0%
(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 50.1%
distribute-rgt1-in50.1%
Simplified50.1%
Taylor expanded in im around 0 28.3%
+-commutative28.3%
Simplified28.3%
Final simplification28.3%
(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%
Taylor expanded in re around 0 50.1%
distribute-rgt1-in50.1%
Simplified50.1%
Taylor expanded in re around inf 3.9%
*-commutative3.9%
Simplified3.9%
Taylor expanded in im around 0 3.1%
Final simplification3.1%
herbie shell --seed 2024071
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))