
(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 12 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.9999999977) (exp re) (if (<= (exp re) 1.01) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.9999999977) {
tmp = exp(re);
} else if (exp(re) <= 1.01) {
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.9999999977d0) then
tmp = exp(re)
else if (exp(re) <= 1.01d0) 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.9999999977) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 1.01) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.9999999977: tmp = math.exp(re) elif math.exp(re) <= 1.01: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.9999999977) tmp = exp(re); elseif (exp(re) <= 1.01) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 0.9999999977) tmp = exp(re); elseif (exp(re) <= 1.01) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.9999999977], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.01], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.9999999977:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 1.01:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 0.99999999770000003 or 1.01000000000000001 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 85.7%
if 0.99999999770000003 < (exp.f64 re) < 1.01000000000000001Initial program 100.0%
Taylor expanded in re around 0 99.0%
Final simplification92.1%
(FPCore (re im)
:precision binary64
(if (<= re -0.00038)
(exp re)
(if (<= re 0.0008)
(* (cos im) (+ re 1.0))
(if (<= re 1.05e+103)
(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.00038) {
tmp = exp(re);
} else if (re <= 0.0008) {
tmp = cos(im) * (re + 1.0);
} else if (re <= 1.05e+103) {
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.00038d0)) then
tmp = exp(re)
else if (re <= 0.0008d0) then
tmp = cos(im) * (re + 1.0d0)
else if (re <= 1.05d+103) 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.00038) {
tmp = Math.exp(re);
} else if (re <= 0.0008) {
tmp = Math.cos(im) * (re + 1.0);
} else if (re <= 1.05e+103) {
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.00038: tmp = math.exp(re) elif re <= 0.0008: tmp = math.cos(im) * (re + 1.0) elif re <= 1.05e+103: 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.00038) tmp = exp(re); elseif (re <= 0.0008) tmp = Float64(cos(im) * Float64(re + 1.0)); elseif (re <= 1.05e+103) 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.00038) tmp = exp(re); elseif (re <= 0.0008) tmp = cos(im) * (re + 1.0); elseif (re <= 1.05e+103) 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[LessEqual[re, -0.00038], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.0008], 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[(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.00038:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.0008:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;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 < -3.8000000000000002e-4 or 8.00000000000000038e-4 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 90.8%
if -3.8000000000000002e-4 < re < 8.00000000000000038e-4Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
distribute-lft-in100.0%
Simplified100.0%
if 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
*-commutative100.0%
distribute-lft1-in100.0%
distribute-rgt-out100.0%
+-commutative100.0%
cube-mult100.0%
unpow2100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification96.9%
(FPCore (re im)
:precision binary64
(if (<= re -0.00078)
(exp re)
(if (<= re 0.00125)
(* (cos im) (+ re 1.0))
(if (<= re 1.9e+154) (exp re) (* (cos im) (* re (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if (re <= -0.00078) {
tmp = exp(re);
} else if (re <= 0.00125) {
tmp = cos(im) * (re + 1.0);
} else if (re <= 1.9e+154) {
tmp = exp(re);
} else {
tmp = cos(im) * (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 <= (-0.00078d0)) then
tmp = exp(re)
else if (re <= 0.00125d0) then
tmp = cos(im) * (re + 1.0d0)
else if (re <= 1.9d+154) then
tmp = exp(re)
else
tmp = cos(im) * (re * (re * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.00078) {
tmp = Math.exp(re);
} else if (re <= 0.00125) {
tmp = Math.cos(im) * (re + 1.0);
} else if (re <= 1.9e+154) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (re * (re * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.00078: tmp = math.exp(re) elif re <= 0.00125: tmp = math.cos(im) * (re + 1.0) elif re <= 1.9e+154: tmp = math.exp(re) else: tmp = math.cos(im) * (re * (re * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.00078) tmp = exp(re); elseif (re <= 0.00125) tmp = Float64(cos(im) * Float64(re + 1.0)); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = Float64(cos(im) * Float64(re * Float64(re * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.00078) tmp = exp(re); elseif (re <= 0.00125) tmp = cos(im) * (re + 1.0); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = cos(im) * (re * (re * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.00078], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.00125], 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[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.00078:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.00125:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -7.79999999999999986e-4 or 0.00125000000000000003 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 90.8%
if -7.79999999999999986e-4 < re < 0.00125000000000000003Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
distribute-lft-in100.0%
Simplified100.0%
if 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
distribute-lft1-in100.0%
distribute-rgt-out100.0%
+-commutative100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification96.5%
(FPCore (re im) :precision binary64 (if (<= re -4.8e-5) (exp re) (if (<= re 0.000135) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -4.8e-5) {
tmp = exp(re);
} else if (re <= 0.000135) {
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 (re <= (-4.8d-5)) then
tmp = exp(re)
else if (re <= 0.000135d0) 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 (re <= -4.8e-5) {
tmp = Math.exp(re);
} else if (re <= 0.000135) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.8e-5: tmp = math.exp(re) elif re <= 0.000135: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -4.8e-5) tmp = exp(re); elseif (re <= 0.000135) 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 (re <= -4.8e-5) tmp = exp(re); elseif (re <= 0.000135) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.8e-5], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.000135], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.8 \cdot 10^{-5}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.000135:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -4.8000000000000001e-5 or 1.35000000000000002e-4 < re Initial program 100.0%
Taylor expanded in im around 0 85.6%
if -4.8000000000000001e-5 < re < 1.35000000000000002e-4Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
distribute-lft-in100.0%
Simplified100.0%
Final simplification92.6%
(FPCore (re im)
:precision binary64
(if (<= re -405.0)
(* -0.5 (* (+ re 1.0) (* im im)))
(if (<= re 0.012)
(cos im)
(if (<= re 6.5e+146)
(* (+ re 1.0) (+ 1.0 (* im (* im -0.5))))
(* (* re re) 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -405.0) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else if (re <= 0.012) {
tmp = cos(im);
} else if (re <= 6.5e+146) {
tmp = (re + 1.0) * (1.0 + (im * (im * -0.5)));
} 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 <= (-405.0d0)) then
tmp = (-0.5d0) * ((re + 1.0d0) * (im * im))
else if (re <= 0.012d0) then
tmp = cos(im)
else if (re <= 6.5d+146) then
tmp = (re + 1.0d0) * (1.0d0 + (im * (im * (-0.5d0))))
else
tmp = (re * re) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -405.0) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else if (re <= 0.012) {
tmp = Math.cos(im);
} else if (re <= 6.5e+146) {
tmp = (re + 1.0) * (1.0 + (im * (im * -0.5)));
} else {
tmp = (re * re) * 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -405.0: tmp = -0.5 * ((re + 1.0) * (im * im)) elif re <= 0.012: tmp = math.cos(im) elif re <= 6.5e+146: tmp = (re + 1.0) * (1.0 + (im * (im * -0.5))) else: tmp = (re * re) * 0.5 return tmp
function code(re, im) tmp = 0.0 if (re <= -405.0) tmp = Float64(-0.5 * Float64(Float64(re + 1.0) * Float64(im * im))); elseif (re <= 0.012) tmp = cos(im); elseif (re <= 6.5e+146) tmp = Float64(Float64(re + 1.0) * Float64(1.0 + Float64(im * Float64(im * -0.5)))); else tmp = Float64(Float64(re * re) * 0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -405.0) tmp = -0.5 * ((re + 1.0) * (im * im)); elseif (re <= 0.012) tmp = cos(im); elseif (re <= 6.5e+146) tmp = (re + 1.0) * (1.0 + (im * (im * -0.5))); else tmp = (re * re) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -405.0], N[(-0.5 * N[(N[(re + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.012], N[Cos[im], $MachinePrecision], If[LessEqual[re, 6.5e+146], N[(N[(re + 1.0), $MachinePrecision] * N[(1.0 + N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -405:\\
\;\;\;\;-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{elif}\;re \leq 0.012:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 6.5 \cdot 10^{+146}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(1 + im \cdot \left(im \cdot -0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.5\\
\end{array}
\end{array}
if re < -405Initial 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%
associate-+r+1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
+-commutative1.9%
Simplified1.9%
*-un-lft-identity1.9%
associate-*r*1.9%
distribute-rgt-out1.9%
+-commutative1.9%
associate-*r*1.9%
Applied egg-rr1.9%
Taylor expanded in im around inf 21.3%
unpow221.3%
+-commutative21.3%
Simplified21.3%
if -405 < re < 0.012Initial program 100.0%
Taylor expanded in re around 0 98.0%
if 0.012 < re < 6.4999999999999997e146Initial program 100.0%
Taylor expanded in re around 0 4.9%
*-rgt-identity4.9%
distribute-lft-in4.9%
Simplified4.9%
Taylor expanded in im around 0 18.8%
associate-+r+18.8%
+-commutative18.8%
*-commutative18.8%
unpow218.8%
+-commutative18.8%
Simplified18.8%
*-un-lft-identity18.8%
associate-*r*18.8%
distribute-rgt-out18.8%
+-commutative18.8%
associate-*r*18.8%
Applied egg-rr18.8%
if 6.4999999999999997e146 < re Initial program 100.0%
Taylor expanded in re around 0 95.0%
*-commutative95.0%
associate-*r*95.0%
*-commutative95.0%
distribute-lft1-in95.0%
distribute-rgt-out95.0%
+-commutative95.0%
*-commutative95.0%
unpow295.0%
associate-*l*95.0%
Simplified95.0%
Taylor expanded in re around inf 95.0%
*-commutative95.0%
unpow295.0%
associate-*r*95.0%
associate-*r*95.0%
Simplified95.0%
Taylor expanded in im around 0 67.2%
unpow267.2%
Simplified67.2%
Final simplification64.9%
(FPCore (re im)
:precision binary64
(if (<= re -15.0)
(* -0.5 (* (+ re 1.0) (* im im)))
(if (<= re 6.8e-18)
(+ re 1.0)
(if (<= re 6.5e+146)
(* (+ re 1.0) (+ 1.0 (* im (* im -0.5))))
(* (* re re) 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -15.0) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else if (re <= 6.8e-18) {
tmp = re + 1.0;
} else if (re <= 6.5e+146) {
tmp = (re + 1.0) * (1.0 + (im * (im * -0.5)));
} 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 <= (-15.0d0)) then
tmp = (-0.5d0) * ((re + 1.0d0) * (im * im))
else if (re <= 6.8d-18) then
tmp = re + 1.0d0
else if (re <= 6.5d+146) then
tmp = (re + 1.0d0) * (1.0d0 + (im * (im * (-0.5d0))))
else
tmp = (re * re) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -15.0) {
tmp = -0.5 * ((re + 1.0) * (im * im));
} else if (re <= 6.8e-18) {
tmp = re + 1.0;
} else if (re <= 6.5e+146) {
tmp = (re + 1.0) * (1.0 + (im * (im * -0.5)));
} else {
tmp = (re * re) * 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -15.0: tmp = -0.5 * ((re + 1.0) * (im * im)) elif re <= 6.8e-18: tmp = re + 1.0 elif re <= 6.5e+146: tmp = (re + 1.0) * (1.0 + (im * (im * -0.5))) else: tmp = (re * re) * 0.5 return tmp
function code(re, im) tmp = 0.0 if (re <= -15.0) tmp = Float64(-0.5 * Float64(Float64(re + 1.0) * Float64(im * im))); elseif (re <= 6.8e-18) tmp = Float64(re + 1.0); elseif (re <= 6.5e+146) tmp = Float64(Float64(re + 1.0) * Float64(1.0 + Float64(im * Float64(im * -0.5)))); else tmp = Float64(Float64(re * re) * 0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -15.0) tmp = -0.5 * ((re + 1.0) * (im * im)); elseif (re <= 6.8e-18) tmp = re + 1.0; elseif (re <= 6.5e+146) tmp = (re + 1.0) * (1.0 + (im * (im * -0.5))); else tmp = (re * re) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -15.0], N[(-0.5 * N[(N[(re + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 6.8e-18], N[(re + 1.0), $MachinePrecision], If[LessEqual[re, 6.5e+146], N[(N[(re + 1.0), $MachinePrecision] * N[(1.0 + N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -15:\\
\;\;\;\;-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{elif}\;re \leq 6.8 \cdot 10^{-18}:\\
\;\;\;\;re + 1\\
\mathbf{elif}\;re \leq 6.5 \cdot 10^{+146}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(1 + im \cdot \left(im \cdot -0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.5\\
\end{array}
\end{array}
if re < -15Initial 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%
associate-+r+1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
+-commutative1.9%
Simplified1.9%
*-un-lft-identity1.9%
associate-*r*1.9%
distribute-rgt-out1.9%
+-commutative1.9%
associate-*r*1.9%
Applied egg-rr1.9%
Taylor expanded in im around inf 21.0%
unpow221.0%
+-commutative21.0%
Simplified21.0%
if -15 < re < 6.80000000000000002e-18Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 58.7%
if 6.80000000000000002e-18 < re < 6.4999999999999997e146Initial program 100.0%
Taylor expanded in re around 0 12.8%
*-rgt-identity12.8%
distribute-lft-in12.8%
Simplified12.8%
Taylor expanded in im around 0 22.9%
associate-+r+22.9%
+-commutative22.9%
*-commutative22.9%
unpow222.9%
+-commutative22.9%
Simplified22.9%
*-un-lft-identity22.9%
associate-*r*22.9%
distribute-rgt-out22.9%
+-commutative22.9%
associate-*r*22.9%
Applied egg-rr22.9%
if 6.4999999999999997e146 < re Initial program 100.0%
Taylor expanded in re around 0 95.0%
*-commutative95.0%
associate-*r*95.0%
*-commutative95.0%
distribute-lft1-in95.0%
distribute-rgt-out95.0%
+-commutative95.0%
*-commutative95.0%
unpow295.0%
associate-*l*95.0%
Simplified95.0%
Taylor expanded in re around inf 95.0%
*-commutative95.0%
unpow295.0%
associate-*r*95.0%
associate-*r*95.0%
Simplified95.0%
Taylor expanded in im around 0 67.2%
unpow267.2%
Simplified67.2%
Final simplification45.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.5 (* im (+ im (* re im))))))
(if (<= re -9.5)
t_0
(if (<= re 27500.0)
(+ re 1.0)
(if (<= re 2.4e+146) t_0 (* (* re re) 0.5))))))
double code(double re, double im) {
double t_0 = -0.5 * (im * (im + (re * im)));
double tmp;
if (re <= -9.5) {
tmp = t_0;
} else if (re <= 27500.0) {
tmp = re + 1.0;
} else if (re <= 2.4e+146) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * (im * (im + (re * im)))
if (re <= (-9.5d0)) then
tmp = t_0
else if (re <= 27500.0d0) then
tmp = re + 1.0d0
else if (re <= 2.4d+146) then
tmp = t_0
else
tmp = (re * re) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.5 * (im * (im + (re * im)));
double tmp;
if (re <= -9.5) {
tmp = t_0;
} else if (re <= 27500.0) {
tmp = re + 1.0;
} else if (re <= 2.4e+146) {
tmp = t_0;
} else {
tmp = (re * re) * 0.5;
}
return tmp;
}
def code(re, im): t_0 = -0.5 * (im * (im + (re * im))) tmp = 0 if re <= -9.5: tmp = t_0 elif re <= 27500.0: tmp = re + 1.0 elif re <= 2.4e+146: tmp = t_0 else: tmp = (re * re) * 0.5 return tmp
function code(re, im) t_0 = Float64(-0.5 * Float64(im * Float64(im + Float64(re * im)))) tmp = 0.0 if (re <= -9.5) tmp = t_0; elseif (re <= 27500.0) tmp = Float64(re + 1.0); elseif (re <= 2.4e+146) tmp = t_0; else tmp = Float64(Float64(re * re) * 0.5); end return tmp end
function tmp_2 = code(re, im) t_0 = -0.5 * (im * (im + (re * im))); tmp = 0.0; if (re <= -9.5) tmp = t_0; elseif (re <= 27500.0) tmp = re + 1.0; elseif (re <= 2.4e+146) tmp = t_0; else tmp = (re * re) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.5 * N[(im * N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -9.5], t$95$0, If[LessEqual[re, 27500.0], N[(re + 1.0), $MachinePrecision], If[LessEqual[re, 2.4e+146], t$95$0, N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(im \cdot \left(im + re \cdot im\right)\right)\\
\mathbf{if}\;re \leq -9.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 27500:\\
\;\;\;\;re + 1\\
\mathbf{elif}\;re \leq 2.4 \cdot 10^{+146}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.5\\
\end{array}
\end{array}
if re < -9.5 or 27500 < re < 2.4000000000000002e146Initial program 100.0%
Taylor expanded in re around 0 2.8%
*-rgt-identity2.8%
distribute-lft-in2.8%
Simplified2.8%
Taylor expanded in im around 0 7.4%
associate-+r+7.4%
+-commutative7.4%
*-commutative7.4%
unpow27.4%
+-commutative7.4%
Simplified7.4%
*-un-lft-identity7.4%
associate-*r*7.4%
distribute-rgt-out7.4%
+-commutative7.4%
associate-*r*7.4%
Applied egg-rr7.4%
Taylor expanded in im around inf 19.6%
unpow219.6%
+-commutative19.6%
distribute-lft1-in19.3%
unpow219.3%
+-commutative19.3%
unpow219.3%
associate-*l*14.5%
distribute-rgt-out14.8%
Simplified14.8%
if -9.5 < re < 27500Initial program 100.0%
Taylor expanded in re around 0 99.5%
*-rgt-identity99.5%
distribute-lft-in99.5%
Simplified99.5%
Taylor expanded in im around 0 58.7%
if 2.4000000000000002e146 < re Initial program 100.0%
Taylor expanded in re around 0 95.0%
*-commutative95.0%
associate-*r*95.0%
*-commutative95.0%
distribute-lft1-in95.0%
distribute-rgt-out95.0%
+-commutative95.0%
*-commutative95.0%
unpow295.0%
associate-*l*95.0%
Simplified95.0%
Taylor expanded in re around inf 95.0%
*-commutative95.0%
unpow295.0%
associate-*r*95.0%
associate-*r*95.0%
Simplified95.0%
Taylor expanded in im around 0 67.2%
unpow267.2%
Simplified67.2%
Final simplification43.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.5 (* (+ re 1.0) (* im im)))))
(if (<= re -10.5)
t_0
(if (<= re 700.0) (+ re 1.0) (if (<= re 8e+146) t_0 (* (* re re) 0.5))))))
double code(double re, double im) {
double t_0 = -0.5 * ((re + 1.0) * (im * im));
double tmp;
if (re <= -10.5) {
tmp = t_0;
} else if (re <= 700.0) {
tmp = re + 1.0;
} else if (re <= 8e+146) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (-0.5d0) * ((re + 1.0d0) * (im * im))
if (re <= (-10.5d0)) then
tmp = t_0
else if (re <= 700.0d0) then
tmp = re + 1.0d0
else if (re <= 8d+146) then
tmp = t_0
else
tmp = (re * re) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.5 * ((re + 1.0) * (im * im));
double tmp;
if (re <= -10.5) {
tmp = t_0;
} else if (re <= 700.0) {
tmp = re + 1.0;
} else if (re <= 8e+146) {
tmp = t_0;
} else {
tmp = (re * re) * 0.5;
}
return tmp;
}
def code(re, im): t_0 = -0.5 * ((re + 1.0) * (im * im)) tmp = 0 if re <= -10.5: tmp = t_0 elif re <= 700.0: tmp = re + 1.0 elif re <= 8e+146: tmp = t_0 else: tmp = (re * re) * 0.5 return tmp
function code(re, im) t_0 = Float64(-0.5 * Float64(Float64(re + 1.0) * Float64(im * im))) tmp = 0.0 if (re <= -10.5) tmp = t_0; elseif (re <= 700.0) tmp = Float64(re + 1.0); elseif (re <= 8e+146) tmp = t_0; else tmp = Float64(Float64(re * re) * 0.5); end return tmp end
function tmp_2 = code(re, im) t_0 = -0.5 * ((re + 1.0) * (im * im)); tmp = 0.0; if (re <= -10.5) tmp = t_0; elseif (re <= 700.0) tmp = re + 1.0; elseif (re <= 8e+146) tmp = t_0; else tmp = (re * re) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.5 * N[(N[(re + 1.0), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -10.5], t$95$0, If[LessEqual[re, 700.0], N[(re + 1.0), $MachinePrecision], If[LessEqual[re, 8e+146], t$95$0, N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\\
\mathbf{if}\;re \leq -10.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 700:\\
\;\;\;\;re + 1\\
\mathbf{elif}\;re \leq 8 \cdot 10^{+146}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.5\\
\end{array}
\end{array}
if re < -10.5 or 700 < re < 7.99999999999999947e146Initial program 100.0%
Taylor expanded in re around 0 2.8%
*-rgt-identity2.8%
distribute-lft-in2.8%
Simplified2.8%
Taylor expanded in im around 0 7.4%
associate-+r+7.4%
+-commutative7.4%
*-commutative7.4%
unpow27.4%
+-commutative7.4%
Simplified7.4%
*-un-lft-identity7.4%
associate-*r*7.4%
distribute-rgt-out7.4%
+-commutative7.4%
associate-*r*7.4%
Applied egg-rr7.4%
Taylor expanded in im around inf 19.6%
unpow219.6%
+-commutative19.6%
Simplified19.6%
if -10.5 < re < 700Initial program 100.0%
Taylor expanded in re around 0 99.5%
*-rgt-identity99.5%
distribute-lft-in99.5%
Simplified99.5%
Taylor expanded in im around 0 58.7%
if 7.99999999999999947e146 < re Initial program 100.0%
Taylor expanded in re around 0 95.0%
*-commutative95.0%
associate-*r*95.0%
*-commutative95.0%
distribute-lft1-in95.0%
distribute-rgt-out95.0%
+-commutative95.0%
*-commutative95.0%
unpow295.0%
associate-*l*95.0%
Simplified95.0%
Taylor expanded in re around inf 95.0%
*-commutative95.0%
unpow295.0%
associate-*r*95.0%
associate-*r*95.0%
Simplified95.0%
Taylor expanded in im around 0 67.2%
unpow267.2%
Simplified67.2%
Final simplification45.4%
(FPCore (re im) :precision binary64 (if (<= re 1.1e+15) (+ re 1.0) (* (* re re) 0.5)))
double code(double re, double im) {
double tmp;
if (re <= 1.1e+15) {
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 <= 1.1d+15) 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 <= 1.1e+15) {
tmp = re + 1.0;
} else {
tmp = (re * re) * 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.1e+15: tmp = re + 1.0 else: tmp = (re * re) * 0.5 return tmp
function code(re, im) tmp = 0.0 if (re <= 1.1e+15) 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 <= 1.1e+15) tmp = re + 1.0; else tmp = (re * re) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.1e+15], N[(re + 1.0), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.1 \cdot 10^{+15}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.5\\
\end{array}
\end{array}
if re < 1.1e15Initial program 100.0%
Taylor expanded in re around 0 65.9%
*-rgt-identity65.9%
distribute-lft-in65.9%
Simplified65.9%
Taylor expanded in im around 0 39.2%
if 1.1e15 < re Initial program 100.0%
Taylor expanded in re around 0 54.9%
*-commutative54.9%
associate-*r*54.9%
*-commutative54.9%
distribute-lft1-in54.9%
distribute-rgt-out54.9%
+-commutative54.9%
*-commutative54.9%
unpow254.9%
associate-*l*54.9%
Simplified54.9%
Taylor expanded in re around inf 54.9%
*-commutative54.9%
unpow254.9%
associate-*r*54.9%
associate-*r*54.9%
Simplified54.9%
Taylor expanded in im around 0 39.1%
unpow239.1%
Simplified39.1%
Final simplification39.2%
(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.6%
*-rgt-identity50.6%
distribute-lft-in50.6%
Simplified50.6%
Taylor expanded in im around 0 30.3%
Final simplification30.3%
(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 50.6%
*-rgt-identity50.6%
distribute-lft-in50.6%
Simplified50.6%
Taylor expanded in im around 0 33.2%
associate-+r+33.2%
+-commutative33.2%
*-commutative33.2%
unpow233.2%
+-commutative33.2%
Simplified33.2%
Taylor expanded in re around inf 33.3%
unpow233.3%
associate-*r*33.3%
*-commutative33.3%
associate-*r*33.3%
associate-*l*33.3%
*-commutative33.3%
*-commutative33.3%
Simplified33.3%
Taylor expanded in re around 0 29.8%
Final simplification29.8%
herbie shell --seed 2023192
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))