
(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 13 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) 5e-12) (exp re) (if (<= (exp re) 2.0) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 5e-12) {
tmp = exp(re);
} else if (exp(re) <= 2.0) {
tmp = cos(im) * (re + 1.0);
} else {
tmp = exp(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (exp(re) <= 5d-12) then
tmp = exp(re)
else if (exp(re) <= 2.0d0) then
tmp = cos(im) * (re + 1.0d0)
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 5e-12) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 2.0) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 5e-12: tmp = math.exp(re) elif math.exp(re) <= 2.0: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 5e-12) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = Float64(cos(im) * Float64(re + 1.0)); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 5e-12) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 5e-12], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 4.9999999999999997e-12 or 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 88.7%
if 4.9999999999999997e-12 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 99.7%
*-rgt-identity99.7%
distribute-lft-out99.6%
Simplified99.6%
Final simplification94.4%
(FPCore (re im) :precision binary64 (if (<= (exp re) 5e-12) (exp re) (if (<= (exp re) 2.0) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 5e-12) {
tmp = exp(re);
} else if (exp(re) <= 2.0) {
tmp = cos(im);
} else {
tmp = exp(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (exp(re) <= 5d-12) then
tmp = exp(re)
else if (exp(re) <= 2.0d0) then
tmp = cos(im)
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 5e-12) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 2.0) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 5e-12: tmp = math.exp(re) elif math.exp(re) <= 2.0: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 5e-12) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 5e-12) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 5e-12], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 4.9999999999999997e-12 or 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 88.7%
if 4.9999999999999997e-12 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 98.8%
Final simplification93.9%
(FPCore (re im)
:precision binary64
(if (<= re -0.0205)
(exp re)
(if (or (<= re 600000.0) (not (<= re 1.35e+154)))
(* (cos im) (+ (* 0.5 (* re re)) (+ re 1.0)))
(* (exp re) (+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
double tmp;
if (re <= -0.0205) {
tmp = exp(re);
} else if ((re <= 600000.0) || !(re <= 1.35e+154)) {
tmp = cos(im) * ((0.5 * (re * re)) + (re + 1.0));
} else {
tmp = exp(re) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-0.0205d0)) then
tmp = exp(re)
else if ((re <= 600000.0d0) .or. (.not. (re <= 1.35d+154))) then
tmp = cos(im) * ((0.5d0 * (re * re)) + (re + 1.0d0))
else
tmp = exp(re) * (1.0d0 + ((-0.5d0) * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.0205) {
tmp = Math.exp(re);
} else if ((re <= 600000.0) || !(re <= 1.35e+154)) {
tmp = Math.cos(im) * ((0.5 * (re * re)) + (re + 1.0));
} else {
tmp = Math.exp(re) * (1.0 + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.0205: tmp = math.exp(re) elif (re <= 600000.0) or not (re <= 1.35e+154): tmp = math.cos(im) * ((0.5 * (re * re)) + (re + 1.0)) else: tmp = math.exp(re) * (1.0 + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.0205) tmp = exp(re); elseif ((re <= 600000.0) || !(re <= 1.35e+154)) tmp = Float64(cos(im) * Float64(Float64(0.5 * Float64(re * re)) + Float64(re + 1.0))); else tmp = Float64(exp(re) * Float64(1.0 + Float64(-0.5 * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.0205) tmp = exp(re); elseif ((re <= 600000.0) || ~((re <= 1.35e+154))) tmp = cos(im) * ((0.5 * (re * re)) + (re + 1.0)); else tmp = exp(re) * (1.0 + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.0205], N[Exp[re], $MachinePrecision], If[Or[LessEqual[re, 600000.0], N[Not[LessEqual[re, 1.35e+154]], $MachinePrecision]], N[(N[Cos[im], $MachinePrecision] * N[(N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0205:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 600000 \lor \neg \left(re \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\cos im \cdot \left(0.5 \cdot \left(re \cdot re\right) + \left(re + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -0.0205000000000000009Initial program 100.0%
Taylor expanded in im around 0 100.0%
if -0.0205000000000000009 < re < 6e5 or 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.3%
+-commutative99.3%
+-commutative99.3%
*-rgt-identity99.3%
distribute-lft-out99.3%
*-commutative99.3%
associate-*l*99.3%
distribute-lft-out99.3%
+-commutative99.3%
*-commutative99.3%
unpow299.3%
Simplified99.3%
if 6e5 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 77.8%
unpow277.8%
Simplified77.8%
Final simplification96.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))) (t_1 (- -1.0 t_0)))
(if (<= re -580.0)
(* -0.5 (* im im))
(if (<= re 1.9e+67)
(cos im)
(if (<= re 1.35e+154)
(/ (+ (* re re) (* (+ 1.0 t_0) t_1)) (+ re t_1))
t_0)))))
double code(double re, double im) {
double t_0 = re * (re * 0.5);
double t_1 = -1.0 - t_0;
double tmp;
if (re <= -580.0) {
tmp = -0.5 * (im * im);
} else if (re <= 1.9e+67) {
tmp = cos(im);
} else if (re <= 1.35e+154) {
tmp = ((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1);
} else {
tmp = 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) :: t_1
real(8) :: tmp
t_0 = re * (re * 0.5d0)
t_1 = (-1.0d0) - t_0
if (re <= (-580.0d0)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 1.9d+67) then
tmp = cos(im)
else if (re <= 1.35d+154) then
tmp = ((re * re) + ((1.0d0 + t_0) * t_1)) / (re + t_1)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (re * 0.5);
double t_1 = -1.0 - t_0;
double tmp;
if (re <= -580.0) {
tmp = -0.5 * (im * im);
} else if (re <= 1.9e+67) {
tmp = Math.cos(im);
} else if (re <= 1.35e+154) {
tmp = ((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = re * (re * 0.5) t_1 = -1.0 - t_0 tmp = 0 if re <= -580.0: tmp = -0.5 * (im * im) elif re <= 1.9e+67: tmp = math.cos(im) elif re <= 1.35e+154: tmp = ((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(re * Float64(re * 0.5)) t_1 = Float64(-1.0 - t_0) tmp = 0.0 if (re <= -580.0) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 1.9e+67) tmp = cos(im); elseif (re <= 1.35e+154) tmp = Float64(Float64(Float64(re * re) + Float64(Float64(1.0 + t_0) * t_1)) / Float64(re + t_1)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = re * (re * 0.5); t_1 = -1.0 - t_0; tmp = 0.0; if (re <= -580.0) tmp = -0.5 * (im * im); elseif (re <= 1.9e+67) tmp = cos(im); elseif (re <= 1.35e+154) tmp = ((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 - t$95$0), $MachinePrecision]}, If[LessEqual[re, -580.0], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.9e+67], N[Cos[im], $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[(N[(re * re), $MachinePrecision] + N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(re + t$95$1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(re \cdot 0.5\right)\\
t_1 := -1 - t_0\\
\mathbf{if}\;re \leq -580:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 1.9 \cdot 10^{+67}:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{re \cdot re + \left(1 + t_0\right) \cdot t_1}{re + t_1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if re < -580Initial program 100.0%
Taylor expanded in im around 0 75.8%
unpow275.8%
Simplified75.8%
Taylor expanded in im around inf 75.8%
unpow275.8%
*-commutative75.8%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around 0 31.0%
unpow231.0%
Simplified31.0%
if -580 < re < 1.9000000000000001e67Initial program 100.0%
Taylor expanded in re around 0 88.5%
if 1.9000000000000001e67 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in re around 0 7.5%
+-commutative7.5%
+-commutative7.5%
*-rgt-identity7.5%
distribute-lft-out7.5%
*-commutative7.5%
associate-*l*7.5%
distribute-lft-out7.5%
+-commutative7.5%
*-commutative7.5%
unpow27.5%
Simplified7.5%
Taylor expanded in im around 0 5.9%
associate-+l+5.9%
flip-+68.6%
*-commutative68.6%
associate-*l*68.6%
*-commutative68.6%
associate-*l*68.6%
*-commutative68.6%
associate-*l*68.6%
Applied egg-rr68.6%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
+-commutative100.0%
+-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out100.0%
+-commutative100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in im around 0 80.0%
Taylor expanded in re around inf 80.0%
unpow280.0%
*-commutative80.0%
associate-*r*80.0%
*-commutative80.0%
Simplified80.0%
Final simplification71.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))) (t_1 (- -1.0 t_0)))
(if (<= re -550.0)
(* -0.5 (* im im))
(if (<= re 1.35e+154)
(/ (+ (* re re) (* (+ 1.0 t_0) t_1)) (+ re t_1))
t_0))))
double code(double re, double im) {
double t_0 = re * (re * 0.5);
double t_1 = -1.0 - t_0;
double tmp;
if (re <= -550.0) {
tmp = -0.5 * (im * im);
} else if (re <= 1.35e+154) {
tmp = ((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1);
} else {
tmp = 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) :: t_1
real(8) :: tmp
t_0 = re * (re * 0.5d0)
t_1 = (-1.0d0) - t_0
if (re <= (-550.0d0)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 1.35d+154) then
tmp = ((re * re) + ((1.0d0 + t_0) * t_1)) / (re + t_1)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (re * 0.5);
double t_1 = -1.0 - t_0;
double tmp;
if (re <= -550.0) {
tmp = -0.5 * (im * im);
} else if (re <= 1.35e+154) {
tmp = ((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1);
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = re * (re * 0.5) t_1 = -1.0 - t_0 tmp = 0 if re <= -550.0: tmp = -0.5 * (im * im) elif re <= 1.35e+154: tmp = ((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(re * Float64(re * 0.5)) t_1 = Float64(-1.0 - t_0) tmp = 0.0 if (re <= -550.0) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 1.35e+154) tmp = Float64(Float64(Float64(re * re) + Float64(Float64(1.0 + t_0) * t_1)) / Float64(re + t_1)); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = re * (re * 0.5); t_1 = -1.0 - t_0; tmp = 0.0; if (re <= -550.0) tmp = -0.5 * (im * im); elseif (re <= 1.35e+154) tmp = ((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 - t$95$0), $MachinePrecision]}, If[LessEqual[re, -550.0], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[(N[(re * re), $MachinePrecision] + N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(re + t$95$1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(re \cdot 0.5\right)\\
t_1 := -1 - t_0\\
\mathbf{if}\;re \leq -550:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{re \cdot re + \left(1 + t_0\right) \cdot t_1}{re + t_1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if re < -550Initial program 100.0%
Taylor expanded in im around 0 75.8%
unpow275.8%
Simplified75.8%
Taylor expanded in im around inf 75.8%
unpow275.8%
*-commutative75.8%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around 0 31.0%
unpow231.0%
Simplified31.0%
if -550 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in re around 0 78.9%
+-commutative78.9%
+-commutative78.9%
*-rgt-identity78.9%
distribute-lft-out78.9%
*-commutative78.9%
associate-*l*78.9%
distribute-lft-out78.9%
+-commutative78.9%
*-commutative78.9%
unpow278.9%
Simplified78.9%
Taylor expanded in im around 0 38.6%
associate-+l+38.6%
flip-+46.7%
*-commutative46.7%
associate-*l*46.7%
*-commutative46.7%
associate-*l*46.7%
*-commutative46.7%
associate-*l*46.7%
Applied egg-rr46.7%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
+-commutative100.0%
+-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out100.0%
+-commutative100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in im around 0 80.0%
Taylor expanded in re around inf 80.0%
unpow280.0%
*-commutative80.0%
associate-*r*80.0%
*-commutative80.0%
Simplified80.0%
Final simplification45.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.5 (* im im))) (t_1 (* re (* re 0.5))))
(if (<= re -480.0)
t_0
(if (<= re 3e+19)
(+ (* 0.5 (* re re)) (+ re 1.0))
(if (or (<= re 5e+193) (not (<= re 2e+245)))
(* (+ 1.0 t_0) t_1)
t_1)))))
double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double t_1 = re * (re * 0.5);
double tmp;
if (re <= -480.0) {
tmp = t_0;
} else if (re <= 3e+19) {
tmp = (0.5 * (re * re)) + (re + 1.0);
} else if ((re <= 5e+193) || !(re <= 2e+245)) {
tmp = (1.0 + t_0) * t_1;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-0.5d0) * (im * im)
t_1 = re * (re * 0.5d0)
if (re <= (-480.0d0)) then
tmp = t_0
else if (re <= 3d+19) then
tmp = (0.5d0 * (re * re)) + (re + 1.0d0)
else if ((re <= 5d+193) .or. (.not. (re <= 2d+245))) then
tmp = (1.0d0 + t_0) * t_1
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double t_1 = re * (re * 0.5);
double tmp;
if (re <= -480.0) {
tmp = t_0;
} else if (re <= 3e+19) {
tmp = (0.5 * (re * re)) + (re + 1.0);
} else if ((re <= 5e+193) || !(re <= 2e+245)) {
tmp = (1.0 + t_0) * t_1;
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = -0.5 * (im * im) t_1 = re * (re * 0.5) tmp = 0 if re <= -480.0: tmp = t_0 elif re <= 3e+19: tmp = (0.5 * (re * re)) + (re + 1.0) elif (re <= 5e+193) or not (re <= 2e+245): tmp = (1.0 + t_0) * t_1 else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(-0.5 * Float64(im * im)) t_1 = Float64(re * Float64(re * 0.5)) tmp = 0.0 if (re <= -480.0) tmp = t_0; elseif (re <= 3e+19) tmp = Float64(Float64(0.5 * Float64(re * re)) + Float64(re + 1.0)); elseif ((re <= 5e+193) || !(re <= 2e+245)) tmp = Float64(Float64(1.0 + t_0) * t_1); else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = -0.5 * (im * im); t_1 = re * (re * 0.5); tmp = 0.0; if (re <= -480.0) tmp = t_0; elseif (re <= 3e+19) tmp = (0.5 * (re * re)) + (re + 1.0); elseif ((re <= 5e+193) || ~((re <= 2e+245))) tmp = (1.0 + t_0) * t_1; else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -480.0], t$95$0, If[LessEqual[re, 3e+19], N[(N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 5e+193], N[Not[LessEqual[re, 2e+245]], $MachinePrecision]], N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(im \cdot im\right)\\
t_1 := re \cdot \left(re \cdot 0.5\right)\\
\mathbf{if}\;re \leq -480:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 3 \cdot 10^{+19}:\\
\;\;\;\;0.5 \cdot \left(re \cdot re\right) + \left(re + 1\right)\\
\mathbf{elif}\;re \leq 5 \cdot 10^{+193} \lor \neg \left(re \leq 2 \cdot 10^{+245}\right):\\
\;\;\;\;\left(1 + t_0\right) \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if re < -480Initial program 100.0%
Taylor expanded in im around 0 75.8%
unpow275.8%
Simplified75.8%
Taylor expanded in im around inf 75.8%
unpow275.8%
*-commutative75.8%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around 0 31.0%
unpow231.0%
Simplified31.0%
if -480 < re < 3e19Initial program 100.0%
Taylor expanded in re around 0 95.1%
+-commutative95.1%
+-commutative95.1%
*-rgt-identity95.1%
distribute-lft-out95.1%
*-commutative95.1%
associate-*l*95.1%
distribute-lft-out95.1%
+-commutative95.1%
*-commutative95.1%
unpow295.1%
Simplified95.1%
Taylor expanded in im around 0 46.1%
if 3e19 < re < 4.99999999999999972e193 or 2.00000000000000009e245 < re Initial program 100.0%
Taylor expanded in re around 0 32.6%
+-commutative32.6%
+-commutative32.6%
*-rgt-identity32.6%
distribute-lft-out32.6%
*-commutative32.6%
associate-*l*32.6%
distribute-lft-out32.6%
+-commutative32.6%
*-commutative32.6%
unpow232.6%
Simplified32.6%
Taylor expanded in im around 0 46.9%
unpow288.4%
Simplified46.9%
Taylor expanded in re around inf 46.9%
unpow222.0%
*-commutative22.0%
associate-*r*22.0%
*-commutative22.0%
Simplified46.9%
if 4.99999999999999972e193 < re < 2.00000000000000009e245Initial program 100.0%
Taylor expanded in re around 0 100.0%
+-commutative100.0%
+-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out100.0%
+-commutative100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around inf 100.0%
unpow2100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification44.0%
(FPCore (re im) :precision binary64 (if (<= re -1.08e-7) (* -0.5 (* im im)) (if (<= re 6.3e+32) (+ re 1.0) (* -0.5 (* re (* im im))))))
double code(double re, double im) {
double tmp;
if (re <= -1.08e-7) {
tmp = -0.5 * (im * im);
} else if (re <= 6.3e+32) {
tmp = re + 1.0;
} else {
tmp = -0.5 * (re * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-1.08d-7)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 6.3d+32) then
tmp = re + 1.0d0
else
tmp = (-0.5d0) * (re * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.08e-7) {
tmp = -0.5 * (im * im);
} else if (re <= 6.3e+32) {
tmp = re + 1.0;
} else {
tmp = -0.5 * (re * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.08e-7: tmp = -0.5 * (im * im) elif re <= 6.3e+32: tmp = re + 1.0 else: tmp = -0.5 * (re * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.08e-7) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 6.3e+32) tmp = Float64(re + 1.0); else tmp = Float64(-0.5 * Float64(re * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.08e-7) tmp = -0.5 * (im * im); elseif (re <= 6.3e+32) tmp = re + 1.0; else tmp = -0.5 * (re * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.08e-7], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 6.3e+32], N[(re + 1.0), $MachinePrecision], N[(-0.5 * N[(re * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.08 \cdot 10^{-7}:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 6.3 \cdot 10^{+32}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -1.08000000000000001e-7Initial program 100.0%
Taylor expanded in im around 0 75.0%
unpow275.0%
Simplified75.0%
Taylor expanded in im around inf 73.6%
unpow273.6%
*-commutative73.6%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in re around 0 30.1%
unpow230.1%
Simplified30.1%
if -1.08000000000000001e-7 < re < 6.3000000000000002e32Initial program 100.0%
Taylor expanded in re around 0 93.5%
*-rgt-identity93.5%
distribute-lft-out93.5%
Simplified93.5%
Taylor expanded in im around 0 45.8%
if 6.3000000000000002e32 < re Initial program 100.0%
Taylor expanded in re around 0 5.1%
*-rgt-identity5.1%
distribute-lft-out5.1%
Simplified5.1%
Taylor expanded in im around 0 20.0%
unpow279.2%
Simplified20.0%
Taylor expanded in im around inf 17.9%
+-commutative17.9%
*-commutative17.9%
unpow217.9%
Simplified17.9%
Taylor expanded in re around inf 17.9%
unpow217.9%
Simplified17.9%
Final simplification36.4%
(FPCore (re im) :precision binary64 (if (<= re -480.0) (* -0.5 (* im im)) (+ (* 0.5 (* re re)) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if (re <= -480.0) {
tmp = -0.5 * (im * im);
} else {
tmp = (0.5 * (re * re)) + (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 <= (-480.0d0)) then
tmp = (-0.5d0) * (im * im)
else
tmp = (0.5d0 * (re * re)) + (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -480.0) {
tmp = -0.5 * (im * im);
} else {
tmp = (0.5 * (re * re)) + (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -480.0: tmp = -0.5 * (im * im) else: tmp = (0.5 * (re * re)) + (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if (re <= -480.0) tmp = Float64(-0.5 * Float64(im * im)); else tmp = Float64(Float64(0.5 * Float64(re * re)) + Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -480.0) tmp = -0.5 * (im * im); else tmp = (0.5 * (re * re)) + (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -480.0], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -480:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot re\right) + \left(re + 1\right)\\
\end{array}
\end{array}
if re < -480Initial program 100.0%
Taylor expanded in im around 0 75.8%
unpow275.8%
Simplified75.8%
Taylor expanded in im around inf 75.8%
unpow275.8%
*-commutative75.8%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around 0 31.0%
unpow231.0%
Simplified31.0%
if -480 < re Initial program 100.0%
Taylor expanded in re around 0 81.1%
+-commutative81.1%
+-commutative81.1%
*-rgt-identity81.1%
distribute-lft-out81.1%
*-commutative81.1%
associate-*l*81.1%
distribute-lft-out81.1%
+-commutative81.1%
*-commutative81.1%
unpow281.1%
Simplified81.1%
Taylor expanded in im around 0 42.9%
Final simplification39.8%
(FPCore (re im) :precision binary64 (if (<= re -1.08e-7) (* -0.5 (* im im)) (if (<= re 4.2e-5) (+ re 1.0) (* re (* re 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -1.08e-7) {
tmp = -0.5 * (im * im);
} else if (re <= 4.2e-5) {
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.08d-7)) then
tmp = (-0.5d0) * (im * im)
else if (re <= 4.2d-5) 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.08e-7) {
tmp = -0.5 * (im * im);
} else if (re <= 4.2e-5) {
tmp = re + 1.0;
} else {
tmp = re * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.08e-7: tmp = -0.5 * (im * im) elif re <= 4.2e-5: tmp = re + 1.0 else: tmp = re * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.08e-7) tmp = Float64(-0.5 * Float64(im * im)); elseif (re <= 4.2e-5) 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.08e-7) tmp = -0.5 * (im * im); elseif (re <= 4.2e-5) tmp = re + 1.0; else tmp = re * (re * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.08e-7], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 4.2e-5], N[(re + 1.0), $MachinePrecision], N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.08 \cdot 10^{-7}:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{elif}\;re \leq 4.2 \cdot 10^{-5}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -1.08000000000000001e-7Initial program 100.0%
Taylor expanded in im around 0 75.0%
unpow275.0%
Simplified75.0%
Taylor expanded in im around inf 73.6%
unpow273.6%
*-commutative73.6%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in re around 0 30.1%
unpow230.1%
Simplified30.1%
if -1.08000000000000001e-7 < re < 4.19999999999999977e-5Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in im around 0 49.1%
if 4.19999999999999977e-5 < re Initial program 100.0%
Taylor expanded in re around 0 39.8%
+-commutative39.8%
+-commutative39.8%
*-rgt-identity39.8%
distribute-lft-out39.8%
*-commutative39.8%
associate-*l*39.8%
distribute-lft-out39.8%
+-commutative39.8%
*-commutative39.8%
unpow239.8%
Simplified39.8%
Taylor expanded in im around 0 30.5%
Taylor expanded in re around inf 30.5%
unpow230.5%
*-commutative30.5%
associate-*r*30.5%
*-commutative30.5%
Simplified30.5%
Final simplification39.8%
(FPCore (re im) :precision binary64 (if (<= re -1.08e-7) (* -0.5 (* im im)) (+ re 1.0)))
double code(double re, double im) {
double tmp;
if (re <= -1.08e-7) {
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 <= (-1.08d-7)) 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 <= -1.08e-7) {
tmp = -0.5 * (im * im);
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.08e-7: tmp = -0.5 * (im * im) else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if (re <= -1.08e-7) 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 <= -1.08e-7) tmp = -0.5 * (im * im); else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.08e-7], N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.08 \cdot 10^{-7}:\\
\;\;\;\;-0.5 \cdot \left(im \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if re < -1.08000000000000001e-7Initial program 100.0%
Taylor expanded in im around 0 75.0%
unpow275.0%
Simplified75.0%
Taylor expanded in im around inf 73.6%
unpow273.6%
*-commutative73.6%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in re around 0 30.1%
unpow230.1%
Simplified30.1%
if -1.08000000000000001e-7 < re Initial program 100.0%
Taylor expanded in re around 0 70.9%
*-rgt-identity70.9%
distribute-lft-out70.9%
Simplified70.9%
Taylor expanded in im around 0 35.1%
Final simplification33.8%
(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 53.0%
*-rgt-identity53.0%
distribute-lft-out53.0%
Simplified53.0%
Taylor expanded in im around 0 26.4%
Final simplification26.4%
(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 52.5%
Taylor expanded in im around 0 26.3%
Final simplification26.3%
herbie shell --seed 2023240
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))