
(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.5) (not (<= (exp re) 1.0000001))) (exp re) (cos im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.5) || !(exp(re) <= 1.0000001)) {
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.5d0) .or. (.not. (exp(re) <= 1.0000001d0))) 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.5) || !(Math.exp(re) <= 1.0000001)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.5) or not (math.exp(re) <= 1.0000001): tmp = math.exp(re) else: tmp = math.cos(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.5) || !(exp(re) <= 1.0000001)) tmp = exp(re); else tmp = cos(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.5) || ~((exp(re) <= 1.0000001))) tmp = exp(re); else tmp = cos(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.5], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.0000001]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Cos[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.5 \lor \neg \left(e^{re} \leq 1.0000001\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.5 or 1.00000010000000006 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 90.0%
if 0.5 < (exp.f64 re) < 1.00000010000000006Initial program 100.0%
Taylor expanded in re around 0 99.4%
Final simplification94.6%
(FPCore (re im)
:precision binary64
(if (<= re -0.01)
(exp re)
(if (<= re 1.3e-7)
(* (cos im) (+ re 1.0))
(if (<= re 1.05e+103)
(exp re)
(*
(cos im)
(+ 1.0 (* re (+ 1.0 (* re (* re 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (re <= -0.01) {
tmp = exp(re);
} else if (re <= 1.3e-7) {
tmp = cos(im) * (re + 1.0);
} else if (re <= 1.05e+103) {
tmp = exp(re);
} else {
tmp = cos(im) * (1.0 + (re * (1.0 + (re * (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.01d0)) then
tmp = exp(re)
else if (re <= 1.3d-7) then
tmp = cos(im) * (re + 1.0d0)
else if (re <= 1.05d+103) then
tmp = exp(re)
else
tmp = cos(im) * (1.0d0 + (re * (1.0d0 + (re * (re * 0.16666666666666666d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.01) {
tmp = Math.exp(re);
} else if (re <= 1.3e-7) {
tmp = Math.cos(im) * (re + 1.0);
} else if (re <= 1.05e+103) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + (re * (1.0 + (re * (re * 0.16666666666666666)))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.01: tmp = math.exp(re) elif re <= 1.3e-7: tmp = math.cos(im) * (re + 1.0) elif re <= 1.05e+103: tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re * (1.0 + (re * (re * 0.16666666666666666))))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.01) tmp = exp(re); elseif (re <= 1.3e-7) tmp = Float64(cos(im) * Float64(re + 1.0)); elseif (re <= 1.05e+103) tmp = exp(re); else tmp = Float64(cos(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(re * 0.16666666666666666)))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.01) tmp = exp(re); elseif (re <= 1.3e-7) tmp = cos(im) * (re + 1.0); elseif (re <= 1.05e+103) tmp = exp(re); else tmp = cos(im) * (1.0 + (re * (1.0 + (re * (re * 0.16666666666666666))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.01], N[Exp[re], $MachinePrecision], If[LessEqual[re, 1.3e-7], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $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[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.01:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 1.3 \cdot 10^{-7}:\\
\;\;\;\;\cos im \cdot \left(re + 1\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(re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if re < -0.0100000000000000002 or 1.29999999999999999e-7 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 93.0%
if -0.0100000000000000002 < re < 1.29999999999999999e-7Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
if 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Final simplification97.7%
(FPCore (re im)
:precision binary64
(if (<= re -0.08)
(exp re)
(if (<= re 1.3e-7)
(* (cos im) (+ re 1.0))
(if (<= re 1.9e+154)
(exp re)
(* (cos im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))))
double code(double re, double im) {
double tmp;
if (re <= -0.08) {
tmp = exp(re);
} else if (re <= 1.3e-7) {
tmp = cos(im) * (re + 1.0);
} else if (re <= 1.9e+154) {
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.08d0)) then
tmp = exp(re)
else if (re <= 1.3d-7) then
tmp = cos(im) * (re + 1.0d0)
else if (re <= 1.9d+154) 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.08) {
tmp = Math.exp(re);
} else if (re <= 1.3e-7) {
tmp = Math.cos(im) * (re + 1.0);
} else if (re <= 1.9e+154) {
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.08: tmp = math.exp(re) elif re <= 1.3e-7: tmp = math.cos(im) * (re + 1.0) elif re <= 1.9e+154: 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.08) tmp = exp(re); elseif (re <= 1.3e-7) tmp = Float64(cos(im) * Float64(re + 1.0)); elseif (re <= 1.9e+154) 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.08) tmp = exp(re); elseif (re <= 1.3e-7) tmp = cos(im) * (re + 1.0); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = cos(im) * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.08], N[Exp[re], $MachinePrecision], If[LessEqual[re, 1.3e-7], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.9e+154], 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.08:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 1.3 \cdot 10^{-7}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;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 < -0.0800000000000000017 or 1.29999999999999999e-7 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 92.5%
if -0.0800000000000000017 < re < 1.29999999999999999e-7Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
if 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.3%
(FPCore (re im) :precision binary64 (if (or (<= re -0.0019) (not (<= re 1.3e-7))) (exp re) (* (cos im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0019) || !(re <= 1.3e-7)) {
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 <= (-0.0019d0)) .or. (.not. (re <= 1.3d-7))) 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 <= -0.0019) || !(re <= 1.3e-7)) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0019) or not (re <= 1.3e-7): tmp = math.exp(re) else: tmp = math.cos(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0019) || !(re <= 1.3e-7)) 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 <= -0.0019) || ~((re <= 1.3e-7))) tmp = exp(re); else tmp = cos(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.0019], N[Not[LessEqual[re, 1.3e-7]], $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 -0.0019 \lor \neg \left(re \leq 1.3 \cdot 10^{-7}\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -0.0019 or 1.29999999999999999e-7 < re Initial program 100.0%
Taylor expanded in im around 0 90.0%
if -0.0019 < re < 1.29999999999999999e-7Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Final simplification94.9%
(FPCore (re im) :precision binary64 (if (<= re 9.2e-8) (cos im) (+ 1.0 (* re (+ 1.0 (* re (+ (* re 0.16666666666666666) 0.5)))))))
double code(double re, double im) {
double tmp;
if (re <= 9.2e-8) {
tmp = cos(im);
} else {
tmp = 1.0 + (re * (1.0 + (re * ((re * 0.16666666666666666) + 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 <= 9.2d-8) then
tmp = cos(im)
else
tmp = 1.0d0 + (re * (1.0d0 + (re * ((re * 0.16666666666666666d0) + 0.5d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 9.2e-8) {
tmp = Math.cos(im);
} else {
tmp = 1.0 + (re * (1.0 + (re * ((re * 0.16666666666666666) + 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 9.2e-8: tmp = math.cos(im) else: tmp = 1.0 + (re * (1.0 + (re * ((re * 0.16666666666666666) + 0.5)))) return tmp
function code(re, im) tmp = 0.0 if (re <= 9.2e-8) tmp = cos(im); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(Float64(re * 0.16666666666666666) + 0.5))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 9.2e-8) tmp = cos(im); else tmp = 1.0 + (re * (1.0 + (re * ((re * 0.16666666666666666) + 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 9.2e-8], N[Cos[im], $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 9.2 \cdot 10^{-8}:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot \left(re \cdot 0.16666666666666666 + 0.5\right)\right)\\
\end{array}
\end{array}
if re < 9.2000000000000003e-8Initial program 100.0%
Taylor expanded in re around 0 66.0%
if 9.2000000000000003e-8 < re Initial program 100.0%
Taylor expanded in im around 0 79.4%
Taylor expanded in re around 0 63.4%
*-commutative75.1%
Simplified63.4%
Final simplification65.4%
(FPCore (re im) :precision binary64 (if (<= re 5.2e+24) (+ re 1.0) (* re (+ 1.0 (* -0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (re <= 5.2e+24) {
tmp = re + 1.0;
} else {
tmp = re * (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 <= 5.2d+24) then
tmp = re + 1.0d0
else
tmp = re * (1.0d0 + ((-0.5d0) * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 5.2e+24) {
tmp = re + 1.0;
} else {
tmp = re * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 5.2e+24: tmp = re + 1.0 else: tmp = re * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= 5.2e+24) tmp = Float64(re + 1.0); else tmp = Float64(re * Float64(1.0 + Float64(-0.5 * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 5.2e+24) tmp = re + 1.0; else tmp = re * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 5.2e+24], N[(re + 1.0), $MachinePrecision], N[(re * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 5.2 \cdot 10^{+24}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 5.1999999999999997e24Initial program 100.0%
Taylor expanded in re around 0 64.5%
distribute-rgt1-in64.5%
Simplified64.5%
Taylor expanded in im around 0 33.9%
+-commutative33.9%
Simplified33.9%
if 5.1999999999999997e24 < re Initial program 100.0%
Taylor expanded in re around 0 6.2%
distribute-rgt1-in6.2%
Simplified6.2%
Taylor expanded in im around 0 21.1%
associate-+r+21.1%
+-commutative21.1%
*-lft-identity21.1%
associate-*r*21.1%
+-commutative21.1%
distribute-rgt-out21.1%
Simplified21.1%
unpow221.1%
Applied egg-rr21.1%
Taylor expanded in re around inf 21.1%
(FPCore (re im) :precision binary64 (+ 1.0 (* re (+ 1.0 (* re (+ (* re 0.16666666666666666) 0.5))))))
double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * ((re * 0.16666666666666666) + 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 * ((re * 0.16666666666666666d0) + 0.5d0))))
end function
public static double code(double re, double im) {
return 1.0 + (re * (1.0 + (re * ((re * 0.16666666666666666) + 0.5))));
}
def code(re, im): return 1.0 + (re * (1.0 + (re * ((re * 0.16666666666666666) + 0.5))))
function code(re, im) return Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(Float64(re * 0.16666666666666666) + 0.5))))) end
function tmp = code(re, im) tmp = 1.0 + (re * (1.0 + (re * ((re * 0.16666666666666666) + 0.5)))); end
code[re_, im_] := N[(1.0 + N[(re * N[(1.0 + N[(re * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + re \cdot \left(1 + re \cdot \left(re \cdot 0.16666666666666666 + 0.5\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 71.0%
Taylor expanded in re around 0 41.4%
*-commutative68.2%
Simplified41.4%
Final simplification41.4%
(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 im around 0 71.0%
Taylor expanded in re around 0 39.1%
*-commutative65.6%
Simplified39.1%
(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 52.0%
distribute-rgt1-in52.0%
Simplified52.0%
Taylor expanded in im around 0 27.7%
+-commutative27.7%
Simplified27.7%
(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 re around 0 51.0%
Taylor expanded in im around 0 27.2%
herbie shell --seed 2024131
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))