
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Initial program 99.6%
Final simplification99.6%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 1.0) (not (<= (exp re) 1.5))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 1.0) || !(exp(re) <= 1.5)) {
tmp = exp(re) * im;
} else {
tmp = sin(im);
}
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) .or. (.not. (exp(re) <= 1.5d0))) then
tmp = exp(re) * im
else
tmp = sin(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 1.0) || !(Math.exp(re) <= 1.5)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 1.0) or not (math.exp(re) <= 1.5): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 1.0) || !(exp(re) <= 1.5)) tmp = Float64(exp(re) * im); else tmp = sin(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 1.0) || ~((exp(re) <= 1.5))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.5]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1 \lor \neg \left(e^{re} \leq 1.5\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 1.5 < (exp.f64 re) Initial program 99.6%
Taylor expanded in im around 0 68.9%
if 1 < (exp.f64 re) < 1.5Initial program 99.6%
Taylor expanded in re around 0 52.1%
Final simplification68.9%
(FPCore (re im)
:precision binary64
(if (<= re -280.0)
0.0
(if (<= re 2.2e-18)
(* (sin im) (+ (+ re 1.0) (* 0.5 (* re re))))
(if (<= re 1.9e+154) (* (exp re) im) (* (sin im) (* re (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if (re <= -280.0) {
tmp = 0.0;
} else if (re <= 2.2e-18) {
tmp = sin(im) * ((re + 1.0) + (0.5 * (re * re)));
} else if (re <= 1.9e+154) {
tmp = exp(re) * im;
} else {
tmp = sin(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 <= (-280.0d0)) then
tmp = 0.0d0
else if (re <= 2.2d-18) then
tmp = sin(im) * ((re + 1.0d0) + (0.5d0 * (re * re)))
else if (re <= 1.9d+154) then
tmp = exp(re) * im
else
tmp = sin(im) * (re * (re * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -280.0) {
tmp = 0.0;
} else if (re <= 2.2e-18) {
tmp = Math.sin(im) * ((re + 1.0) + (0.5 * (re * re)));
} else if (re <= 1.9e+154) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re * (re * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -280.0: tmp = 0.0 elif re <= 2.2e-18: tmp = math.sin(im) * ((re + 1.0) + (0.5 * (re * re))) elif re <= 1.9e+154: tmp = math.exp(re) * im else: tmp = math.sin(im) * (re * (re * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -280.0) tmp = 0.0; elseif (re <= 2.2e-18) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re)))); elseif (re <= 1.9e+154) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(re * Float64(re * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -280.0) tmp = 0.0; elseif (re <= 2.2e-18) tmp = sin(im) * ((re + 1.0) + (0.5 * (re * re))); elseif (re <= 1.9e+154) tmp = exp(re) * im; else tmp = sin(im) * (re * (re * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -280.0], 0.0, If[LessEqual[re, 2.2e-18], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.9e+154], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -280:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -280Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
log1p-udef100.0%
add-exp-log100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
if -280 < re < 2.1999999999999998e-18Initial program 100.0%
Taylor expanded in re around 0 97.8%
*-rgt-identity97.8%
*-commutative97.8%
associate-*l*97.8%
distribute-lft-out97.8%
distribute-lft-out97.8%
associate-+l+97.8%
+-commutative97.8%
*-commutative97.8%
unpow297.8%
Simplified97.8%
if 2.1999999999999998e-18 < re < 1.8999999999999999e154Initial program 97.2%
Taylor expanded in im around 0 76.7%
if 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out100.0%
distribute-lft-out100.0%
associate-+l+100.0%
+-commutative100.0%
*-commutative100.0%
unpow2100.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 simplification95.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -3.6e-6)
t_0
(if (<= re 2.2e-18)
(* (sin im) (+ re 1.0))
(if (<= re 1.9e+154) t_0 (* (sin im) (* re (* re 0.5))))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -3.6e-6) {
tmp = t_0;
} else if (re <= 2.2e-18) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 1.9e+154) {
tmp = t_0;
} else {
tmp = sin(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) :: t_0
real(8) :: tmp
t_0 = exp(re) * im
if (re <= (-3.6d-6)) then
tmp = t_0
else if (re <= 2.2d-18) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 1.9d+154) then
tmp = t_0
else
tmp = sin(im) * (re * (re * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * im;
double tmp;
if (re <= -3.6e-6) {
tmp = t_0;
} else if (re <= 2.2e-18) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 1.9e+154) {
tmp = t_0;
} else {
tmp = Math.sin(im) * (re * (re * 0.5));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -3.6e-6: tmp = t_0 elif re <= 2.2e-18: tmp = math.sin(im) * (re + 1.0) elif re <= 1.9e+154: tmp = t_0 else: tmp = math.sin(im) * (re * (re * 0.5)) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -3.6e-6) tmp = t_0; elseif (re <= 2.2e-18) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 1.9e+154) tmp = t_0; else tmp = Float64(sin(im) * Float64(re * Float64(re * 0.5))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -3.6e-6) tmp = t_0; elseif (re <= 2.2e-18) tmp = sin(im) * (re + 1.0); elseif (re <= 1.9e+154) tmp = t_0; else tmp = sin(im) * (re * (re * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -3.6e-6], t$95$0, If[LessEqual[re, 2.2e-18], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.9e+154], t$95$0, N[(N[Sin[im], $MachinePrecision] * N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -3.6 \cdot 10^{-6}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -3.59999999999999984e-6 or 2.1999999999999998e-18 < re < 1.8999999999999999e154Initial program 99.1%
Taylor expanded in im around 0 88.8%
if -3.59999999999999984e-6 < re < 2.1999999999999998e-18Initial program 100.0%
Taylor expanded in re around 0 100.0%
+-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out100.0%
Simplified100.0%
if 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-out100.0%
distribute-lft-out100.0%
associate-+l+100.0%
+-commutative100.0%
*-commutative100.0%
unpow2100.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 simplification95.4%
(FPCore (re im) :precision binary64 (if (or (<= re -3.6e-6) (not (<= re 2.2e-18))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -3.6e-6) || !(re <= 2.2e-18)) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * (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 <= (-3.6d-6)) .or. (.not. (re <= 2.2d-18))) then
tmp = exp(re) * im
else
tmp = sin(im) * (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -3.6e-6) || !(re <= 2.2e-18)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -3.6e-6) or not (re <= 2.2e-18): tmp = math.exp(re) * im else: tmp = math.sin(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -3.6e-6) || !(re <= 2.2e-18)) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -3.6e-6) || ~((re <= 2.2e-18))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -3.6e-6], N[Not[LessEqual[re, 2.2e-18]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.6 \cdot 10^{-6} \lor \neg \left(re \leq 2.2 \cdot 10^{-18}\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -3.59999999999999984e-6 or 2.1999999999999998e-18 < re Initial program 99.3%
Taylor expanded in im around 0 86.4%
if -3.59999999999999984e-6 < re < 2.1999999999999998e-18Initial program 100.0%
Taylor expanded in re around 0 100.0%
+-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out100.0%
Simplified100.0%
Final simplification93.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))) (t_1 (- -1.0 t_0)))
(if (<= re -280.0)
0.0
(if (<= re 1.35e+25)
(sin im)
(if (<= re 2.05e+151)
(* im (/ (+ (* re re) (* (+ 1.0 t_0) t_1)) (+ re t_1)))
(* (* re re) (* im 0.5)))))))
double code(double re, double im) {
double t_0 = re * (re * 0.5);
double t_1 = -1.0 - t_0;
double tmp;
if (re <= -280.0) {
tmp = 0.0;
} else if (re <= 1.35e+25) {
tmp = sin(im);
} else if (re <= 2.05e+151) {
tmp = im * (((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1));
} else {
tmp = (re * re) * (im * 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) :: t_1
real(8) :: tmp
t_0 = re * (re * 0.5d0)
t_1 = (-1.0d0) - t_0
if (re <= (-280.0d0)) then
tmp = 0.0d0
else if (re <= 1.35d+25) then
tmp = sin(im)
else if (re <= 2.05d+151) then
tmp = im * (((re * re) + ((1.0d0 + t_0) * t_1)) / (re + t_1))
else
tmp = (re * re) * (im * 0.5d0)
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 <= -280.0) {
tmp = 0.0;
} else if (re <= 1.35e+25) {
tmp = Math.sin(im);
} else if (re <= 2.05e+151) {
tmp = im * (((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1));
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
def code(re, im): t_0 = re * (re * 0.5) t_1 = -1.0 - t_0 tmp = 0 if re <= -280.0: tmp = 0.0 elif re <= 1.35e+25: tmp = math.sin(im) elif re <= 2.05e+151: tmp = im * (((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1)) else: tmp = (re * re) * (im * 0.5) 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 <= -280.0) tmp = 0.0; elseif (re <= 1.35e+25) tmp = sin(im); elseif (re <= 2.05e+151) tmp = Float64(im * Float64(Float64(Float64(re * re) + Float64(Float64(1.0 + t_0) * t_1)) / Float64(re + t_1))); else tmp = Float64(Float64(re * re) * Float64(im * 0.5)); 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 <= -280.0) tmp = 0.0; elseif (re <= 1.35e+25) tmp = sin(im); elseif (re <= 2.05e+151) tmp = im * (((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1)); else tmp = (re * re) * (im * 0.5); 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, -280.0], 0.0, If[LessEqual[re, 1.35e+25], N[Sin[im], $MachinePrecision], If[LessEqual[re, 2.05e+151], N[(im * 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]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\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 -280:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+25}:\\
\;\;\;\;\sin im\\
\mathbf{elif}\;re \leq 2.05 \cdot 10^{+151}:\\
\;\;\;\;im \cdot \frac{re \cdot re + \left(1 + t_0\right) \cdot t_1}{re + t_1}\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -280Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
log1p-udef100.0%
add-exp-log100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
if -280 < re < 1.35e25Initial program 99.3%
Taylor expanded in re around 0 92.4%
if 1.35e25 < re < 2.0499999999999999e151Initial program 100.0%
Taylor expanded in re around 0 4.9%
*-rgt-identity4.9%
*-commutative4.9%
associate-*l*4.9%
distribute-lft-out4.9%
distribute-lft-out4.9%
associate-+l+4.9%
+-commutative4.9%
*-commutative4.9%
unpow24.9%
Simplified4.9%
associate-+l+4.9%
flip-+62.9%
*-commutative62.9%
associate-*l*62.9%
*-commutative62.9%
associate-*l*62.9%
*-commutative62.9%
associate-*l*62.9%
Applied egg-rr62.9%
Taylor expanded in im around 0 55.3%
if 2.0499999999999999e151 < re Initial program 100.0%
Taylor expanded in re around 0 96.6%
*-rgt-identity96.6%
*-commutative96.6%
associate-*l*96.6%
distribute-lft-out96.6%
distribute-lft-out96.6%
associate-+l+96.6%
+-commutative96.6%
*-commutative96.6%
unpow296.6%
Simplified96.6%
Taylor expanded in im around 0 76.9%
Taylor expanded in re around inf 76.9%
*-commutative76.9%
associate-*r*76.9%
*-commutative76.9%
unpow276.9%
Simplified76.9%
Final simplification89.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))) (t_1 (- -1.0 t_0)))
(if (<= re -62.0)
0.0
(if (<= re 2.05e+151)
(* im (/ (+ (* re re) (* (+ 1.0 t_0) t_1)) (+ re t_1)))
(* (* re re) (* im 0.5))))))
double code(double re, double im) {
double t_0 = re * (re * 0.5);
double t_1 = -1.0 - t_0;
double tmp;
if (re <= -62.0) {
tmp = 0.0;
} else if (re <= 2.05e+151) {
tmp = im * (((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1));
} else {
tmp = (re * re) * (im * 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) :: t_1
real(8) :: tmp
t_0 = re * (re * 0.5d0)
t_1 = (-1.0d0) - t_0
if (re <= (-62.0d0)) then
tmp = 0.0d0
else if (re <= 2.05d+151) then
tmp = im * (((re * re) + ((1.0d0 + t_0) * t_1)) / (re + t_1))
else
tmp = (re * re) * (im * 0.5d0)
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 <= -62.0) {
tmp = 0.0;
} else if (re <= 2.05e+151) {
tmp = im * (((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1));
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
def code(re, im): t_0 = re * (re * 0.5) t_1 = -1.0 - t_0 tmp = 0 if re <= -62.0: tmp = 0.0 elif re <= 2.05e+151: tmp = im * (((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1)) else: tmp = (re * re) * (im * 0.5) 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 <= -62.0) tmp = 0.0; elseif (re <= 2.05e+151) tmp = Float64(im * Float64(Float64(Float64(re * re) + Float64(Float64(1.0 + t_0) * t_1)) / Float64(re + t_1))); else tmp = Float64(Float64(re * re) * Float64(im * 0.5)); 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 <= -62.0) tmp = 0.0; elseif (re <= 2.05e+151) tmp = im * (((re * re) + ((1.0 + t_0) * t_1)) / (re + t_1)); else tmp = (re * re) * (im * 0.5); 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, -62.0], 0.0, If[LessEqual[re, 2.05e+151], N[(im * 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]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]]]]]
\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 -62:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 2.05 \cdot 10^{+151}:\\
\;\;\;\;im \cdot \frac{re \cdot re + \left(1 + t_0\right) \cdot t_1}{re + t_1}\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -62Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.5%
log1p-udef98.5%
add-exp-log98.5%
Applied egg-rr98.5%
Taylor expanded in im around 0 98.5%
if -62 < re < 2.0499999999999999e151Initial program 99.4%
Taylor expanded in re around 0 80.6%
*-rgt-identity80.6%
*-commutative80.6%
associate-*l*80.6%
distribute-lft-out80.6%
distribute-lft-out80.6%
associate-+l+80.6%
+-commutative80.6%
*-commutative80.6%
unpow280.6%
Simplified80.6%
associate-+l+80.6%
flip-+89.7%
*-commutative89.7%
associate-*l*89.7%
*-commutative89.7%
associate-*l*89.7%
*-commutative89.7%
associate-*l*89.7%
Applied egg-rr89.7%
Taylor expanded in im around 0 50.0%
if 2.0499999999999999e151 < re Initial program 100.0%
Taylor expanded in re around 0 96.6%
*-rgt-identity96.6%
*-commutative96.6%
associate-*l*96.6%
distribute-lft-out96.6%
distribute-lft-out96.6%
associate-+l+96.6%
+-commutative96.6%
*-commutative96.6%
unpow296.6%
Simplified96.6%
Taylor expanded in im around 0 76.9%
Taylor expanded in re around inf 76.9%
*-commutative76.9%
associate-*r*76.9%
*-commutative76.9%
unpow276.9%
Simplified76.9%
Final simplification65.1%
(FPCore (re im) :precision binary64 (if (<= re -29.5) 0.0 (+ (* (* re re) (* im 0.5)) (+ im (* re im)))))
double code(double re, double im) {
double tmp;
if (re <= -29.5) {
tmp = 0.0;
} else {
tmp = ((re * re) * (im * 0.5)) + (im + (re * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-29.5d0)) then
tmp = 0.0d0
else
tmp = ((re * re) * (im * 0.5d0)) + (im + (re * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -29.5) {
tmp = 0.0;
} else {
tmp = ((re * re) * (im * 0.5)) + (im + (re * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -29.5: tmp = 0.0 else: tmp = ((re * re) * (im * 0.5)) + (im + (re * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= -29.5) tmp = 0.0; else tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) + Float64(im + Float64(re * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -29.5) tmp = 0.0; else tmp = ((re * re) * (im * 0.5)) + (im + (re * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -29.5], 0.0, N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] + N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -29.5:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) + \left(im + re \cdot im\right)\\
\end{array}
\end{array}
if re < -29.5Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.5%
log1p-udef98.5%
add-exp-log98.5%
Applied egg-rr98.5%
Taylor expanded in im around 0 98.5%
if -29.5 < re Initial program 99.5%
Taylor expanded in re around 0 82.8%
*-rgt-identity82.8%
*-commutative82.8%
associate-*l*82.8%
distribute-lft-out82.8%
distribute-lft-out82.8%
associate-+l+82.8%
+-commutative82.8%
*-commutative82.8%
unpow282.8%
Simplified82.8%
Taylor expanded in im around 0 48.2%
distribute-lft-in48.2%
+-commutative48.2%
distribute-rgt-in48.2%
*-un-lft-identity48.2%
associate-*r*48.2%
Applied egg-rr48.2%
Final simplification61.0%
(FPCore (re im) :precision binary64 (if (<= re -45.0) 0.0 (* im (+ (+ re 1.0) (* 0.5 (* re re))))))
double code(double re, double im) {
double tmp;
if (re <= -45.0) {
tmp = 0.0;
} else {
tmp = im * ((re + 1.0) + (0.5 * (re * re)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-45.0d0)) then
tmp = 0.0d0
else
tmp = im * ((re + 1.0d0) + (0.5d0 * (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -45.0) {
tmp = 0.0;
} else {
tmp = im * ((re + 1.0) + (0.5 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -45.0: tmp = 0.0 else: tmp = im * ((re + 1.0) + (0.5 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -45.0) tmp = 0.0; else tmp = Float64(im * Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -45.0) tmp = 0.0; else tmp = im * ((re + 1.0) + (0.5 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -45.0], 0.0, N[(im * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -45:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < -45Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.5%
log1p-udef98.5%
add-exp-log98.5%
Applied egg-rr98.5%
Taylor expanded in im around 0 98.5%
if -45 < re Initial program 99.5%
Taylor expanded in re around 0 82.8%
*-rgt-identity82.8%
*-commutative82.8%
associate-*l*82.8%
distribute-lft-out82.8%
distribute-lft-out82.8%
associate-+l+82.8%
+-commutative82.8%
*-commutative82.8%
unpow282.8%
Simplified82.8%
Taylor expanded in im around 0 48.2%
Final simplification61.0%
(FPCore (re im) :precision binary64 (if (<= re -1.0) 0.0 (if (<= re 0.7) (+ im (* re im)) (* re (* re (* im 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = 0.0;
} else if (re <= 0.7) {
tmp = im + (re * im);
} else {
tmp = re * (re * (im * 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.0d0)) then
tmp = 0.0d0
else if (re <= 0.7d0) then
tmp = im + (re * im)
else
tmp = re * (re * (im * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = 0.0;
} else if (re <= 0.7) {
tmp = im + (re * im);
} else {
tmp = re * (re * (im * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.0: tmp = 0.0 elif re <= 0.7: tmp = im + (re * im) else: tmp = re * (re * (im * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.0) tmp = 0.0; elseif (re <= 0.7) tmp = Float64(im + Float64(re * im)); else tmp = Float64(re * Float64(re * Float64(im * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.0) tmp = 0.0; elseif (re <= 0.7) tmp = im + (re * im); else tmp = re * (re * (im * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.0], 0.0, If[LessEqual[re, 0.7], N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 0.7:\\
\;\;\;\;im + re \cdot im\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.5%
log1p-udef98.5%
add-exp-log98.5%
Applied egg-rr98.5%
Taylor expanded in im around 0 98.5%
if -1 < re < 0.69999999999999996Initial program 100.0%
Taylor expanded in im around 0 51.6%
Taylor expanded in re around 0 50.3%
if 0.69999999999999996 < re Initial program 98.3%
Taylor expanded in re around 0 47.0%
*-rgt-identity47.0%
*-commutative47.0%
associate-*l*47.0%
distribute-lft-out47.0%
distribute-lft-out47.0%
associate-+l+47.0%
+-commutative47.0%
*-commutative47.0%
unpow247.0%
Simplified47.0%
Taylor expanded in im around 0 42.1%
Taylor expanded in re around inf 42.1%
*-commutative42.1%
associate-*r*42.1%
unpow242.1%
associate-*l*32.1%
*-commutative32.1%
Simplified32.1%
Final simplification58.5%
(FPCore (re im) :precision binary64 (if (<= re -1.4) 0.0 (if (<= re 0.7) (+ im (* re im)) (* (* re re) (* im 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -1.4) {
tmp = 0.0;
} else if (re <= 0.7) {
tmp = im + (re * im);
} else {
tmp = (re * re) * (im * 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.4d0)) then
tmp = 0.0d0
else if (re <= 0.7d0) then
tmp = im + (re * im)
else
tmp = (re * re) * (im * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.4) {
tmp = 0.0;
} else if (re <= 0.7) {
tmp = im + (re * im);
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.4: tmp = 0.0 elif re <= 0.7: tmp = im + (re * im) else: tmp = (re * re) * (im * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.4) tmp = 0.0; elseif (re <= 0.7) tmp = Float64(im + Float64(re * im)); else tmp = Float64(Float64(re * re) * Float64(im * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.4) tmp = 0.0; elseif (re <= 0.7) tmp = im + (re * im); else tmp = (re * re) * (im * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.4], 0.0, If[LessEqual[re, 0.7], N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.4:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 0.7:\\
\;\;\;\;im + re \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -1.3999999999999999Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.5%
log1p-udef98.5%
add-exp-log98.5%
Applied egg-rr98.5%
Taylor expanded in im around 0 98.5%
if -1.3999999999999999 < re < 0.69999999999999996Initial program 100.0%
Taylor expanded in im around 0 51.6%
Taylor expanded in re around 0 50.3%
if 0.69999999999999996 < re Initial program 98.3%
Taylor expanded in re around 0 47.0%
*-rgt-identity47.0%
*-commutative47.0%
associate-*l*47.0%
distribute-lft-out47.0%
distribute-lft-out47.0%
associate-+l+47.0%
+-commutative47.0%
*-commutative47.0%
unpow247.0%
Simplified47.0%
Taylor expanded in im around 0 42.1%
Taylor expanded in re around inf 42.1%
*-commutative42.1%
associate-*r*42.1%
*-commutative42.1%
unpow242.1%
Simplified42.1%
Final simplification60.7%
(FPCore (re im) :precision binary64 (if (<= re -100.0) 0.0 (if (<= re 0.7) im (* re im))))
double code(double re, double im) {
double tmp;
if (re <= -100.0) {
tmp = 0.0;
} else if (re <= 0.7) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-100.0d0)) then
tmp = 0.0d0
else if (re <= 0.7d0) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -100.0) {
tmp = 0.0;
} else if (re <= 0.7) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -100.0: tmp = 0.0 elif re <= 0.7: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= -100.0) tmp = 0.0; elseif (re <= 0.7) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -100.0) tmp = 0.0; elseif (re <= 0.7) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -100.0], 0.0, If[LessEqual[re, 0.7], im, N[(re * im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -100:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 0.7:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < -100Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.5%
log1p-udef98.5%
add-exp-log98.5%
Applied egg-rr98.5%
Taylor expanded in im around 0 98.5%
if -100 < re < 0.69999999999999996Initial program 100.0%
Taylor expanded in im around 0 51.6%
Taylor expanded in re around 0 49.6%
if 0.69999999999999996 < re Initial program 98.3%
Taylor expanded in re around 0 4.7%
+-commutative4.7%
*-rgt-identity4.7%
distribute-lft-out4.7%
Simplified4.7%
Taylor expanded in re around inf 4.6%
Taylor expanded in im around 0 23.1%
Final simplification56.1%
(FPCore (re im) :precision binary64 (if (<= re -1.0) 0.0 (+ im (* re im))))
double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = 0.0;
} else {
tmp = im + (re * 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.0d0)) then
tmp = 0.0d0
else
tmp = im + (re * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = 0.0;
} else {
tmp = im + (re * im);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.0: tmp = 0.0 else: tmp = im + (re * im) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.0) tmp = 0.0; else tmp = Float64(im + Float64(re * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.0) tmp = 0.0; else tmp = im + (re * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.0], 0.0, N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;im + re \cdot im\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.5%
log1p-udef98.5%
add-exp-log98.5%
Applied egg-rr98.5%
Taylor expanded in im around 0 98.5%
if -1 < re Initial program 99.5%
Taylor expanded in im around 0 58.8%
Taylor expanded in re around 0 42.2%
Final simplification56.5%
(FPCore (re im) :precision binary64 (if (<= re 0.7) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 0.7) {
tmp = im;
} else {
tmp = re * 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.7d0) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.7) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.7: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 0.7) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.7) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.7], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.7:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 0.69999999999999996Initial program 100.0%
Taylor expanded in im around 0 66.9%
Taylor expanded in re around 0 34.6%
if 0.69999999999999996 < re Initial program 98.3%
Taylor expanded in re around 0 4.7%
+-commutative4.7%
*-rgt-identity4.7%
distribute-lft-out4.7%
Simplified4.7%
Taylor expanded in re around inf 4.6%
Taylor expanded in im around 0 23.1%
Final simplification32.0%
(FPCore (re im) :precision binary64 im)
double code(double re, double im) {
return im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im
end function
public static double code(double re, double im) {
return im;
}
def code(re, im): return im
function code(re, im) return im end
function tmp = code(re, im) tmp = im; end
code[re_, im_] := im
\begin{array}{l}
\\
im
\end{array}
Initial program 99.6%
Taylor expanded in im around 0 68.9%
Taylor expanded in re around 0 27.5%
Final simplification27.5%
herbie shell --seed 2023257
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))