
(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 14 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) 1.0) (exp re) (if (<= (exp re) 1.0000001) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 1.0) {
tmp = exp(re);
} else if (exp(re) <= 1.0000001) {
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) <= 1.0d0) then
tmp = exp(re)
else if (exp(re) <= 1.0000001d0) 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) <= 1.0) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 1.0000001) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 1.0: tmp = math.exp(re) elif math.exp(re) <= 1.0000001: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 1.0) tmp = exp(re); elseif (exp(re) <= 1.0000001) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 1.0) tmp = exp(re); elseif (exp(re) <= 1.0000001) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.0000001], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 1.0000001:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 1.00000010000000006 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 72.1%
if 1 < (exp.f64 re) < 1.00000010000000006Initial program 100.0%
Taylor expanded in re around 0 86.7%
Final simplification72.3%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.0275) (and (not (<= re 0.031)) (<= re 1.05e+103)))
(exp re)
(*
(cos im)
(+ (* (* re re) (+ 0.5 (* re 0.16666666666666666))) (+ re 1.0)))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0275) || (!(re <= 0.031) && (re <= 1.05e+103))) {
tmp = exp(re);
} else {
tmp = cos(im) * (((re * re) * (0.5 + (re * 0.16666666666666666))) + (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.0275d0)) .or. (.not. (re <= 0.031d0)) .and. (re <= 1.05d+103)) then
tmp = exp(re)
else
tmp = cos(im) * (((re * re) * (0.5d0 + (re * 0.16666666666666666d0))) + (re + 1.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.0275) || (!(re <= 0.031) && (re <= 1.05e+103))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (((re * re) * (0.5 + (re * 0.16666666666666666))) + (re + 1.0));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0275) or (not (re <= 0.031) and (re <= 1.05e+103)): tmp = math.exp(re) else: tmp = math.cos(im) * (((re * re) * (0.5 + (re * 0.16666666666666666))) + (re + 1.0)) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0275) || (!(re <= 0.031) && (re <= 1.05e+103))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(Float64(re * re) * Float64(0.5 + Float64(re * 0.16666666666666666))) + Float64(re + 1.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.0275) || (~((re <= 0.031)) && (re <= 1.05e+103))) tmp = exp(re); else tmp = cos(im) * (((re * re) * (0.5 + (re * 0.16666666666666666))) + (re + 1.0)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.0275], And[N[Not[LessEqual[re, 0.031]], $MachinePrecision], LessEqual[re, 1.05e+103]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(N[(re * re), $MachinePrecision] * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0275 \lor \neg \left(re \leq 0.031\right) \land re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re \cdot re\right) \cdot \left(0.5 + re \cdot 0.16666666666666666\right) + \left(re + 1\right)\right)\\
\end{array}
\end{array}
if re < -0.0275000000000000001 or 0.031 < re < 1.0500000000000001e103Initial program 99.9%
Taylor expanded in im around 0 90.0%
if -0.0275000000000000001 < re < 0.031 or 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.7%
associate-+r+99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
distribute-rgt-out99.7%
*-commutative99.7%
*-commutative99.7%
distribute-lft1-in99.7%
distribute-rgt-out99.7%
+-commutative99.7%
cube-mult99.7%
unpow299.7%
associate-*r*99.7%
Simplified99.7%
Final simplification96.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))))
(if (<= re -0.0031)
(exp re)
(if (<= re 0.075)
(* (cos im) (+ t_0 (+ re 1.0)))
(if (<= re 1.9e+154) (exp re) (* (cos im) t_0))))))
double code(double re, double im) {
double t_0 = re * (re * 0.5);
double tmp;
if (re <= -0.0031) {
tmp = exp(re);
} else if (re <= 0.075) {
tmp = cos(im) * (t_0 + (re + 1.0));
} else if (re <= 1.9e+154) {
tmp = exp(re);
} else {
tmp = cos(im) * t_0;
}
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 = re * (re * 0.5d0)
if (re <= (-0.0031d0)) then
tmp = exp(re)
else if (re <= 0.075d0) then
tmp = cos(im) * (t_0 + (re + 1.0d0))
else if (re <= 1.9d+154) then
tmp = exp(re)
else
tmp = cos(im) * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (re * 0.5);
double tmp;
if (re <= -0.0031) {
tmp = Math.exp(re);
} else if (re <= 0.075) {
tmp = Math.cos(im) * (t_0 + (re + 1.0));
} else if (re <= 1.9e+154) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * t_0;
}
return tmp;
}
def code(re, im): t_0 = re * (re * 0.5) tmp = 0 if re <= -0.0031: tmp = math.exp(re) elif re <= 0.075: tmp = math.cos(im) * (t_0 + (re + 1.0)) elif re <= 1.9e+154: tmp = math.exp(re) else: tmp = math.cos(im) * t_0 return tmp
function code(re, im) t_0 = Float64(re * Float64(re * 0.5)) tmp = 0.0 if (re <= -0.0031) tmp = exp(re); elseif (re <= 0.075) tmp = Float64(cos(im) * Float64(t_0 + Float64(re + 1.0))); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = Float64(cos(im) * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = re * (re * 0.5); tmp = 0.0; if (re <= -0.0031) tmp = exp(re); elseif (re <= 0.075) tmp = cos(im) * (t_0 + (re + 1.0)); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = cos(im) * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -0.0031], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.075], N[(N[Cos[im], $MachinePrecision] * N[(t$95$0 + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.9e+154], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(re \cdot 0.5\right)\\
\mathbf{if}\;re \leq -0.0031:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.075:\\
\;\;\;\;\cos im \cdot \left(t_0 + \left(re + 1\right)\right)\\
\mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot t_0\\
\end{array}
\end{array}
if re < -0.00309999999999999989 or 0.0749999999999999972 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 88.2%
if -0.00309999999999999989 < re < 0.0749999999999999972Initial program 100.0%
Taylor expanded in re around 0 99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
distribute-lft1-in99.6%
distribute-rgt-out99.6%
+-commutative99.6%
*-commutative99.6%
unpow299.6%
associate-*l*99.6%
Simplified99.6%
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%
unpow2100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification95.3%
(FPCore (re im)
:precision binary64
(if (<= re -0.000125)
(exp re)
(if (<= re 0.031)
(* (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.000125) {
tmp = exp(re);
} else if (re <= 0.031) {
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.000125d0)) then
tmp = exp(re)
else if (re <= 0.031d0) 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.000125) {
tmp = Math.exp(re);
} else if (re <= 0.031) {
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.000125: tmp = math.exp(re) elif re <= 0.031: 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.000125) tmp = exp(re); elseif (re <= 0.031) 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.000125) tmp = exp(re); elseif (re <= 0.031) 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.000125], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.031], 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.000125:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.031:\\
\;\;\;\;\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 < -1.25e-4 or 0.031 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 88.2%
if -1.25e-4 < re < 0.031Initial program 100.0%
Taylor expanded in re around 0 99.4%
*-rgt-identity99.4%
distribute-lft-in99.4%
Simplified99.4%
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%
unpow2100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification95.2%
(FPCore (re im) :precision binary64 (if (<= re -3.2e-5) (exp re) (if (<= re 0.031) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -3.2e-5) {
tmp = exp(re);
} else if (re <= 0.031) {
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 <= (-3.2d-5)) then
tmp = exp(re)
else if (re <= 0.031d0) 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 <= -3.2e-5) {
tmp = Math.exp(re);
} else if (re <= 0.031) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -3.2e-5: tmp = math.exp(re) elif re <= 0.031: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -3.2e-5) tmp = exp(re); elseif (re <= 0.031) 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 <= -3.2e-5) tmp = exp(re); elseif (re <= 0.031) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -3.2e-5], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.031], 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 -3.2 \cdot 10^{-5}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.031:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -3.19999999999999986e-5 or 0.031 < re Initial program 100.0%
Taylor expanded in im around 0 84.7%
if -3.19999999999999986e-5 < re < 0.031Initial program 100.0%
Taylor expanded in re around 0 99.4%
*-rgt-identity99.4%
distribute-lft-in99.4%
Simplified99.4%
Final simplification92.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- 1.0 (* re re))))
(if (<= re 3000000000000.0)
(cos im)
(if (<= re 6e+150)
(+ 1.0 (+ re (* -0.5 (/ (* t_0 (* im (* im (+ re 1.0)))) t_0))))
(* re (* re 0.5))))))
double code(double re, double im) {
double t_0 = 1.0 - (re * re);
double tmp;
if (re <= 3000000000000.0) {
tmp = cos(im);
} else if (re <= 6e+150) {
tmp = 1.0 + (re + (-0.5 * ((t_0 * (im * (im * (re + 1.0)))) / 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 = 1.0d0 - (re * re)
if (re <= 3000000000000.0d0) then
tmp = cos(im)
else if (re <= 6d+150) then
tmp = 1.0d0 + (re + ((-0.5d0) * ((t_0 * (im * (im * (re + 1.0d0)))) / 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 = 1.0 - (re * re);
double tmp;
if (re <= 3000000000000.0) {
tmp = Math.cos(im);
} else if (re <= 6e+150) {
tmp = 1.0 + (re + (-0.5 * ((t_0 * (im * (im * (re + 1.0)))) / t_0)));
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): t_0 = 1.0 - (re * re) tmp = 0 if re <= 3000000000000.0: tmp = math.cos(im) elif re <= 6e+150: tmp = 1.0 + (re + (-0.5 * ((t_0 * (im * (im * (re + 1.0)))) / t_0))) else: tmp = re * (re * 0.5) return tmp
function code(re, im) t_0 = Float64(1.0 - Float64(re * re)) tmp = 0.0 if (re <= 3000000000000.0) tmp = cos(im); elseif (re <= 6e+150) tmp = Float64(1.0 + Float64(re + Float64(-0.5 * Float64(Float64(t_0 * Float64(im * Float64(im * Float64(re + 1.0)))) / t_0)))); else tmp = Float64(re * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) t_0 = 1.0 - (re * re); tmp = 0.0; if (re <= 3000000000000.0) tmp = cos(im); elseif (re <= 6e+150) tmp = 1.0 + (re + (-0.5 * ((t_0 * (im * (im * (re + 1.0)))) / t_0))); else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 3000000000000.0], N[Cos[im], $MachinePrecision], If[LessEqual[re, 6e+150], N[(1.0 + N[(re + N[(-0.5 * N[(N[(t$95$0 * N[(im * N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - re \cdot re\\
\mathbf{if}\;re \leq 3000000000000:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 6 \cdot 10^{+150}:\\
\;\;\;\;1 + \left(re + -0.5 \cdot \frac{t_0 \cdot \left(im \cdot \left(im \cdot \left(re + 1\right)\right)\right)}{t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 3e12Initial program 100.0%
Taylor expanded in re around 0 65.3%
if 3e12 < re < 6.00000000000000025e150Initial program 100.0%
Taylor expanded in re around 0 3.8%
*-rgt-identity3.8%
distribute-lft-in3.8%
Simplified3.8%
Taylor expanded in im around 0 22.1%
+-commutative22.1%
*-commutative22.1%
unpow222.1%
+-commutative22.1%
Simplified22.1%
*-commutative22.1%
flip-+22.1%
associate-*l/25.7%
metadata-eval25.7%
Applied egg-rr25.7%
flip--25.7%
metadata-eval25.7%
associate-/r/25.7%
*-commutative25.7%
associate-*l*25.7%
+-commutative25.7%
Applied egg-rr25.7%
associate-*l/32.8%
associate-*r*32.8%
*-commutative32.8%
associate-*l*32.8%
associate-*l*32.8%
+-commutative32.8%
Simplified32.8%
if 6.00000000000000025e150 < re Initial program 100.0%
Taylor expanded in re around 0 92.0%
*-commutative92.0%
associate-*r*92.0%
*-commutative92.0%
distribute-lft1-in92.0%
distribute-rgt-out92.0%
+-commutative92.0%
*-commutative92.0%
unpow292.0%
associate-*l*92.0%
Simplified92.0%
Taylor expanded in re around inf 92.0%
unpow292.0%
*-commutative92.0%
associate-*r*92.0%
Simplified92.0%
Taylor expanded in im around 0 67.8%
*-commutative67.8%
unpow267.8%
associate-*r*67.8%
Simplified67.8%
Final simplification62.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- 1.0 (* re re))))
(if (<= re 4400000000000.0)
(+ re 1.0)
(if (<= re 9.6e+150)
(+ 1.0 (+ re (* -0.5 (/ (* t_0 (* im (* im (+ re 1.0)))) t_0))))
(* re (* re 0.5))))))
double code(double re, double im) {
double t_0 = 1.0 - (re * re);
double tmp;
if (re <= 4400000000000.0) {
tmp = re + 1.0;
} else if (re <= 9.6e+150) {
tmp = 1.0 + (re + (-0.5 * ((t_0 * (im * (im * (re + 1.0)))) / 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 = 1.0d0 - (re * re)
if (re <= 4400000000000.0d0) then
tmp = re + 1.0d0
else if (re <= 9.6d+150) then
tmp = 1.0d0 + (re + ((-0.5d0) * ((t_0 * (im * (im * (re + 1.0d0)))) / 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 = 1.0 - (re * re);
double tmp;
if (re <= 4400000000000.0) {
tmp = re + 1.0;
} else if (re <= 9.6e+150) {
tmp = 1.0 + (re + (-0.5 * ((t_0 * (im * (im * (re + 1.0)))) / t_0)));
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): t_0 = 1.0 - (re * re) tmp = 0 if re <= 4400000000000.0: tmp = re + 1.0 elif re <= 9.6e+150: tmp = 1.0 + (re + (-0.5 * ((t_0 * (im * (im * (re + 1.0)))) / t_0))) else: tmp = re * (re * 0.5) return tmp
function code(re, im) t_0 = Float64(1.0 - Float64(re * re)) tmp = 0.0 if (re <= 4400000000000.0) tmp = Float64(re + 1.0); elseif (re <= 9.6e+150) tmp = Float64(1.0 + Float64(re + Float64(-0.5 * Float64(Float64(t_0 * Float64(im * Float64(im * Float64(re + 1.0)))) / t_0)))); else tmp = Float64(re * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) t_0 = 1.0 - (re * re); tmp = 0.0; if (re <= 4400000000000.0) tmp = re + 1.0; elseif (re <= 9.6e+150) tmp = 1.0 + (re + (-0.5 * ((t_0 * (im * (im * (re + 1.0)))) / t_0))); else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 4400000000000.0], N[(re + 1.0), $MachinePrecision], If[LessEqual[re, 9.6e+150], N[(1.0 + N[(re + N[(-0.5 * N[(N[(t$95$0 * N[(im * N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - re \cdot re\\
\mathbf{if}\;re \leq 4400000000000:\\
\;\;\;\;re + 1\\
\mathbf{elif}\;re \leq 9.6 \cdot 10^{+150}:\\
\;\;\;\;1 + \left(re + -0.5 \cdot \frac{t_0 \cdot \left(im \cdot \left(im \cdot \left(re + 1\right)\right)\right)}{t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 4.4e12Initial program 100.0%
Taylor expanded in re around 0 65.6%
*-rgt-identity65.6%
distribute-lft-in65.6%
Simplified65.6%
Taylor expanded in im around 0 39.6%
if 4.4e12 < re < 9.60000000000000011e150Initial program 100.0%
Taylor expanded in re around 0 3.8%
*-rgt-identity3.8%
distribute-lft-in3.8%
Simplified3.8%
Taylor expanded in im around 0 22.1%
+-commutative22.1%
*-commutative22.1%
unpow222.1%
+-commutative22.1%
Simplified22.1%
*-commutative22.1%
flip-+22.1%
associate-*l/25.7%
metadata-eval25.7%
Applied egg-rr25.7%
flip--25.7%
metadata-eval25.7%
associate-/r/25.7%
*-commutative25.7%
associate-*l*25.7%
+-commutative25.7%
Applied egg-rr25.7%
associate-*l/32.8%
associate-*r*32.8%
*-commutative32.8%
associate-*l*32.8%
associate-*l*32.8%
+-commutative32.8%
Simplified32.8%
if 9.60000000000000011e150 < re Initial program 100.0%
Taylor expanded in re around 0 92.0%
*-commutative92.0%
associate-*r*92.0%
*-commutative92.0%
distribute-lft1-in92.0%
distribute-rgt-out92.0%
+-commutative92.0%
*-commutative92.0%
unpow292.0%
associate-*l*92.0%
Simplified92.0%
Taylor expanded in re around inf 92.0%
unpow292.0%
*-commutative92.0%
associate-*r*92.0%
Simplified92.0%
Taylor expanded in im around 0 67.8%
*-commutative67.8%
unpow267.8%
associate-*r*67.8%
Simplified67.8%
Final simplification42.5%
(FPCore (re im) :precision binary64 (if (<= re 9.5e+150) (+ 1.0 (- re (* -0.5 (/ (* (* re re) (* im im)) (- 1.0 re))))) (* re (* re 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 9.5e+150) {
tmp = 1.0 + (re - (-0.5 * (((re * re) * (im * im)) / (1.0 - re))));
} 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 <= 9.5d+150) then
tmp = 1.0d0 + (re - ((-0.5d0) * (((re * re) * (im * im)) / (1.0d0 - re))))
else
tmp = re * (re * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 9.5e+150) {
tmp = 1.0 + (re - (-0.5 * (((re * re) * (im * im)) / (1.0 - re))));
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 9.5e+150: tmp = 1.0 + (re - (-0.5 * (((re * re) * (im * im)) / (1.0 - re)))) else: tmp = re * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 9.5e+150) tmp = Float64(1.0 + Float64(re - Float64(-0.5 * Float64(Float64(Float64(re * re) * Float64(im * im)) / Float64(1.0 - re))))); else tmp = Float64(re * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 9.5e+150) tmp = 1.0 + (re - (-0.5 * (((re * re) * (im * im)) / (1.0 - re)))); else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 9.5e+150], N[(1.0 + N[(re - N[(-0.5 * N[(N[(N[(re * re), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 9.5 \cdot 10^{+150}:\\
\;\;\;\;1 + \left(re - -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(im \cdot im\right)}{1 - re}\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 9.5000000000000001e150Initial program 100.0%
Taylor expanded in re around 0 58.4%
*-rgt-identity58.4%
distribute-lft-in58.4%
Simplified58.4%
Taylor expanded in im around 0 35.3%
+-commutative35.3%
*-commutative35.3%
unpow235.3%
+-commutative35.3%
Simplified35.3%
*-commutative35.3%
flip-+35.3%
associate-*l/35.7%
metadata-eval35.7%
Applied egg-rr35.7%
Taylor expanded in re around inf 36.2%
unpow236.2%
mul-1-neg36.2%
distribute-rgt-neg-out36.2%
Simplified36.2%
if 9.5000000000000001e150 < re Initial program 100.0%
Taylor expanded in re around 0 92.0%
*-commutative92.0%
associate-*r*92.0%
*-commutative92.0%
distribute-lft1-in92.0%
distribute-rgt-out92.0%
+-commutative92.0%
*-commutative92.0%
unpow292.0%
associate-*l*92.0%
Simplified92.0%
Taylor expanded in re around inf 92.0%
unpow292.0%
*-commutative92.0%
associate-*r*92.0%
Simplified92.0%
Taylor expanded in im around 0 67.8%
*-commutative67.8%
unpow267.8%
associate-*r*67.8%
Simplified67.8%
Final simplification40.2%
(FPCore (re im) :precision binary64 (if (<= re 3000000000000.0) (+ re 1.0) (if (<= re 8.5e+150) (+ 1.0 (+ re (* -0.5 (* im im)))) (* re (* re 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= 3000000000000.0) {
tmp = re + 1.0;
} else if (re <= 8.5e+150) {
tmp = 1.0 + (re + (-0.5 * (im * im)));
} 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 <= 3000000000000.0d0) then
tmp = re + 1.0d0
else if (re <= 8.5d+150) then
tmp = 1.0d0 + (re + ((-0.5d0) * (im * im)))
else
tmp = re * (re * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 3000000000000.0) {
tmp = re + 1.0;
} else if (re <= 8.5e+150) {
tmp = 1.0 + (re + (-0.5 * (im * im)));
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3000000000000.0: tmp = re + 1.0 elif re <= 8.5e+150: tmp = 1.0 + (re + (-0.5 * (im * im))) else: tmp = re * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 3000000000000.0) tmp = Float64(re + 1.0); elseif (re <= 8.5e+150) tmp = Float64(1.0 + Float64(re + Float64(-0.5 * Float64(im * im)))); else tmp = Float64(re * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3000000000000.0) tmp = re + 1.0; elseif (re <= 8.5e+150) tmp = 1.0 + (re + (-0.5 * (im * im))); else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3000000000000.0], N[(re + 1.0), $MachinePrecision], If[LessEqual[re, 8.5e+150], N[(1.0 + N[(re + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3000000000000:\\
\;\;\;\;re + 1\\
\mathbf{elif}\;re \leq 8.5 \cdot 10^{+150}:\\
\;\;\;\;1 + \left(re + -0.5 \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 3e12Initial program 100.0%
Taylor expanded in re around 0 65.6%
*-rgt-identity65.6%
distribute-lft-in65.6%
Simplified65.6%
Taylor expanded in im around 0 39.6%
if 3e12 < re < 8.4999999999999999e150Initial program 100.0%
Taylor expanded in re around 0 3.8%
*-rgt-identity3.8%
distribute-lft-in3.8%
Simplified3.8%
Taylor expanded in im around 0 22.1%
+-commutative22.1%
*-commutative22.1%
unpow222.1%
+-commutative22.1%
Simplified22.1%
Taylor expanded in re around 0 21.8%
unpow221.8%
Simplified21.8%
if 8.4999999999999999e150 < re Initial program 100.0%
Taylor expanded in re around 0 92.0%
*-commutative92.0%
associate-*r*92.0%
*-commutative92.0%
distribute-lft1-in92.0%
distribute-rgt-out92.0%
+-commutative92.0%
*-commutative92.0%
unpow292.0%
associate-*l*92.0%
Simplified92.0%
Taylor expanded in re around inf 92.0%
unpow292.0%
*-commutative92.0%
associate-*r*92.0%
Simplified92.0%
Taylor expanded in im around 0 67.8%
*-commutative67.8%
unpow267.8%
associate-*r*67.8%
Simplified67.8%
Final simplification41.4%
(FPCore (re im) :precision binary64 (if (<= re 2.4e+149) (+ 1.0 (+ re (* -0.5 (* im (* re im))))) (* re (* re 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 2.4e+149) {
tmp = 1.0 + (re + (-0.5 * (im * (re * im))));
} 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 <= 2.4d+149) then
tmp = 1.0d0 + (re + ((-0.5d0) * (im * (re * im))))
else
tmp = re * (re * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2.4e+149) {
tmp = 1.0 + (re + (-0.5 * (im * (re * im))));
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2.4e+149: tmp = 1.0 + (re + (-0.5 * (im * (re * im)))) else: tmp = re * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 2.4e+149) tmp = Float64(1.0 + Float64(re + Float64(-0.5 * Float64(im * Float64(re * im))))); else tmp = Float64(re * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2.4e+149) tmp = 1.0 + (re + (-0.5 * (im * (re * im)))); else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2.4e+149], N[(1.0 + N[(re + N[(-0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.4 \cdot 10^{+149}:\\
\;\;\;\;1 + \left(re + -0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 2.40000000000000012e149Initial program 100.0%
Taylor expanded in re around 0 58.4%
*-rgt-identity58.4%
distribute-lft-in58.4%
Simplified58.4%
Taylor expanded in im around 0 35.3%
+-commutative35.3%
*-commutative35.3%
unpow235.3%
+-commutative35.3%
Simplified35.3%
Taylor expanded in re around inf 35.7%
unpow235.7%
*-commutative35.7%
associate-*r*35.8%
Simplified35.8%
if 2.40000000000000012e149 < re Initial program 100.0%
Taylor expanded in re around 0 92.0%
*-commutative92.0%
associate-*r*92.0%
*-commutative92.0%
distribute-lft1-in92.0%
distribute-rgt-out92.0%
+-commutative92.0%
*-commutative92.0%
unpow292.0%
associate-*l*92.0%
Simplified92.0%
Taylor expanded in re around inf 92.0%
unpow292.0%
*-commutative92.0%
associate-*r*92.0%
Simplified92.0%
Taylor expanded in im around 0 67.8%
*-commutative67.8%
unpow267.8%
associate-*r*67.8%
Simplified67.8%
Final simplification39.9%
(FPCore (re im) :precision binary64 (if (<= re 1.6) (+ re 1.0) (* re (* re 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 1.6) {
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.6d0) 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.6) {
tmp = re + 1.0;
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.6: tmp = re + 1.0 else: tmp = re * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.6) tmp = Float64(re + 1.0); else tmp = Float64(re * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.6) tmp = re + 1.0; else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.6], N[(re + 1.0), $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.6:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 1.6000000000000001Initial program 100.0%
Taylor expanded in re around 0 66.5%
*-rgt-identity66.5%
distribute-lft-in66.5%
Simplified66.5%
Taylor expanded in im around 0 40.1%
if 1.6000000000000001 < re Initial program 100.0%
Taylor expanded in re around 0 51.6%
*-commutative51.6%
associate-*r*51.6%
*-commutative51.6%
distribute-lft1-in51.6%
distribute-rgt-out51.6%
+-commutative51.6%
*-commutative51.6%
unpow251.6%
associate-*l*51.6%
Simplified51.6%
Taylor expanded in re around inf 51.5%
unpow251.5%
*-commutative51.5%
associate-*r*51.5%
Simplified51.5%
Taylor expanded in im around 0 37.6%
*-commutative37.6%
unpow237.6%
associate-*r*37.6%
Simplified37.6%
Final simplification39.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 51.7%
*-rgt-identity51.7%
distribute-lft-in51.7%
Simplified51.7%
Taylor expanded in im around 0 31.4%
Final simplification31.4%
(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 51.7%
*-rgt-identity51.7%
distribute-lft-in51.7%
Simplified51.7%
Taylor expanded in re around inf 3.9%
Taylor expanded in im around 0 3.4%
Final simplification3.4%
herbie shell --seed 2023278
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))