
(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%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.0) (exp re) (if (<= (exp re) 2.0) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = exp(re);
} else if (exp(re) <= 2.0) {
tmp = cos(im) * (re + 1.0);
} else {
tmp = exp(re);
}
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.0d0) then
tmp = exp(re)
else if (exp(re) <= 2.0d0) then
tmp = cos(im) * (re + 1.0d0)
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 0.0) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 2.0) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.0: tmp = math.exp(re) elif math.exp(re) <= 2.0: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = Float64(cos(im) * Float64(re + 1.0)); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 0.0) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 92.9%
if 0.0 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 98.4%
*-rgt-identity98.4%
distribute-lft-in98.4%
Simplified98.4%
Final simplification95.4%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.0) (exp re) (if (<= (exp re) 2.0) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = exp(re);
} else if (exp(re) <= 2.0) {
tmp = cos(im);
} else {
tmp = exp(re);
}
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.0d0) then
tmp = exp(re)
else if (exp(re) <= 2.0d0) then
tmp = cos(im)
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 0.0) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 2.0) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.0: tmp = math.exp(re) elif math.exp(re) <= 2.0: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 0.0) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 92.9%
if 0.0 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 97.6%
Final simplification95.1%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.075) (and (not (<= re 2.9)) (<= re 6.5e+102)))
(exp re)
(*
(cos im)
(+ (+ re 1.0) (* (* re re) (+ 0.5 (* re 0.16666666666666666)))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.075) || (!(re <= 2.9) && (re <= 6.5e+102))) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + ((re * 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.075d0)) .or. (.not. (re <= 2.9d0)) .and. (re <= 6.5d+102)) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + ((re * 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.075) || (!(re <= 2.9) && (re <= 6.5e+102))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.075) or (not (re <= 2.9) and (re <= 6.5e+102)): tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666)))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.075) || (!(re <= 2.9) && (re <= 6.5e+102))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * Float64(0.5 + Float64(re * 0.16666666666666666))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.075) || (~((re <= 2.9)) && (re <= 6.5e+102))) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.075], And[N[Not[LessEqual[re, 2.9]], $MachinePrecision], LessEqual[re, 6.5e+102]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.075 \lor \neg \left(re \leq 2.9\right) \land re \leq 6.5 \cdot 10^{+102}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if re < -0.0749999999999999972 or 2.89999999999999991 < re < 6.5000000000000004e102Initial program 100.0%
Taylor expanded in im around 0 95.6%
if -0.0749999999999999972 < re < 2.89999999999999991 or 6.5000000000000004e102 < re Initial program 100.0%
Taylor expanded in re around 0 98.8%
associate-+r+98.8%
*-commutative98.8%
associate-*r*98.8%
*-commutative98.8%
associate-*r*98.8%
distribute-rgt-out98.8%
*-commutative98.8%
*-commutative98.8%
distribute-lft1-in98.8%
distribute-rgt-out98.8%
+-commutative98.8%
cube-mult98.8%
unpow298.8%
associate-*r*98.3%
Simplified98.3%
Final simplification97.4%
(FPCore (re im) :precision binary64 (if (<= re -0.075) (exp re) (if (<= re 0.055) (* (cos im) (+ (+ re 1.0) (* re (* re 0.5)))) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -0.075) {
tmp = exp(re);
} else if (re <= 0.055) {
tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5)));
} else {
tmp = exp(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.075d0)) then
tmp = exp(re)
else if (re <= 0.055d0) then
tmp = cos(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.075) {
tmp = Math.exp(re);
} else if (re <= 0.055) {
tmp = Math.cos(im) * ((re + 1.0) + (re * (re * 0.5)));
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.075: tmp = math.exp(re) elif re <= 0.055: tmp = math.cos(im) * ((re + 1.0) + (re * (re * 0.5))) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.075) tmp = exp(re); elseif (re <= 0.055) tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.075) tmp = exp(re); elseif (re <= 0.055) tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5))); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.075], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.055], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.075:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.055:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -0.0749999999999999972 or 0.0550000000000000003 < re Initial program 100.0%
Taylor expanded in im around 0 92.9%
if -0.0749999999999999972 < re < 0.0550000000000000003Initial program 100.0%
Taylor expanded in re around 0 98.7%
*-commutative98.7%
associate-*r*98.7%
*-commutative98.7%
distribute-lft1-in98.7%
distribute-rgt-out98.7%
+-commutative98.7%
*-commutative98.7%
unpow298.7%
associate-*l*98.7%
Simplified98.7%
Final simplification95.6%
(FPCore (re im) :precision binary64 (if (<= re -550.0) (* im (* im -0.5)) (if (<= re 1.35) (cos im) (+ 1.0 (+ re (* re (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if (re <= -550.0) {
tmp = im * (im * -0.5);
} else if (re <= 1.35) {
tmp = cos(im);
} else {
tmp = 1.0 + (re + (re * (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 <= (-550.0d0)) then
tmp = im * (im * (-0.5d0))
else if (re <= 1.35d0) then
tmp = cos(im)
else
tmp = 1.0d0 + (re + (re * (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -550.0) {
tmp = im * (im * -0.5);
} else if (re <= 1.35) {
tmp = Math.cos(im);
} else {
tmp = 1.0 + (re + (re * (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -550.0: tmp = im * (im * -0.5) elif re <= 1.35: tmp = math.cos(im) else: tmp = 1.0 + (re + (re * (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if (re <= -550.0) tmp = Float64(im * Float64(im * -0.5)); elseif (re <= 1.35) tmp = cos(im); else tmp = Float64(1.0 + Float64(re + Float64(re * Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -550.0) tmp = im * (im * -0.5); elseif (re <= 1.35) tmp = cos(im); else tmp = 1.0 + (re + (re * (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -550.0], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35], N[Cos[im], $MachinePrecision], N[(1.0 + N[(re + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -550:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\
\mathbf{elif}\;re \leq 1.35:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -550Initial program 100.0%
Taylor expanded in re around 0 2.3%
*-rgt-identity2.3%
distribute-lft-in2.3%
Simplified2.3%
Taylor expanded in im around 0 1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
Simplified1.9%
Taylor expanded in re around 0 2.5%
unpow22.5%
Simplified2.5%
Taylor expanded in im around inf 23.5%
unpow223.5%
*-commutative23.5%
associate-*r*23.5%
Simplified23.5%
if -550 < re < 1.3500000000000001Initial program 100.0%
Taylor expanded in re around 0 97.6%
if 1.3500000000000001 < re Initial program 100.0%
Taylor expanded in re around 0 48.1%
*-commutative48.1%
associate-*r*48.1%
*-commutative48.1%
distribute-lft1-in48.1%
distribute-rgt-out48.1%
+-commutative48.1%
*-commutative48.1%
unpow248.1%
associate-*l*48.1%
Simplified48.1%
Taylor expanded in im around 0 41.9%
fma-def41.9%
unpow241.9%
+-commutative41.9%
Simplified41.9%
fma-udef41.9%
associate-+r+41.9%
*-commutative41.9%
associate-*l*41.9%
Applied egg-rr41.9%
Final simplification62.5%
(FPCore (re im) :precision binary64 (if (<= re -510.0) (* im (* im -0.5)) (+ 1.0 (+ re (* re (* re 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -510.0) {
tmp = im * (im * -0.5);
} else {
tmp = 1.0 + (re + (re * (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 <= (-510.0d0)) then
tmp = im * (im * (-0.5d0))
else
tmp = 1.0d0 + (re + (re * (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -510.0) {
tmp = im * (im * -0.5);
} else {
tmp = 1.0 + (re + (re * (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -510.0: tmp = im * (im * -0.5) else: tmp = 1.0 + (re + (re * (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if (re <= -510.0) tmp = Float64(im * Float64(im * -0.5)); else tmp = Float64(1.0 + Float64(re + Float64(re * Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -510.0) tmp = im * (im * -0.5); else tmp = 1.0 + (re + (re * (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -510.0], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -510:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -510Initial program 100.0%
Taylor expanded in re around 0 2.3%
*-rgt-identity2.3%
distribute-lft-in2.3%
Simplified2.3%
Taylor expanded in im around 0 1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
Simplified1.9%
Taylor expanded in re around 0 2.5%
unpow22.5%
Simplified2.5%
Taylor expanded in im around inf 23.5%
unpow223.5%
*-commutative23.5%
associate-*r*23.5%
Simplified23.5%
if -510 < re Initial program 100.0%
Taylor expanded in re around 0 80.4%
*-commutative80.4%
associate-*r*80.4%
*-commutative80.4%
distribute-lft1-in80.4%
distribute-rgt-out80.4%
+-commutative80.4%
*-commutative80.4%
unpow280.4%
associate-*l*80.4%
Simplified80.4%
Taylor expanded in im around 0 50.7%
fma-def50.7%
unpow250.7%
+-commutative50.7%
Simplified50.7%
fma-udef50.7%
associate-+r+50.7%
*-commutative50.7%
associate-*l*50.7%
Applied egg-rr50.7%
Final simplification43.2%
(FPCore (re im) :precision binary64 (if (<= re -145.0) (* im (* im -0.5)) (if (<= re 2.4) (+ re 1.0) (* (* re re) 0.5))))
double code(double re, double im) {
double tmp;
if (re <= -145.0) {
tmp = im * (im * -0.5);
} else if (re <= 2.4) {
tmp = re + 1.0;
} else {
tmp = (re * 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 <= (-145.0d0)) then
tmp = im * (im * (-0.5d0))
else if (re <= 2.4d0) then
tmp = re + 1.0d0
else
tmp = (re * re) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -145.0) {
tmp = im * (im * -0.5);
} else if (re <= 2.4) {
tmp = re + 1.0;
} else {
tmp = (re * re) * 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -145.0: tmp = im * (im * -0.5) elif re <= 2.4: tmp = re + 1.0 else: tmp = (re * re) * 0.5 return tmp
function code(re, im) tmp = 0.0 if (re <= -145.0) tmp = Float64(im * Float64(im * -0.5)); elseif (re <= 2.4) tmp = Float64(re + 1.0); else tmp = Float64(Float64(re * re) * 0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -145.0) tmp = im * (im * -0.5); elseif (re <= 2.4) tmp = re + 1.0; else tmp = (re * re) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -145.0], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 2.4], N[(re + 1.0), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -145:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\
\mathbf{elif}\;re \leq 2.4:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.5\\
\end{array}
\end{array}
if re < -145Initial program 100.0%
Taylor expanded in re around 0 2.3%
*-rgt-identity2.3%
distribute-lft-in2.3%
Simplified2.3%
Taylor expanded in im around 0 1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
Simplified1.9%
Taylor expanded in re around 0 2.5%
unpow22.5%
Simplified2.5%
Taylor expanded in im around inf 23.5%
unpow223.5%
*-commutative23.5%
associate-*r*23.5%
Simplified23.5%
if -145 < re < 2.39999999999999991Initial program 100.0%
Taylor expanded in re around 0 98.4%
*-rgt-identity98.4%
distribute-lft-in98.4%
Simplified98.4%
Taylor expanded in im around 0 55.7%
+-commutative55.7%
Simplified55.7%
if 2.39999999999999991 < re Initial program 100.0%
Taylor expanded in re around 0 48.1%
*-commutative48.1%
associate-*r*48.1%
*-commutative48.1%
distribute-lft1-in48.1%
distribute-rgt-out48.1%
+-commutative48.1%
*-commutative48.1%
unpow248.1%
associate-*l*48.1%
Simplified48.1%
Taylor expanded in re around inf 48.1%
*-commutative48.1%
unpow248.1%
*-commutative48.1%
associate-*r*48.1%
Simplified48.1%
Taylor expanded in re around 0 48.1%
unpow248.1%
*-commutative48.1%
associate-*r*48.1%
*-commutative48.1%
associate-*r*48.1%
associate-*l*48.1%
*-commutative48.1%
associate-*l*48.1%
Simplified48.1%
Taylor expanded in im around 0 41.8%
*-commutative41.8%
unpow241.8%
Simplified41.8%
Final simplification43.2%
(FPCore (re im) :precision binary64 (if (<= re -72.0) (* im (* im -0.5)) (+ re 1.0)))
double code(double re, double im) {
double tmp;
if (re <= -72.0) {
tmp = im * (im * -0.5);
} else {
tmp = 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 <= (-72.0d0)) then
tmp = im * (im * (-0.5d0))
else
tmp = re + 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -72.0) {
tmp = im * (im * -0.5);
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -72.0: tmp = im * (im * -0.5) else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if (re <= -72.0) tmp = Float64(im * Float64(im * -0.5)); else tmp = Float64(re + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -72.0) tmp = im * (im * -0.5); else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -72.0], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -72:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if re < -72Initial program 100.0%
Taylor expanded in re around 0 2.3%
*-rgt-identity2.3%
distribute-lft-in2.3%
Simplified2.3%
Taylor expanded in im around 0 1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
Simplified1.9%
Taylor expanded in re around 0 2.5%
unpow22.5%
Simplified2.5%
Taylor expanded in im around inf 23.5%
unpow223.5%
*-commutative23.5%
associate-*r*23.5%
Simplified23.5%
if -72 < re Initial program 100.0%
Taylor expanded in re around 0 64.8%
*-rgt-identity64.8%
distribute-lft-in64.8%
Simplified64.8%
Taylor expanded in im around 0 37.4%
+-commutative37.4%
Simplified37.4%
Final simplification33.5%
(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 47.5%
*-rgt-identity47.5%
distribute-lft-in47.5%
Simplified47.5%
Taylor expanded in im around 0 27.6%
+-commutative27.6%
Simplified27.6%
Final simplification27.6%
(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 47.5%
*-rgt-identity47.5%
distribute-lft-in47.5%
Simplified47.5%
Taylor expanded in im around 0 27.9%
+-commutative27.9%
*-commutative27.9%
unpow227.9%
Simplified27.9%
Taylor expanded in re around 0 27.3%
unpow227.3%
Simplified27.3%
Taylor expanded in im around 0 27.4%
Final simplification27.4%
herbie shell --seed 2023187
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))