
(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 13 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%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.999995) (not (<= (exp re) 1.0000005))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.999995) || !(exp(re) <= 1.0000005)) {
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.999995d0) .or. (.not. (exp(re) <= 1.0000005d0))) 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.999995) || !(Math.exp(re) <= 1.0000005)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.999995) or not (math.exp(re) <= 1.0000005): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.999995) || !(exp(re) <= 1.0000005)) 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.999995) || ~((exp(re) <= 1.0000005))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.999995], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.0000005]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.999995 \lor \neg \left(e^{re} \leq 1.0000005\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.99999499999999997 or 1.0000005000000001 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 81.5%
if 0.99999499999999997 < (exp.f64 re) < 1.0000005000000001Initial program 100.0%
Taylor expanded in re around 0 99.7%
Final simplification90.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.124)
t_0
(if (<= re 7.8e+21)
(* (sin im) (+ (+ re 1.0) (* 0.5 (* re re))))
(if (<= re 1.35e+154) t_0 (* (* re re) (* (sin im) 0.5)))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.124) {
tmp = t_0;
} else if (re <= 7.8e+21) {
tmp = sin(im) * ((re + 1.0) + (0.5 * (re * re)));
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = (re * re) * (sin(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) :: tmp
t_0 = exp(re) * im
if (re <= (-0.124d0)) then
tmp = t_0
else if (re <= 7.8d+21) then
tmp = sin(im) * ((re + 1.0d0) + (0.5d0 * (re * re)))
else if (re <= 1.35d+154) then
tmp = t_0
else
tmp = (re * re) * (sin(im) * 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 <= -0.124) {
tmp = t_0;
} else if (re <= 7.8e+21) {
tmp = Math.sin(im) * ((re + 1.0) + (0.5 * (re * re)));
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = (re * re) * (Math.sin(im) * 0.5);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.124: tmp = t_0 elif re <= 7.8e+21: tmp = math.sin(im) * ((re + 1.0) + (0.5 * (re * re))) elif re <= 1.35e+154: tmp = t_0 else: tmp = (re * re) * (math.sin(im) * 0.5) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.124) tmp = t_0; elseif (re <= 7.8e+21) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re)))); elseif (re <= 1.35e+154) tmp = t_0; else tmp = Float64(Float64(re * re) * Float64(sin(im) * 0.5)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.124) tmp = t_0; elseif (re <= 7.8e+21) tmp = sin(im) * ((re + 1.0) + (0.5 * (re * re))); elseif (re <= 1.35e+154) tmp = t_0; else tmp = (re * re) * (sin(im) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.124], t$95$0, If[LessEqual[re, 7.8e+21], 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.35e+154], t$95$0, N[(N[(re * re), $MachinePrecision] * N[(N[Sin[im], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.124:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 7.8 \cdot 10^{+21}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(\sin im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -0.124 or 7.8e21 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 87.2%
if -0.124 < re < 7.8e21Initial program 100.0%
Taylor expanded in re around 0 98.4%
*-rgt-identity98.4%
*-commutative98.4%
associate-*l*98.4%
distribute-lft-out98.4%
distribute-lft-out98.4%
associate-+l+98.4%
+-commutative98.4%
*-commutative98.4%
unpow298.4%
Simplified98.4%
if 1.35000000000000003e154 < 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%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification94.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.0085)
t_0
(if (<= re 8e-7)
(* (sin im) (+ re 1.0))
(if (<= re 1.35e+154) t_0 (* (* re re) (* (sin im) 0.5)))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.0085) {
tmp = t_0;
} else if (re <= 8e-7) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = (re * re) * (sin(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) :: tmp
t_0 = exp(re) * im
if (re <= (-0.0085d0)) then
tmp = t_0
else if (re <= 8d-7) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 1.35d+154) then
tmp = t_0
else
tmp = (re * re) * (sin(im) * 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 <= -0.0085) {
tmp = t_0;
} else if (re <= 8e-7) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = (re * re) * (Math.sin(im) * 0.5);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.0085: tmp = t_0 elif re <= 8e-7: tmp = math.sin(im) * (re + 1.0) elif re <= 1.35e+154: tmp = t_0 else: tmp = (re * re) * (math.sin(im) * 0.5) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.0085) tmp = t_0; elseif (re <= 8e-7) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 1.35e+154) tmp = t_0; else tmp = Float64(Float64(re * re) * Float64(sin(im) * 0.5)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.0085) tmp = t_0; elseif (re <= 8e-7) tmp = sin(im) * (re + 1.0); elseif (re <= 1.35e+154) tmp = t_0; else tmp = (re * re) * (sin(im) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.0085], t$95$0, If[LessEqual[re, 8e-7], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], t$95$0, N[(N[(re * re), $MachinePrecision] * N[(N[Sin[im], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.0085:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 8 \cdot 10^{-7}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(\sin im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -0.0085000000000000006 or 7.9999999999999996e-7 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 85.7%
if -0.0085000000000000006 < re < 7.9999999999999996e-7Initial program 100.0%
Taylor expanded in re around 0 99.5%
+-commutative99.5%
*-rgt-identity99.5%
distribute-lft-out99.5%
Simplified99.5%
if 1.35000000000000003e154 < 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%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification94.3%
(FPCore (re im) :precision binary64 (if (or (<= re -0.017) (not (<= re 8e-7))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.017) || !(re <= 8e-7)) {
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 <= (-0.017d0)) .or. (.not. (re <= 8d-7))) 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 <= -0.017) || !(re <= 8e-7)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.017) or not (re <= 8e-7): tmp = math.exp(re) * im else: tmp = math.sin(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.017) || !(re <= 8e-7)) 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 <= -0.017) || ~((re <= 8e-7))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.017], N[Not[LessEqual[re, 8e-7]], $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 -0.017 \lor \neg \left(re \leq 8 \cdot 10^{-7}\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -0.017000000000000001 or 7.9999999999999996e-7 < re Initial program 100.0%
Taylor expanded in im around 0 82.0%
if -0.017000000000000001 < re < 7.9999999999999996e-7Initial program 100.0%
Taylor expanded in re around 0 99.5%
+-commutative99.5%
*-rgt-identity99.5%
distribute-lft-out99.5%
Simplified99.5%
Final simplification90.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- 1.0 (* re re))))
(if (<= re -1.55e+43)
(* t_0 (* (+ re 1.0) (/ im t_0)))
(if (<= re 1.85e-7) (sin im) (* im (+ (+ re 1.0) (* 0.5 (* re re))))))))
double code(double re, double im) {
double t_0 = 1.0 - (re * re);
double tmp;
if (re <= -1.55e+43) {
tmp = t_0 * ((re + 1.0) * (im / t_0));
} else if (re <= 1.85e-7) {
tmp = sin(im);
} 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (re * re)
if (re <= (-1.55d+43)) then
tmp = t_0 * ((re + 1.0d0) * (im / t_0))
else if (re <= 1.85d-7) then
tmp = sin(im)
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 t_0 = 1.0 - (re * re);
double tmp;
if (re <= -1.55e+43) {
tmp = t_0 * ((re + 1.0) * (im / t_0));
} else if (re <= 1.85e-7) {
tmp = Math.sin(im);
} else {
tmp = im * ((re + 1.0) + (0.5 * (re * re)));
}
return tmp;
}
def code(re, im): t_0 = 1.0 - (re * re) tmp = 0 if re <= -1.55e+43: tmp = t_0 * ((re + 1.0) * (im / t_0)) elif re <= 1.85e-7: tmp = math.sin(im) else: tmp = im * ((re + 1.0) + (0.5 * (re * re))) return tmp
function code(re, im) t_0 = Float64(1.0 - Float64(re * re)) tmp = 0.0 if (re <= -1.55e+43) tmp = Float64(t_0 * Float64(Float64(re + 1.0) * Float64(im / t_0))); elseif (re <= 1.85e-7) tmp = sin(im); 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) t_0 = 1.0 - (re * re); tmp = 0.0; if (re <= -1.55e+43) tmp = t_0 * ((re + 1.0) * (im / t_0)); elseif (re <= 1.85e-7) tmp = sin(im); else tmp = im * ((re + 1.0) + (0.5 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -1.55e+43], N[(t$95$0 * N[(N[(re + 1.0), $MachinePrecision] * N[(im / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.85e-7], N[Sin[im], $MachinePrecision], N[(im * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - re \cdot re\\
\mathbf{if}\;re \leq -1.55 \cdot 10^{+43}:\\
\;\;\;\;t_0 \cdot \left(\left(re + 1\right) \cdot \frac{im}{t_0}\right)\\
\mathbf{elif}\;re \leq 1.85 \cdot 10^{-7}:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < -1.5500000000000001e43Initial program 100.0%
Taylor expanded in re around 0 2.7%
+-commutative2.7%
*-rgt-identity2.7%
distribute-lft-out2.7%
Simplified2.7%
Taylor expanded in im around 0 2.5%
+-commutative2.5%
*-commutative2.5%
+-commutative2.5%
flip-+2.2%
associate-*r/2.2%
metadata-eval2.2%
Applied egg-rr2.2%
associate-/l*2.2%
associate-/r/7.3%
Simplified7.3%
flip--6.8%
metadata-eval6.8%
flip-+6.8%
metadata-eval6.8%
associate-/r/14.1%
metadata-eval14.1%
flip-+14.1%
Applied egg-rr14.1%
if -1.5500000000000001e43 < re < 1.85000000000000002e-7Initial program 100.0%
Taylor expanded in re around 0 95.1%
if 1.85000000000000002e-7 < re Initial program 100.0%
Taylor expanded in re around 0 51.6%
*-rgt-identity51.6%
*-commutative51.6%
associate-*l*51.6%
distribute-lft-out51.6%
distribute-lft-out51.6%
associate-+l+51.6%
+-commutative51.6%
*-commutative51.6%
unpow251.6%
Simplified51.6%
Taylor expanded in im around 0 41.1%
Final simplification62.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- 1.0 (* re re))))
(if (<= re -390.0)
(* t_0 (* (+ re 1.0) (/ im t_0)))
(* im (+ (+ re 1.0) (* 0.5 (* re re)))))))
double code(double re, double im) {
double t_0 = 1.0 - (re * re);
double tmp;
if (re <= -390.0) {
tmp = t_0 * ((re + 1.0) * (im / t_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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (re * re)
if (re <= (-390.0d0)) then
tmp = t_0 * ((re + 1.0d0) * (im / t_0))
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 t_0 = 1.0 - (re * re);
double tmp;
if (re <= -390.0) {
tmp = t_0 * ((re + 1.0) * (im / t_0));
} else {
tmp = im * ((re + 1.0) + (0.5 * (re * re)));
}
return tmp;
}
def code(re, im): t_0 = 1.0 - (re * re) tmp = 0 if re <= -390.0: tmp = t_0 * ((re + 1.0) * (im / t_0)) else: tmp = im * ((re + 1.0) + (0.5 * (re * re))) return tmp
function code(re, im) t_0 = Float64(1.0 - Float64(re * re)) tmp = 0.0 if (re <= -390.0) tmp = Float64(t_0 * Float64(Float64(re + 1.0) * Float64(im / t_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) t_0 = 1.0 - (re * re); tmp = 0.0; if (re <= -390.0) tmp = t_0 * ((re + 1.0) * (im / t_0)); else tmp = im * ((re + 1.0) + (0.5 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -390.0], N[(t$95$0 * N[(N[(re + 1.0), $MachinePrecision] * N[(im / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - re \cdot re\\
\mathbf{if}\;re \leq -390:\\
\;\;\;\;t_0 \cdot \left(\left(re + 1\right) \cdot \frac{im}{t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < -390Initial program 100.0%
Taylor expanded in re around 0 2.8%
+-commutative2.8%
*-rgt-identity2.8%
distribute-lft-out2.8%
Simplified2.8%
Taylor expanded in im around 0 2.5%
+-commutative2.5%
*-commutative2.5%
+-commutative2.5%
flip-+2.3%
associate-*r/2.3%
metadata-eval2.3%
Applied egg-rr2.3%
associate-/l*2.3%
associate-/r/7.0%
Simplified7.0%
flip--6.5%
metadata-eval6.5%
flip-+6.5%
metadata-eval6.5%
associate-/r/13.1%
metadata-eval13.1%
flip-+13.1%
Applied egg-rr13.1%
if -390 < re Initial program 100.0%
Taylor expanded in re around 0 81.6%
*-rgt-identity81.6%
*-commutative81.6%
associate-*l*81.6%
distribute-lft-out81.6%
distribute-lft-out81.6%
associate-+l+81.6%
+-commutative81.6%
*-commutative81.6%
unpow281.6%
Simplified81.6%
Taylor expanded in im around 0 43.5%
Final simplification36.6%
(FPCore (re im) :precision binary64 (* im (+ (+ re 1.0) (* 0.5 (* re re)))))
double code(double re, double im) {
return im * ((re + 1.0) + (0.5 * (re * re)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * ((re + 1.0d0) + (0.5d0 * (re * re)))
end function
public static double code(double re, double im) {
return im * ((re + 1.0) + (0.5 * (re * re)));
}
def code(re, im): return im * ((re + 1.0) + (0.5 * (re * re)))
function code(re, im) return Float64(im * Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re)))) end
function tmp = code(re, im) tmp = im * ((re + 1.0) + (0.5 * (re * re))); end
code[re_, im_] := N[(im * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 63.6%
*-rgt-identity63.6%
*-commutative63.6%
associate-*l*63.6%
distribute-lft-out63.6%
distribute-lft-out63.6%
associate-+l+63.6%
+-commutative63.6%
*-commutative63.6%
unpow263.6%
Simplified63.6%
Taylor expanded in im around 0 34.1%
Final simplification34.1%
(FPCore (re im) :precision binary64 (if (<= re 7.8e+21) (* im (+ re 1.0)) (* (* re 0.5) (* re im))))
double code(double re, double im) {
double tmp;
if (re <= 7.8e+21) {
tmp = im * (re + 1.0);
} else {
tmp = (re * 0.5) * (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 <= 7.8d+21) then
tmp = im * (re + 1.0d0)
else
tmp = (re * 0.5d0) * (re * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 7.8e+21) {
tmp = im * (re + 1.0);
} else {
tmp = (re * 0.5) * (re * im);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 7.8e+21: tmp = im * (re + 1.0) else: tmp = (re * 0.5) * (re * im) return tmp
function code(re, im) tmp = 0.0 if (re <= 7.8e+21) tmp = Float64(im * Float64(re + 1.0)); else tmp = Float64(Float64(re * 0.5) * Float64(re * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 7.8e+21) tmp = im * (re + 1.0); else tmp = (re * 0.5) * (re * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 7.8e+21], N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(re * 0.5), $MachinePrecision] * N[(re * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 7.8 \cdot 10^{+21}:\\
\;\;\;\;im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot 0.5\right) \cdot \left(re \cdot im\right)\\
\end{array}
\end{array}
if re < 7.8e21Initial program 100.0%
Taylor expanded in re around 0 67.9%
+-commutative67.9%
*-rgt-identity67.9%
distribute-lft-out67.9%
Simplified67.9%
Taylor expanded in im around 0 31.4%
if 7.8e21 < re Initial program 100.0%
Taylor expanded in re around 0 51.6%
*-rgt-identity51.6%
*-commutative51.6%
associate-*l*51.6%
distribute-lft-out51.6%
distribute-lft-out51.6%
associate-+l+51.6%
+-commutative51.6%
*-commutative51.6%
unpow251.6%
Simplified51.6%
Taylor expanded in re around inf 51.6%
unpow251.6%
associate-*r*51.6%
*-commutative51.6%
*-commutative51.6%
Simplified51.6%
Taylor expanded in im around 0 40.7%
unpow240.7%
associate-*r*40.7%
associate-*r*40.7%
associate-*l*28.9%
*-commutative28.9%
Simplified28.9%
Final simplification30.7%
(FPCore (re im) :precision binary64 (if (<= re 7.8e+21) (* im (+ re 1.0)) (* (* re re) (* im 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 7.8e+21) {
tmp = im * (re + 1.0);
} 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 <= 7.8d+21) then
tmp = im * (re + 1.0d0)
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 <= 7.8e+21) {
tmp = im * (re + 1.0);
} else {
tmp = (re * re) * (im * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 7.8e+21: tmp = im * (re + 1.0) else: tmp = (re * re) * (im * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 7.8e+21) tmp = Float64(im * Float64(re + 1.0)); 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 <= 7.8e+21) tmp = im * (re + 1.0); else tmp = (re * re) * (im * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 7.8e+21], N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 7.8 \cdot 10^{+21}:\\
\;\;\;\;im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 7.8e21Initial program 100.0%
Taylor expanded in re around 0 67.9%
+-commutative67.9%
*-rgt-identity67.9%
distribute-lft-out67.9%
Simplified67.9%
Taylor expanded in im around 0 31.4%
if 7.8e21 < re Initial program 100.0%
Taylor expanded in re around 0 51.6%
*-rgt-identity51.6%
*-commutative51.6%
associate-*l*51.6%
distribute-lft-out51.6%
distribute-lft-out51.6%
associate-+l+51.6%
+-commutative51.6%
*-commutative51.6%
unpow251.6%
Simplified51.6%
Taylor expanded in re around inf 51.6%
unpow251.6%
associate-*r*51.6%
*-commutative51.6%
*-commutative51.6%
Simplified51.6%
Taylor expanded in im around 0 40.7%
Final simplification34.0%
(FPCore (re im) :precision binary64 (if (<= re 7.8e+21) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 7.8e+21) {
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 <= 7.8d+21) 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 <= 7.8e+21) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 7.8e+21: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 7.8e+21) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 7.8e+21) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 7.8e+21], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 7.8 \cdot 10^{+21}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 7.8e21Initial program 100.0%
Taylor expanded in re around 0 67.6%
Taylor expanded in im around 0 31.3%
if 7.8e21 < re Initial program 100.0%
Taylor expanded in re around 0 4.5%
+-commutative4.5%
*-rgt-identity4.5%
distribute-lft-out4.5%
Simplified4.5%
Taylor expanded in im around 0 15.0%
Taylor expanded in re around inf 15.0%
Final simplification26.7%
(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 50.3%
+-commutative50.3%
*-rgt-identity50.3%
distribute-lft-out50.3%
Simplified50.3%
Taylor expanded in im around 0 26.8%
Final simplification26.8%
(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 re around 0 49.6%
Taylor expanded in im around 0 23.2%
Final simplification23.2%
herbie shell --seed 2023196
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))