
(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) 1.0) (exp re) (if (<= (exp re) 1.005) (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.005) {
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.005d0) 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.005) {
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.005: 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.005) 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.005) 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.005], 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.005:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 1.0049999999999999 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 76.6%
if 1 < (exp.f64 re) < 1.0049999999999999Initial program 99.7%
Taylor expanded in re around 0 71.8%
Final simplification76.5%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.0285) (and (not (<= re 0.0085)) (<= re 1.6e+89)))
(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.0285) || (!(re <= 0.0085) && (re <= 1.6e+89))) {
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.0285d0)) .or. (.not. (re <= 0.0085d0)) .and. (re <= 1.6d+89)) 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.0285) || (!(re <= 0.0085) && (re <= 1.6e+89))) {
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.0285) or (not (re <= 0.0085) and (re <= 1.6e+89)): 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.0285) || (!(re <= 0.0085) && (re <= 1.6e+89))) 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.0285) || (~((re <= 0.0085)) && (re <= 1.6e+89))) 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.0285], And[N[Not[LessEqual[re, 0.0085]], $MachinePrecision], LessEqual[re, 1.6e+89]]], 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.0285 \lor \neg \left(re \leq 0.0085\right) \land re \leq 1.6 \cdot 10^{+89}:\\
\;\;\;\;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.028500000000000001 or 0.0085000000000000006 < re < 1.59999999999999994e89Initial program 100.0%
Taylor expanded in im around 0 97.8%
if -0.028500000000000001 < re < 0.0085000000000000006 or 1.59999999999999994e89 < re Initial program 100.0%
Taylor expanded in re around 0 98.7%
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.8%
Simplified98.8%
Final simplification98.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))))
(if (<= re -0.0145)
(exp re)
(if (<= re 0.0043)
(* (cos im) (+ (+ re 1.0) t_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.0145) {
tmp = exp(re);
} else if (re <= 0.0043) {
tmp = cos(im) * ((re + 1.0) + t_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.0145d0)) then
tmp = exp(re)
else if (re <= 0.0043d0) then
tmp = cos(im) * ((re + 1.0d0) + t_0)
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.0145) {
tmp = Math.exp(re);
} else if (re <= 0.0043) {
tmp = Math.cos(im) * ((re + 1.0) + t_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.0145: tmp = math.exp(re) elif re <= 0.0043: tmp = math.cos(im) * ((re + 1.0) + t_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.0145) tmp = exp(re); elseif (re <= 0.0043) tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + t_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.0145) tmp = exp(re); elseif (re <= 0.0043) tmp = cos(im) * ((re + 1.0) + t_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.0145], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.0043], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + t$95$0), $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.0145:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.0043:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + t_0\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.0145000000000000007 or 0.0043 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 96.3%
if -0.0145000000000000007 < re < 0.0043Initial program 100.0%
Taylor expanded in re around 0 99.3%
*-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
distribute-lft1-in99.3%
distribute-rgt-out99.3%
+-commutative99.3%
*-commutative99.3%
unpow299.3%
associate-*l*99.3%
Simplified99.3%
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 simplification98.1%
(FPCore (re im)
:precision binary64
(if (<= re -0.00105)
(exp re)
(if (<= re 0.0009)
(* (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.00105) {
tmp = exp(re);
} else if (re <= 0.0009) {
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.00105d0)) then
tmp = exp(re)
else if (re <= 0.0009d0) 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.00105) {
tmp = Math.exp(re);
} else if (re <= 0.0009) {
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.00105: tmp = math.exp(re) elif re <= 0.0009: 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.00105) tmp = exp(re); elseif (re <= 0.0009) 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.00105) tmp = exp(re); elseif (re <= 0.0009) 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.00105], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.0009], 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.00105:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.0009:\\
\;\;\;\;\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 < -0.00104999999999999994 or 8.9999999999999998e-4 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 96.3%
if -0.00104999999999999994 < re < 8.9999999999999998e-4Initial program 100.0%
Taylor expanded in re around 0 98.4%
*-rgt-identity98.4%
distribute-lft-in98.4%
Simplified98.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%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification97.7%
(FPCore (re im) :precision binary64 (if (<= re -0.066) (exp re) (if (<= re 0.0017) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -0.066) {
tmp = exp(re);
} else if (re <= 0.0017) {
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 <= (-0.066d0)) then
tmp = exp(re)
else if (re <= 0.0017d0) 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 <= -0.066) {
tmp = Math.exp(re);
} else if (re <= 0.0017) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.066: tmp = math.exp(re) elif re <= 0.0017: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.066) tmp = exp(re); elseif (re <= 0.0017) 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 <= -0.066) tmp = exp(re); elseif (re <= 0.0017) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.066], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.0017], 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 -0.066:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.0017:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -0.066000000000000003 or 0.00169999999999999991 < re Initial program 100.0%
Taylor expanded in im around 0 92.6%
if -0.066000000000000003 < re < 0.00169999999999999991Initial program 100.0%
Taylor expanded in re around 0 98.4%
*-rgt-identity98.4%
distribute-lft-in98.4%
Simplified98.4%
Final simplification95.3%
(FPCore (re im) :precision binary64 (if (<= re -620.0) (* -0.5 (* im im)) (if (<= re 5.2e+48) (cos im) (* re (* re 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -620.0) {
tmp = -0.5 * (im * im);
} else if (re <= 5.2e+48) {
tmp = cos(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 <= (-620.0d0)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 5.2d+48) then
tmp = cos(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 <= -620.0) {
tmp = -0.5 * (im * im);
} else if (re <= 5.2e+48) {
tmp = Math.cos(im);
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -620.0: tmp = -0.5 * (im * im) elif re <= 5.2e+48: tmp = math.cos(im) else: tmp = re * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= -620.0) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 5.2e+48) tmp = cos(im); else tmp = Float64(re * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -620.0) tmp = -0.5 * (im * im); elseif (re <= 5.2e+48) tmp = cos(im); else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -620.0], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 5.2e+48], N[Cos[im], $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -620:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 5.2 \cdot 10^{+48}:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -620Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
distribute-lft-in2.2%
Simplified2.2%
Taylor expanded in im around 0 1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
+-commutative1.9%
Simplified1.9%
Taylor expanded in re around 0 2.5%
unpow22.5%
Simplified2.5%
Taylor expanded in im around inf 21.4%
unpow221.4%
Simplified21.4%
if -620 < re < 5.1999999999999999e48Initial program 100.0%
Taylor expanded in re around 0 89.0%
if 5.1999999999999999e48 < re Initial program 100.0%
Taylor expanded in re around 0 55.9%
*-commutative55.9%
associate-*r*55.9%
*-commutative55.9%
distribute-lft1-in55.9%
distribute-rgt-out55.9%
+-commutative55.9%
*-commutative55.9%
unpow255.9%
associate-*l*55.9%
Simplified55.9%
Taylor expanded in re around inf 55.9%
*-commutative55.9%
unpow255.9%
associate-*r*55.9%
associate-*r*55.9%
Simplified55.9%
Taylor expanded in im around 0 5.8%
fma-def5.8%
unpow25.8%
unpow25.8%
unpow25.8%
associate-*r*5.8%
Simplified5.8%
Taylor expanded in im around 0 43.9%
unpow243.9%
*-commutative43.9%
associate-*l*43.9%
Simplified43.9%
Final simplification60.5%
(FPCore (re im) :precision binary64 (if (<= re -4.6) (* -0.5 (* im im)) (if (<= re 2.8) (+ re 1.0) (* re (* re 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -4.6) {
tmp = -0.5 * (im * im);
} else if (re <= 2.8) {
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 <= (-4.6d0)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 2.8d0) 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 <= -4.6) {
tmp = -0.5 * (im * im);
} else if (re <= 2.8) {
tmp = re + 1.0;
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.6: tmp = -0.5 * (im * im) elif re <= 2.8: tmp = re + 1.0 else: tmp = re * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= -4.6) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 2.8) 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 <= -4.6) tmp = -0.5 * (im * im); elseif (re <= 2.8) tmp = re + 1.0; else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.6], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 2.8], N[(re + 1.0), $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.6:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 2.8:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -4.5999999999999996Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
distribute-lft-in2.2%
Simplified2.2%
Taylor expanded in im around 0 1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
+-commutative1.9%
Simplified1.9%
Taylor expanded in re around 0 2.6%
unpow22.6%
Simplified2.6%
Taylor expanded in im around inf 21.2%
unpow221.2%
Simplified21.2%
if -4.5999999999999996 < re < 2.7999999999999998Initial program 100.0%
Taylor expanded in re around 0 97.9%
*-rgt-identity97.9%
distribute-lft-in97.9%
Simplified97.9%
Taylor expanded in im around 0 56.7%
if 2.7999999999999998 < re Initial program 100.0%
Taylor expanded in re around 0 48.3%
*-commutative48.3%
associate-*r*48.3%
*-commutative48.3%
distribute-lft1-in48.3%
distribute-rgt-out48.3%
+-commutative48.3%
*-commutative48.3%
unpow248.3%
associate-*l*48.3%
Simplified48.3%
Taylor expanded in re around inf 48.3%
*-commutative48.3%
unpow248.3%
associate-*r*48.3%
associate-*r*48.3%
Simplified48.3%
Taylor expanded in im around 0 5.6%
fma-def5.6%
unpow25.6%
unpow25.6%
unpow25.6%
associate-*r*5.6%
Simplified5.6%
Taylor expanded in im around 0 38.0%
unpow238.0%
*-commutative38.0%
associate-*l*38.0%
Simplified38.0%
Final simplification41.9%
(FPCore (re im) :precision binary64 (if (<= re -4.6) (* -0.5 (* im im)) (+ re 1.0)))
double code(double re, double im) {
double tmp;
if (re <= -4.6) {
tmp = -0.5 * (im * im);
} 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 <= (-4.6d0)) then
tmp = (-0.5d0) * (im * im)
else
tmp = re + 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -4.6) {
tmp = -0.5 * (im * im);
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.6: tmp = -0.5 * (im * im) else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if (re <= -4.6) tmp = Float64(-0.5 * Float64(im * im)); else tmp = Float64(re + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -4.6) tmp = -0.5 * (im * im); else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.6], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.6:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if re < -4.5999999999999996Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
distribute-lft-in2.2%
Simplified2.2%
Taylor expanded in im around 0 1.9%
+-commutative1.9%
*-commutative1.9%
unpow21.9%
+-commutative1.9%
Simplified1.9%
Taylor expanded in re around 0 2.6%
unpow22.6%
Simplified2.6%
Taylor expanded in im around inf 21.2%
unpow221.2%
Simplified21.2%
if -4.5999999999999996 < re Initial program 100.0%
Taylor expanded in re around 0 67.2%
*-rgt-identity67.2%
distribute-lft-in67.2%
Simplified67.2%
Taylor expanded in im around 0 39.3%
Final simplification34.0%
(FPCore (re im) :precision binary64 (+ re 1.0))
double code(double re, double im) {
return re + 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re + 1.0d0
end function
public static double code(double re, double im) {
return re + 1.0;
}
def code(re, im): return re + 1.0
function code(re, im) return Float64(re + 1.0) end
function tmp = code(re, im) tmp = re + 1.0; end
code[re_, im_] := N[(re + 1.0), $MachinePrecision]
\begin{array}{l}
\\
re + 1
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 48.2%
*-rgt-identity48.2%
distribute-lft-in48.2%
Simplified48.2%
Taylor expanded in im around 0 28.5%
Final simplification28.5%
(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 48.2%
*-rgt-identity48.2%
distribute-lft-in48.2%
Simplified48.2%
Taylor expanded in im around 0 29.2%
+-commutative29.2%
*-commutative29.2%
unpow229.2%
+-commutative29.2%
Simplified29.2%
Taylor expanded in re around 0 28.1%
unpow228.1%
Simplified28.1%
Taylor expanded in im around 0 28.1%
Final simplification28.1%
herbie shell --seed 2023223
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))