
(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 14 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 100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.99999999999) (not (<= (exp re) 1.2))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.99999999999) || !(exp(re) <= 1.2)) {
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) <= 0.99999999999d0) .or. (.not. (exp(re) <= 1.2d0))) 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) <= 0.99999999999) || !(Math.exp(re) <= 1.2)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.99999999999) or not (math.exp(re) <= 1.2): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.99999999999) || !(exp(re) <= 1.2)) 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) <= 0.99999999999) || ~((exp(re) <= 1.2))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.99999999999], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.2]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99999999999 \lor \neg \left(e^{re} \leq 1.2\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.99999999999 or 1.19999999999999996 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 83.6%
if 0.99999999999 < (exp.f64 re) < 1.19999999999999996Initial program 100.0%
Taylor expanded in re around 0 99.2%
Final simplification90.7%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 5e-15) (not (<= (exp re) 2e+30))) (exp re) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 5e-15) || !(exp(re) <= 2e+30)) {
tmp = exp(re);
} 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) <= 5d-15) .or. (.not. (exp(re) <= 2d+30))) then
tmp = exp(re)
else
tmp = sin(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 5e-15) || !(Math.exp(re) <= 2e+30)) {
tmp = Math.exp(re);
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 5e-15) or not (math.exp(re) <= 2e+30): tmp = math.exp(re) else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 5e-15) || !(exp(re) <= 2e+30)) tmp = exp(re); else tmp = sin(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 5e-15) || ~((exp(re) <= 2e+30))) tmp = exp(re); else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 5e-15], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 2e+30]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 5 \cdot 10^{-15} \lor \neg \left(e^{re} \leq 2 \cdot 10^{+30}\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 4.99999999999999999e-15 or 2e30 < (exp.f64 re) Initial program 100.0%
add-exp-log56.1%
prod-exp56.0%
Applied egg-rr56.0%
Taylor expanded in re around inf 78.9%
if 4.99999999999999999e-15 < (exp.f64 re) < 2e30Initial program 100.0%
Taylor expanded in re around 0 95.7%
Final simplification87.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ 1.0 (* re (+ 1.0 (* re 0.5))))) (t_1 (* (sin im) t_0)))
(if (<= re -25.0)
(exp re)
(if (<= re 0.0295)
t_1
(if (<= re 4.7e+24)
(* (exp re) im)
(if (<= re 1.4e+89)
(* t_0 (+ im (* -0.16666666666666666 (pow im 3.0))))
(if (<= re 1.14e+154) (exp re) t_1)))))))
double code(double re, double im) {
double t_0 = 1.0 + (re * (1.0 + (re * 0.5)));
double t_1 = sin(im) * t_0;
double tmp;
if (re <= -25.0) {
tmp = exp(re);
} else if (re <= 0.0295) {
tmp = t_1;
} else if (re <= 4.7e+24) {
tmp = exp(re) * im;
} else if (re <= 1.4e+89) {
tmp = t_0 * (im + (-0.16666666666666666 * pow(im, 3.0)));
} else if (re <= 1.14e+154) {
tmp = exp(re);
} 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 = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
t_1 = sin(im) * t_0
if (re <= (-25.0d0)) then
tmp = exp(re)
else if (re <= 0.0295d0) then
tmp = t_1
else if (re <= 4.7d+24) then
tmp = exp(re) * im
else if (re <= 1.4d+89) then
tmp = t_0 * (im + ((-0.16666666666666666d0) * (im ** 3.0d0)))
else if (re <= 1.14d+154) then
tmp = exp(re)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 1.0 + (re * (1.0 + (re * 0.5)));
double t_1 = Math.sin(im) * t_0;
double tmp;
if (re <= -25.0) {
tmp = Math.exp(re);
} else if (re <= 0.0295) {
tmp = t_1;
} else if (re <= 4.7e+24) {
tmp = Math.exp(re) * im;
} else if (re <= 1.4e+89) {
tmp = t_0 * (im + (-0.16666666666666666 * Math.pow(im, 3.0)));
} else if (re <= 1.14e+154) {
tmp = Math.exp(re);
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 1.0 + (re * (1.0 + (re * 0.5))) t_1 = math.sin(im) * t_0 tmp = 0 if re <= -25.0: tmp = math.exp(re) elif re <= 0.0295: tmp = t_1 elif re <= 4.7e+24: tmp = math.exp(re) * im elif re <= 1.4e+89: tmp = t_0 * (im + (-0.16666666666666666 * math.pow(im, 3.0))) elif re <= 1.14e+154: tmp = math.exp(re) else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) t_1 = Float64(sin(im) * t_0) tmp = 0.0 if (re <= -25.0) tmp = exp(re); elseif (re <= 0.0295) tmp = t_1; elseif (re <= 4.7e+24) tmp = Float64(exp(re) * im); elseif (re <= 1.4e+89) tmp = Float64(t_0 * Float64(im + Float64(-0.16666666666666666 * (im ^ 3.0)))); elseif (re <= 1.14e+154) tmp = exp(re); else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 1.0 + (re * (1.0 + (re * 0.5))); t_1 = sin(im) * t_0; tmp = 0.0; if (re <= -25.0) tmp = exp(re); elseif (re <= 0.0295) tmp = t_1; elseif (re <= 4.7e+24) tmp = exp(re) * im; elseif (re <= 1.4e+89) tmp = t_0 * (im + (-0.16666666666666666 * (im ^ 3.0))); elseif (re <= 1.14e+154) tmp = exp(re); else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[im], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[re, -25.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.0295], t$95$1, If[LessEqual[re, 4.7e+24], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], If[LessEqual[re, 1.4e+89], N[(t$95$0 * N[(im + N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.14e+154], N[Exp[re], $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + re \cdot \left(1 + re \cdot 0.5\right)\\
t_1 := \sin im \cdot t\_0\\
\mathbf{if}\;re \leq -25:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.0295:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;re \leq 4.7 \cdot 10^{+24}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{elif}\;re \leq 1.4 \cdot 10^{+89}:\\
\;\;\;\;t\_0 \cdot \left(im + -0.16666666666666666 \cdot {im}^{3}\right)\\
\mathbf{elif}\;re \leq 1.14 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if re < -25 or 1.3999999999999999e89 < re < 1.13999999999999997e154Initial program 100.0%
add-exp-log54.9%
prod-exp54.9%
Applied egg-rr54.9%
Taylor expanded in re around inf 91.7%
if -25 < re < 0.029499999999999998 or 1.13999999999999997e154 < re Initial program 100.0%
Taylor expanded in re around 0 92.7%
*-rgt-identity92.7%
distribute-lft-in92.7%
associate-*r*92.7%
associate-*r*99.2%
distribute-rgt-out99.2%
distribute-lft-out99.2%
*-rgt-identity99.2%
distribute-lft-out99.2%
*-commutative99.2%
Simplified99.2%
if 0.029499999999999998 < re < 4.7e24Initial program 100.0%
Taylor expanded in im around 0 66.8%
if 4.7e24 < re < 1.3999999999999999e89Initial program 100.0%
Taylor expanded in re around 0 3.9%
*-rgt-identity3.9%
distribute-lft-in3.9%
associate-*r*3.9%
associate-*r*3.9%
distribute-rgt-out3.9%
distribute-lft-out3.9%
*-rgt-identity3.9%
distribute-lft-out3.9%
*-commutative3.9%
Simplified3.9%
Taylor expanded in im around 0 65.3%
distribute-rgt-in65.3%
*-lft-identity65.3%
associate-*l*65.3%
pow-plus65.3%
metadata-eval65.3%
Simplified65.3%
Final simplification94.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (+ 1.0 (* re (+ 1.0 (* re 0.5))))) (t_1 (* (sin im) t_0)))
(if (<= re -32.0)
(exp re)
(if (<= re 0.037)
t_1
(if (<= re 4.7e+24)
(* (exp re) im)
(if (<= re 1.4e+89)
(* t_0 (* -0.16666666666666666 (pow im 3.0)))
(if (<= re 1.14e+154) (exp re) t_1)))))))
double code(double re, double im) {
double t_0 = 1.0 + (re * (1.0 + (re * 0.5)));
double t_1 = sin(im) * t_0;
double tmp;
if (re <= -32.0) {
tmp = exp(re);
} else if (re <= 0.037) {
tmp = t_1;
} else if (re <= 4.7e+24) {
tmp = exp(re) * im;
} else if (re <= 1.4e+89) {
tmp = t_0 * (-0.16666666666666666 * pow(im, 3.0));
} else if (re <= 1.14e+154) {
tmp = exp(re);
} 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 = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
t_1 = sin(im) * t_0
if (re <= (-32.0d0)) then
tmp = exp(re)
else if (re <= 0.037d0) then
tmp = t_1
else if (re <= 4.7d+24) then
tmp = exp(re) * im
else if (re <= 1.4d+89) then
tmp = t_0 * ((-0.16666666666666666d0) * (im ** 3.0d0))
else if (re <= 1.14d+154) then
tmp = exp(re)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 1.0 + (re * (1.0 + (re * 0.5)));
double t_1 = Math.sin(im) * t_0;
double tmp;
if (re <= -32.0) {
tmp = Math.exp(re);
} else if (re <= 0.037) {
tmp = t_1;
} else if (re <= 4.7e+24) {
tmp = Math.exp(re) * im;
} else if (re <= 1.4e+89) {
tmp = t_0 * (-0.16666666666666666 * Math.pow(im, 3.0));
} else if (re <= 1.14e+154) {
tmp = Math.exp(re);
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 1.0 + (re * (1.0 + (re * 0.5))) t_1 = math.sin(im) * t_0 tmp = 0 if re <= -32.0: tmp = math.exp(re) elif re <= 0.037: tmp = t_1 elif re <= 4.7e+24: tmp = math.exp(re) * im elif re <= 1.4e+89: tmp = t_0 * (-0.16666666666666666 * math.pow(im, 3.0)) elif re <= 1.14e+154: tmp = math.exp(re) else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) t_1 = Float64(sin(im) * t_0) tmp = 0.0 if (re <= -32.0) tmp = exp(re); elseif (re <= 0.037) tmp = t_1; elseif (re <= 4.7e+24) tmp = Float64(exp(re) * im); elseif (re <= 1.4e+89) tmp = Float64(t_0 * Float64(-0.16666666666666666 * (im ^ 3.0))); elseif (re <= 1.14e+154) tmp = exp(re); else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 1.0 + (re * (1.0 + (re * 0.5))); t_1 = sin(im) * t_0; tmp = 0.0; if (re <= -32.0) tmp = exp(re); elseif (re <= 0.037) tmp = t_1; elseif (re <= 4.7e+24) tmp = exp(re) * im; elseif (re <= 1.4e+89) tmp = t_0 * (-0.16666666666666666 * (im ^ 3.0)); elseif (re <= 1.14e+154) tmp = exp(re); else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[im], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[re, -32.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.037], t$95$1, If[LessEqual[re, 4.7e+24], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], If[LessEqual[re, 1.4e+89], N[(t$95$0 * N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.14e+154], N[Exp[re], $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + re \cdot \left(1 + re \cdot 0.5\right)\\
t_1 := \sin im \cdot t\_0\\
\mathbf{if}\;re \leq -32:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.037:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;re \leq 4.7 \cdot 10^{+24}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{elif}\;re \leq 1.4 \cdot 10^{+89}:\\
\;\;\;\;t\_0 \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right)\\
\mathbf{elif}\;re \leq 1.14 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if re < -32 or 1.3999999999999999e89 < re < 1.13999999999999997e154Initial program 100.0%
add-exp-log54.9%
prod-exp54.9%
Applied egg-rr54.9%
Taylor expanded in re around inf 91.7%
if -32 < re < 0.0369999999999999982 or 1.13999999999999997e154 < re Initial program 100.0%
Taylor expanded in re around 0 92.7%
*-rgt-identity92.7%
distribute-lft-in92.7%
associate-*r*92.7%
associate-*r*99.2%
distribute-rgt-out99.2%
distribute-lft-out99.2%
*-rgt-identity99.2%
distribute-lft-out99.2%
*-commutative99.2%
Simplified99.2%
if 0.0369999999999999982 < re < 4.7e24Initial program 100.0%
Taylor expanded in im around 0 66.8%
if 4.7e24 < re < 1.3999999999999999e89Initial program 100.0%
Taylor expanded in re around 0 3.9%
*-rgt-identity3.9%
distribute-lft-in3.9%
associate-*r*3.9%
associate-*r*3.9%
distribute-rgt-out3.9%
distribute-lft-out3.9%
*-rgt-identity3.9%
distribute-lft-out3.9%
*-commutative3.9%
Simplified3.9%
Taylor expanded in im around 0 65.3%
distribute-rgt-in65.3%
*-lft-identity65.3%
associate-*l*65.3%
pow-plus65.3%
metadata-eval65.3%
Simplified65.3%
Taylor expanded in im around inf 65.2%
Final simplification94.6%
(FPCore (re im)
:precision binary64
(if (<= re -25.0)
(exp re)
(if (or (<= re 0.017) (not (<= re 1.14e+154)))
(* (sin im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))
(* (exp re) im))))
double code(double re, double im) {
double tmp;
if (re <= -25.0) {
tmp = exp(re);
} else if ((re <= 0.017) || !(re <= 1.14e+154)) {
tmp = sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else {
tmp = exp(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 <= (-25.0d0)) then
tmp = exp(re)
else if ((re <= 0.017d0) .or. (.not. (re <= 1.14d+154))) then
tmp = sin(im) * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
else
tmp = exp(re) * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -25.0) {
tmp = Math.exp(re);
} else if ((re <= 0.017) || !(re <= 1.14e+154)) {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
} else {
tmp = Math.exp(re) * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -25.0: tmp = math.exp(re) elif (re <= 0.017) or not (re <= 1.14e+154): tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))) else: tmp = math.exp(re) * im return tmp
function code(re, im) tmp = 0.0 if (re <= -25.0) tmp = exp(re); elseif ((re <= 0.017) || !(re <= 1.14e+154)) tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); else tmp = Float64(exp(re) * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -25.0) tmp = exp(re); elseif ((re <= 0.017) || ~((re <= 1.14e+154))) tmp = sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))); else tmp = exp(re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -25.0], N[Exp[re], $MachinePrecision], If[Or[LessEqual[re, 0.017], N[Not[LessEqual[re, 1.14e+154]], $MachinePrecision]], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -25:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.017 \lor \neg \left(re \leq 1.14 \cdot 10^{+154}\right):\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\
\end{array}
\end{array}
if re < -25Initial program 100.0%
add-exp-log55.1%
prod-exp55.0%
Applied egg-rr55.0%
Taylor expanded in re around inf 98.8%
if -25 < re < 0.017000000000000001 or 1.13999999999999997e154 < re Initial program 100.0%
Taylor expanded in re around 0 92.7%
*-rgt-identity92.7%
distribute-lft-in92.7%
associate-*r*92.7%
associate-*r*99.2%
distribute-rgt-out99.2%
distribute-lft-out99.2%
*-rgt-identity99.2%
distribute-lft-out99.2%
*-commutative99.2%
Simplified99.2%
if 0.017000000000000001 < re < 1.13999999999999997e154Initial program 100.0%
Taylor expanded in im around 0 63.4%
Final simplification94.9%
(FPCore (re im) :precision binary64 (if (<= re -1.0) (exp re) (if (<= re 0.0135) (* (sin im) (+ re 1.0)) (* (exp re) im))))
double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = exp(re);
} else if (re <= 0.0135) {
tmp = sin(im) * (re + 1.0);
} else {
tmp = exp(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 = exp(re)
else if (re <= 0.0135d0) then
tmp = sin(im) * (re + 1.0d0)
else
tmp = exp(re) * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = Math.exp(re);
} else if (re <= 0.0135) {
tmp = Math.sin(im) * (re + 1.0);
} else {
tmp = Math.exp(re) * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.0: tmp = math.exp(re) elif re <= 0.0135: tmp = math.sin(im) * (re + 1.0) else: tmp = math.exp(re) * im return tmp
function code(re, im) tmp = 0.0 if (re <= -1.0) tmp = exp(re); elseif (re <= 0.0135) tmp = Float64(sin(im) * Float64(re + 1.0)); else tmp = Float64(exp(re) * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.0) tmp = exp(re); elseif (re <= 0.0135) tmp = sin(im) * (re + 1.0); else tmp = exp(re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.0135], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.0135:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
add-exp-log55.1%
prod-exp55.0%
Applied egg-rr55.0%
Taylor expanded in re around inf 98.8%
if -1 < re < 0.0134999999999999998Initial program 100.0%
Taylor expanded in re around 0 99.2%
distribute-rgt1-in99.2%
Simplified99.2%
if 0.0134999999999999998 < re Initial program 100.0%
Taylor expanded in im around 0 67.7%
Final simplification91.1%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.00115) (not (<= re 9.5e-30)))
(exp re)
(+
im
(* re (+ im (* re (+ (* 0.16666666666666666 (* re im)) (* im 0.5))))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.00115) || !(re <= 9.5e-30)) {
tmp = exp(re);
} else {
tmp = im + (re * (im + (re * ((0.16666666666666666 * (re * im)) + (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 <= (-0.00115d0)) .or. (.not. (re <= 9.5d-30))) then
tmp = exp(re)
else
tmp = im + (re * (im + (re * ((0.16666666666666666d0 * (re * im)) + (im * 0.5d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.00115) || !(re <= 9.5e-30)) {
tmp = Math.exp(re);
} else {
tmp = im + (re * (im + (re * ((0.16666666666666666 * (re * im)) + (im * 0.5)))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.00115) or not (re <= 9.5e-30): tmp = math.exp(re) else: tmp = im + (re * (im + (re * ((0.16666666666666666 * (re * im)) + (im * 0.5))))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.00115) || !(re <= 9.5e-30)) tmp = exp(re); else tmp = Float64(im + Float64(re * Float64(im + Float64(re * Float64(Float64(0.16666666666666666 * Float64(re * im)) + Float64(im * 0.5)))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.00115) || ~((re <= 9.5e-30))) tmp = exp(re); else tmp = im + (re * (im + (re * ((0.16666666666666666 * (re * im)) + (im * 0.5))))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.00115], N[Not[LessEqual[re, 9.5e-30]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(im + N[(re * N[(im + N[(re * N[(N[(0.16666666666666666 * N[(re * im), $MachinePrecision]), $MachinePrecision] + N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.00115 \lor \neg \left(re \leq 9.5 \cdot 10^{-30}\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;im + re \cdot \left(im + re \cdot \left(0.16666666666666666 \cdot \left(re \cdot im\right) + im \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.00115 or 9.49999999999999939e-30 < re Initial program 100.0%
add-exp-log55.4%
prod-exp55.4%
Applied egg-rr55.4%
Taylor expanded in re around inf 75.5%
if -0.00115 < re < 9.49999999999999939e-30Initial program 100.0%
Taylor expanded in im around 0 51.9%
Taylor expanded in re around 0 51.9%
Final simplification64.7%
(FPCore (re im) :precision binary64 (let* ((t_0 (+ 1.0 (* re (+ 1.0 (* re 0.5)))))) (if (<= re -52.0) (* t_0 0.0) (* im t_0))))
double code(double re, double im) {
double t_0 = 1.0 + (re * (1.0 + (re * 0.5)));
double tmp;
if (re <= -52.0) {
tmp = t_0 * 0.0;
} else {
tmp = 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 = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
if (re <= (-52.0d0)) then
tmp = t_0 * 0.0d0
else
tmp = im * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 1.0 + (re * (1.0 + (re * 0.5)));
double tmp;
if (re <= -52.0) {
tmp = t_0 * 0.0;
} else {
tmp = im * t_0;
}
return tmp;
}
def code(re, im): t_0 = 1.0 + (re * (1.0 + (re * 0.5))) tmp = 0 if re <= -52.0: tmp = t_0 * 0.0 else: tmp = im * t_0 return tmp
function code(re, im) t_0 = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) tmp = 0.0 if (re <= -52.0) tmp = Float64(t_0 * 0.0); else tmp = Float64(im * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = 1.0 + (re * (1.0 + (re * 0.5))); tmp = 0.0; if (re <= -52.0) tmp = t_0 * 0.0; else tmp = im * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -52.0], N[(t$95$0 * 0.0), $MachinePrecision], N[(im * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + re \cdot \left(1 + re \cdot 0.5\right)\\
\mathbf{if}\;re \leq -52:\\
\;\;\;\;t\_0 \cdot 0\\
\mathbf{else}:\\
\;\;\;\;im \cdot t\_0\\
\end{array}
\end{array}
if re < -52Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
distribute-lft-in2.2%
associate-*r*2.2%
associate-*r*2.2%
distribute-rgt-out2.2%
distribute-lft-out2.2%
*-rgt-identity2.2%
distribute-lft-out2.2%
*-commutative2.2%
Simplified2.2%
expm1-log1p-u2.2%
expm1-undefine30.3%
log1p-undefine30.3%
rem-exp-log30.3%
Applied egg-rr30.3%
Taylor expanded in im around 0 44.1%
if -52 < re Initial program 100.0%
Taylor expanded in re around 0 78.3%
*-rgt-identity78.3%
distribute-lft-in78.3%
associate-*r*78.3%
associate-*r*83.8%
distribute-rgt-out83.8%
distribute-lft-out83.8%
*-rgt-identity83.8%
distribute-lft-out83.8%
*-commutative83.8%
Simplified83.8%
Taylor expanded in im around 0 48.8%
Final simplification47.6%
(FPCore (re im) :precision binary64 (* im (+ 1.0 (* re (+ 1.0 (* re 0.5))))))
double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * 0.5))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end function
public static double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * 0.5))));
}
def code(re, im): return im * (1.0 + (re * (1.0 + (re * 0.5))))
function code(re, im) return Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))) end
function tmp = code(re, im) tmp = im * (1.0 + (re * (1.0 + (re * 0.5)))); end
code[re_, im_] := N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 58.1%
*-rgt-identity58.1%
distribute-lft-in58.1%
associate-*r*58.1%
associate-*r*62.1%
distribute-rgt-out62.1%
distribute-lft-out62.1%
*-rgt-identity62.1%
distribute-lft-out62.1%
*-commutative62.1%
Simplified62.1%
Taylor expanded in im around 0 36.4%
(FPCore (re im) :precision binary64 (+ im (* re (* re (* im 0.5)))))
double code(double re, double im) {
return im + (re * (re * (im * 0.5)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im + (re * (re * (im * 0.5d0)))
end function
public static double code(double re, double im) {
return im + (re * (re * (im * 0.5)));
}
def code(re, im): return im + (re * (re * (im * 0.5)))
function code(re, im) return Float64(im + Float64(re * Float64(re * Float64(im * 0.5)))) end
function tmp = code(re, im) tmp = im + (re * (re * (im * 0.5))); end
code[re_, im_] := N[(im + N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im + re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 67.5%
Taylor expanded in re around 0 32.4%
Taylor expanded in re around inf 31.6%
associate-*r*31.6%
*-commutative31.6%
*-commutative31.6%
Simplified31.6%
(FPCore (re im) :precision binary64 (if (<= re 1.4e+89) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 1.4e+89) {
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 <= 1.4d+89) 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 <= 1.4e+89) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.4e+89: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 1.4e+89) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.4e+89) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.4e+89], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.4 \cdot 10^{+89}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 1.3999999999999999e89Initial program 100.0%
Taylor expanded in im around 0 65.3%
Taylor expanded in re around 0 29.8%
if 1.3999999999999999e89 < re Initial program 100.0%
Taylor expanded in re around 0 4.6%
distribute-rgt1-in4.6%
Simplified4.6%
Taylor expanded in im around 0 21.2%
Taylor expanded in re around inf 21.2%
Final simplification28.2%
(FPCore (re im) :precision binary64 (* im (+ re 1.0)))
double code(double re, double im) {
return im * (re + 1.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (re + 1.0d0)
end function
public static double code(double re, double im) {
return im * (re + 1.0);
}
def code(re, im): return im * (re + 1.0)
function code(re, im) return Float64(im * Float64(re + 1.0)) end
function tmp = code(re, im) tmp = im * (re + 1.0); end
code[re_, im_] := N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(re + 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 49.2%
distribute-rgt1-in49.2%
Simplified49.2%
Taylor expanded in im around 0 28.5%
Final simplification28.5%
(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 100.0%
Taylor expanded in im around 0 67.5%
Taylor expanded in re around 0 24.7%
herbie shell --seed 2024101
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))