
(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 (<= (exp re) 0.0) 0.0 (if (<= (exp re) 1.0) (sin im) (* (exp re) im))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = 0.0;
} else if (exp(re) <= 1.0) {
tmp = sin(im);
} 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 (exp(re) <= 0.0d0) then
tmp = 0.0d0
else if (exp(re) <= 1.0d0) then
tmp = sin(im)
else
tmp = exp(re) * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 0.0) {
tmp = 0.0;
} else if (Math.exp(re) <= 1.0) {
tmp = Math.sin(im);
} else {
tmp = Math.exp(re) * im;
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.0: tmp = 0.0 elif math.exp(re) <= 1.0: tmp = math.sin(im) else: tmp = math.exp(re) * im return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = 0.0; elseif (exp(re) <= 1.0) tmp = sin(im); else tmp = Float64(exp(re) * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 0.0) tmp = 0.0; elseif (exp(re) <= 1.0) tmp = sin(im); else tmp = exp(re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], 0.0, If[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Sin[im], $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;0\\
\mathbf{elif}\;e^{re} \leq 1:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0Initial program 100.0%
add-log-exp_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in im around 0 100.0%
if 0.0 < (exp.f64 re) < 1Initial program 100.0%
Taylor expanded in re around 0 99.1%
if 1 < (exp.f64 re) Initial program 99.9%
Taylor expanded in im around 0 82.7%
Final simplification96.0%
(FPCore (re im)
:precision binary64
(if (<= re -1.6)
0.0
(if (or (<= re 0.031) (not (<= re 1e+103)))
(*
(sin im)
(+ (* (* re re) (+ (* re 0.16666666666666666) 0.5)) (+ re 1.0)))
(* (exp re) im))))
double code(double re, double im) {
double tmp;
if (re <= -1.6) {
tmp = 0.0;
} else if ((re <= 0.031) || !(re <= 1e+103)) {
tmp = sin(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (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.6d0)) then
tmp = 0.0d0
else if ((re <= 0.031d0) .or. (.not. (re <= 1d+103))) then
tmp = sin(im) * (((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)) + (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.6) {
tmp = 0.0;
} else if ((re <= 0.031) || !(re <= 1e+103)) {
tmp = Math.sin(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0));
} else {
tmp = Math.exp(re) * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.6: tmp = 0.0 elif (re <= 0.031) or not (re <= 1e+103): tmp = math.sin(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)) else: tmp = math.exp(re) * im return tmp
function code(re, im) tmp = 0.0 if (re <= -1.6) tmp = 0.0; elseif ((re <= 0.031) || !(re <= 1e+103)) tmp = Float64(sin(im) * Float64(Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)) + 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.6) tmp = 0.0; elseif ((re <= 0.031) || ~((re <= 1e+103))) tmp = sin(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)); else tmp = exp(re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.6], 0.0, If[Or[LessEqual[re, 0.031], N[Not[LessEqual[re, 1e+103]], $MachinePrecision]], N[(N[Sin[im], $MachinePrecision] * N[(N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.6:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 0.031 \lor \neg \left(re \leq 10^{+103}\right):\\
\;\;\;\;\sin im \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right) + \left(re + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\
\end{array}
\end{array}
if re < -1.6000000000000001Initial program 100.0%
add-log-exp_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in im around 0 100.0%
if -1.6000000000000001 < re < 0.031 or 1e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.7%
associate-+r+99.7%
+-commutative99.7%
associate-+r+99.7%
distribute-rgt1-in99.7%
*-commutative99.7%
associate-*r*99.7%
associate-*r*99.7%
distribute-rgt-out99.7%
distribute-lft-out99.7%
+-commutative99.7%
Simplified99.7%
if 0.031 < re < 1e103Initial program 99.9%
Taylor expanded in im around 0 93.2%
Final simplification99.4%
(FPCore (re im)
:precision binary64
(if (<= re -90.0)
0.0
(if (<= re 0.0046)
(* (sin im) (+ (+ re 1.0) (* re (* re 0.5))))
(if (<= re 1.35e+154) (* (exp re) im) (* (sin im) (* (* re re) 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -90.0) {
tmp = 0.0;
} else if (re <= 0.0046) {
tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 1.35e+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 <= (-90.0d0)) then
tmp = 0.0d0
else if (re <= 0.0046d0) then
tmp = sin(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
else if (re <= 1.35d+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 <= -90.0) {
tmp = 0.0;
} else if (re <= 0.0046) {
tmp = Math.sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 1.35e+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 <= -90.0: tmp = 0.0 elif re <= 0.0046: tmp = math.sin(im) * ((re + 1.0) + (re * (re * 0.5))) elif re <= 1.35e+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 <= -90.0) tmp = 0.0; elseif (re <= 0.0046) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); elseif (re <= 1.35e+154) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -90.0) tmp = 0.0; elseif (re <= 0.0046) tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5))); elseif (re <= 1.35e+154) tmp = exp(re) * im; else tmp = sin(im) * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -90.0], 0.0, If[LessEqual[re, 0.0046], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -90:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 0.0046:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -90Initial program 100.0%
add-log-exp_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in im around 0 100.0%
if -90 < re < 0.0045999999999999999Initial program 100.0%
Taylor expanded in re around 0 99.6%
associate-+r+99.6%
+-commutative99.6%
associate-+r+99.6%
distribute-rgt1-in99.6%
*-commutative99.6%
associate-*r*99.6%
associate-*r*99.6%
distribute-rgt-out99.6%
distribute-lft-out99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in re around 0 99.5%
*-commutative99.5%
unpow299.5%
associate-*r*99.5%
Simplified99.5%
if 0.0045999999999999999 < re < 1.35000000000000003e154Initial program 99.9%
Taylor expanded in im around 0 95.9%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+r+100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
unpow2100.0%
associate-*r*100.0%
unpow2100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Final simplification99.3%
(FPCore (re im)
:precision binary64
(if (<= re -1.0)
0.0
(if (<= re 0.00145)
(* (sin im) (+ re 1.0))
(if (<= re 1.35e+154) (* (exp re) im) (* (sin im) (* (* re re) 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = 0.0;
} else if (re <= 0.00145) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 1.35e+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 <= (-1.0d0)) then
tmp = 0.0d0
else if (re <= 0.00145d0) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 1.35d+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 <= -1.0) {
tmp = 0.0;
} else if (re <= 0.00145) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 1.35e+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 <= -1.0: tmp = 0.0 elif re <= 0.00145: tmp = math.sin(im) * (re + 1.0) elif re <= 1.35e+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 <= -1.0) tmp = 0.0; elseif (re <= 0.00145) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 1.35e+154) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(Float64(re * re) * 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.00145) tmp = sin(im) * (re + 1.0); elseif (re <= 1.35e+154) tmp = exp(re) * im; else tmp = sin(im) * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.0], 0.0, If[LessEqual[re, 0.00145], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 0.00145:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
add-log-exp_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in im around 0 100.0%
if -1 < re < 0.00145Initial program 100.0%
Taylor expanded in re around 0 98.9%
distribute-rgt1-in98.9%
Simplified98.9%
if 0.00145 < re < 1.35000000000000003e154Initial program 99.9%
Taylor expanded in im around 0 95.9%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+r+100.0%
distribute-rgt1-in100.0%
*-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
unpow2100.0%
associate-*r*100.0%
unpow2100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
unpow2100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Final simplification99.0%
(FPCore (re im) :precision binary64 (if (<= re -1.0) 0.0 (if (<= re 0.00064) (* (sin im) (+ re 1.0)) (* (exp re) im))))
double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = 0.0;
} else if (re <= 0.00064) {
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 = 0.0d0
else if (re <= 0.00064d0) 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 = 0.0;
} else if (re <= 0.00064) {
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 = 0.0 elif re <= 0.00064: 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 = 0.0; elseif (re <= 0.00064) 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 = 0.0; elseif (re <= 0.00064) tmp = sin(im) * (re + 1.0); else tmp = exp(re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.0], 0.0, If[LessEqual[re, 0.00064], 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:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 0.00064:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\
\end{array}
\end{array}
if re < -1Initial program 100.0%
add-log-exp_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in im around 0 100.0%
if -1 < re < 6.40000000000000052e-4Initial program 100.0%
Taylor expanded in re around 0 98.9%
distribute-rgt1-in98.9%
Simplified98.9%
if 6.40000000000000052e-4 < re Initial program 100.0%
Taylor expanded in im around 0 83.6%
Final simplification96.3%
(FPCore (re im) :precision binary64 (if (<= re -74.0) 0.0 (if (<= re 1.75e-8) (sin im) (+ im (* im (+ re (* re (* re 0.5))))))))
double code(double re, double im) {
double tmp;
if (re <= -74.0) {
tmp = 0.0;
} else if (re <= 1.75e-8) {
tmp = sin(im);
} else {
tmp = im + (im * (re + (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 <= (-74.0d0)) then
tmp = 0.0d0
else if (re <= 1.75d-8) then
tmp = sin(im)
else
tmp = im + (im * (re + (re * (re * 0.5d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -74.0) {
tmp = 0.0;
} else if (re <= 1.75e-8) {
tmp = Math.sin(im);
} else {
tmp = im + (im * (re + (re * (re * 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -74.0: tmp = 0.0 elif re <= 1.75e-8: tmp = math.sin(im) else: tmp = im + (im * (re + (re * (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -74.0) tmp = 0.0; elseif (re <= 1.75e-8) tmp = sin(im); else tmp = Float64(im + Float64(im * Float64(re + Float64(re * Float64(re * 0.5))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -74.0) tmp = 0.0; elseif (re <= 1.75e-8) tmp = sin(im); else tmp = im + (im * (re + (re * (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -74.0], 0.0, If[LessEqual[re, 1.75e-8], N[Sin[im], $MachinePrecision], N[(im + N[(im * N[(re + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -74:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 1.75 \cdot 10^{-8}:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;im + im \cdot \left(re + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -74Initial program 100.0%
add-log-exp_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in im around 0 100.0%
if -74 < re < 1.75000000000000012e-8Initial program 100.0%
Taylor expanded in re around 0 99.1%
if 1.75000000000000012e-8 < re Initial program 99.9%
Taylor expanded in im around 0 82.7%
Taylor expanded in re around 0 44.7%
fma-def44.7%
unpow244.7%
Simplified44.7%
fma-udef44.7%
*-commutative44.7%
associate-*r*44.7%
*-commutative44.7%
*-commutative44.7%
distribute-rgt-out44.7%
associate-*l*44.7%
Applied egg-rr44.7%
Final simplification88.3%
(FPCore (re im) :precision binary64 (if (<= re -5.8e-25) 0.0 (+ im (* im (+ re (* re (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if (re <= -5.8e-25) {
tmp = 0.0;
} else {
tmp = im + (im * (re + (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 <= (-5.8d-25)) then
tmp = 0.0d0
else
tmp = im + (im * (re + (re * (re * 0.5d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -5.8e-25) {
tmp = 0.0;
} else {
tmp = im + (im * (re + (re * (re * 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -5.8e-25: tmp = 0.0 else: tmp = im + (im * (re + (re * (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -5.8e-25) tmp = 0.0; else tmp = Float64(im + Float64(im * Float64(re + Float64(re * Float64(re * 0.5))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -5.8e-25) tmp = 0.0; else tmp = im + (im * (re + (re * (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -5.8e-25], 0.0, N[(im + N[(im * N[(re + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -5.8 \cdot 10^{-25}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;im + im \cdot \left(re + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -5.8000000000000001e-25Initial program 100.0%
add-log-exp_binary6499.9%
Applied rewrite-once99.9%
Taylor expanded in im around 0 91.4%
if -5.8000000000000001e-25 < re Initial program 100.0%
Taylor expanded in im around 0 58.3%
Taylor expanded in re around 0 47.1%
fma-def47.1%
unpow247.1%
Simplified47.1%
fma-udef47.1%
*-commutative47.1%
associate-*r*47.1%
*-commutative47.1%
*-commutative47.1%
distribute-rgt-out47.1%
associate-*l*47.1%
Applied egg-rr47.1%
Final simplification60.8%
(FPCore (re im) :precision binary64 (+ im (* im (+ re (* re (* re 0.5))))))
double code(double re, double im) {
return im + (im * (re + (re * (re * 0.5))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im + (im * (re + (re * (re * 0.5d0))))
end function
public static double code(double re, double im) {
return im + (im * (re + (re * (re * 0.5))));
}
def code(re, im): return im + (im * (re + (re * (re * 0.5))))
function code(re, im) return Float64(im + Float64(im * Float64(re + Float64(re * Float64(re * 0.5))))) end
function tmp = code(re, im) tmp = im + (im * (re + (re * (re * 0.5)))); end
code[re_, im_] := N[(im + N[(im * N[(re + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im + im \cdot \left(re + re \cdot \left(re \cdot 0.5\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 68.5%
Taylor expanded in re around 0 33.2%
fma-def33.2%
unpow233.2%
Simplified33.2%
fma-udef33.2%
*-commutative33.2%
associate-*r*33.2%
*-commutative33.2%
*-commutative33.2%
distribute-rgt-out33.3%
associate-*l*33.3%
Applied egg-rr33.3%
Final simplification33.3%
(FPCore (re im) :precision binary64 (+ im (* 0.5 (* im (* re re)))))
double code(double re, double im) {
return im + (0.5 * (im * (re * re)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im + (0.5d0 * (im * (re * re)))
end function
public static double code(double re, double im) {
return im + (0.5 * (im * (re * re)));
}
def code(re, im): return im + (0.5 * (im * (re * re)))
function code(re, im) return Float64(im + Float64(0.5 * Float64(im * Float64(re * re)))) end
function tmp = code(re, im) tmp = im + (0.5 * (im * (re * re))); end
code[re_, im_] := N[(im + N[(0.5 * N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im + 0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 68.5%
Taylor expanded in re around 0 33.2%
fma-def33.2%
unpow233.2%
Simplified33.2%
fma-udef33.2%
associate-*r*31.4%
associate-*r*31.4%
distribute-rgt-out31.5%
*-commutative31.5%
Applied egg-rr31.5%
Taylor expanded in re around inf 32.8%
unpow232.8%
Simplified32.8%
Final simplification32.8%
(FPCore (re im) :precision binary64 (if (<= re 1.0) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 1.0) {
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.0d0) 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.0) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.0: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 1.0) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.0) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.0], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 1Initial program 100.0%
Taylor expanded in im around 0 65.1%
Taylor expanded in re around 0 31.0%
if 1 < re Initial program 100.0%
Taylor expanded in re around 0 4.3%
distribute-rgt1-in4.3%
Simplified4.3%
Taylor expanded in re around inf 4.3%
*-commutative4.3%
Simplified4.3%
Taylor expanded in im around 0 15.2%
Final simplification28.0%
(FPCore (re im) :precision binary64 (+ im (* re im)))
double code(double re, double im) {
return im + (re * im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im + (re * im)
end function
public static double code(double re, double im) {
return im + (re * im);
}
def code(re, im): return im + (re * im)
function code(re, im) return Float64(im + Float64(re * im)) end
function tmp = code(re, im) tmp = im + (re * im); end
code[re_, im_] := N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im + re \cdot im
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 68.5%
Taylor expanded in re around 0 28.0%
Final simplification28.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 100.0%
Taylor expanded in im around 0 68.5%
Taylor expanded in re around 0 25.6%
Final simplification25.6%
herbie shell --seed 2023297
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))