
(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 16 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.6) (not (<= (exp re) 1.0000000000005))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.6) || !(exp(re) <= 1.0000000000005)) {
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.6d0) .or. (.not. (exp(re) <= 1.0000000000005d0))) 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.6) || !(Math.exp(re) <= 1.0000000000005)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.6) or not (math.exp(re) <= 1.0000000000005): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.6) || !(exp(re) <= 1.0000000000005)) 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.6) || ~((exp(re) <= 1.0000000000005))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.6], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.0000000000005]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.6 \lor \neg \left(e^{re} \leq 1.0000000000005\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.599999999999999978 or 1.0000000000005 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 86.8%
if 0.599999999999999978 < (exp.f64 re) < 1.0000000000005Initial program 100.0%
Taylor expanded in re around 0 99.7%
Final simplification93.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.00048)
t_0
(if (<= re 6.5e-13)
(* (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 <= -0.00048) {
tmp = t_0;
} else if (re <= 6.5e-13) {
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 <= (-0.00048d0)) then
tmp = t_0
else if (re <= 6.5d-13) 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 <= -0.00048) {
tmp = t_0;
} else if (re <= 6.5e-13) {
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 <= -0.00048: tmp = t_0 elif re <= 6.5e-13: 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 <= -0.00048) tmp = t_0; elseif (re <= 6.5e-13) 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 <= -0.00048) tmp = t_0; elseif (re <= 6.5e-13) 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, -0.00048], t$95$0, If[LessEqual[re, 6.5e-13], 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 -0.00048:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 6.5 \cdot 10^{-13}:\\
\;\;\;\;\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 < -4.80000000000000012e-4 or 6.49999999999999957e-13 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 91.5%
if -4.80000000000000012e-4 < re < 6.49999999999999957e-13Initial 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%
unpow2100.0%
associate-*r*100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification96.5%
(FPCore (re im) :precision binary64 (if (or (<= re -0.000465) (not (<= re 6.5e-13))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.000465) || !(re <= 6.5e-13)) {
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.000465d0)) .or. (.not. (re <= 6.5d-13))) 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.000465) || !(re <= 6.5e-13)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.000465) or not (re <= 6.5e-13): 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.000465) || !(re <= 6.5e-13)) 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.000465) || ~((re <= 6.5e-13))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.000465], N[Not[LessEqual[re, 6.5e-13]], $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.000465 \lor \neg \left(re \leq 6.5 \cdot 10^{-13}\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -4.6500000000000003e-4 or 6.49999999999999957e-13 < re Initial program 100.0%
Taylor expanded in im around 0 86.8%
if -4.6500000000000003e-4 < re < 6.49999999999999957e-13Initial program 100.0%
Taylor expanded in re around 0 100.0%
+-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out100.0%
Simplified100.0%
Final simplification93.3%
(FPCore (re im)
:precision binary64
(if (<= re -118.0)
(* 0.0 (+ (+ re 1.0) (* 0.5 (* re re))))
(if (<= re 6.5e-13)
(sin im)
(+ (+ im (* re im)) (* (* re re) (* im 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -118.0) {
tmp = 0.0 * ((re + 1.0) + (0.5 * (re * re)));
} else if (re <= 6.5e-13) {
tmp = sin(im);
} else {
tmp = (im + (re * im)) + ((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 <= (-118.0d0)) then
tmp = 0.0d0 * ((re + 1.0d0) + (0.5d0 * (re * re)))
else if (re <= 6.5d-13) then
tmp = sin(im)
else
tmp = (im + (re * im)) + ((re * re) * (im * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -118.0) {
tmp = 0.0 * ((re + 1.0) + (0.5 * (re * re)));
} else if (re <= 6.5e-13) {
tmp = Math.sin(im);
} else {
tmp = (im + (re * im)) + ((re * re) * (im * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -118.0: tmp = 0.0 * ((re + 1.0) + (0.5 * (re * re))) elif re <= 6.5e-13: tmp = math.sin(im) else: tmp = (im + (re * im)) + ((re * re) * (im * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -118.0) tmp = Float64(0.0 * Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re)))); elseif (re <= 6.5e-13) tmp = sin(im); else tmp = Float64(Float64(im + Float64(re * im)) + Float64(Float64(re * re) * Float64(im * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -118.0) tmp = 0.0 * ((re + 1.0) + (0.5 * (re * re))); elseif (re <= 6.5e-13) tmp = sin(im); else tmp = (im + (re * im)) + ((re * re) * (im * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -118.0], N[(0.0 * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 6.5e-13], N[Sin[im], $MachinePrecision], N[(N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -118:\\
\;\;\;\;0 \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\mathbf{elif}\;re \leq 6.5 \cdot 10^{-13}:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;\left(im + re \cdot im\right) + \left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -118Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
*-commutative2.2%
associate-*l*2.2%
distribute-lft-out2.2%
distribute-lft-out2.2%
associate-+l+2.2%
+-commutative2.2%
*-commutative2.2%
unpow22.2%
Simplified2.2%
expm1-log1p-u2.2%
expm1-udef26.3%
log1p-udef26.3%
add-exp-log26.3%
Applied egg-rr26.3%
Taylor expanded in im around 0 49.3%
if -118 < re < 6.49999999999999957e-13Initial program 100.0%
Taylor expanded in re around 0 99.0%
if 6.49999999999999957e-13 < re Initial program 100.0%
Taylor expanded in re around 0 43.5%
*-rgt-identity43.5%
*-commutative43.5%
associate-*l*43.5%
distribute-lft-out43.5%
distribute-lft-out43.4%
associate-+l+43.4%
+-commutative43.4%
*-commutative43.4%
unpow243.4%
Simplified43.4%
Taylor expanded in im around 0 40.3%
distribute-lft-in40.3%
+-commutative40.3%
distribute-rgt-in40.3%
*-un-lft-identity40.3%
*-commutative40.3%
*-commutative40.3%
associate-*l*40.3%
Applied egg-rr40.3%
Final simplification72.0%
(FPCore (re im) :precision binary64 (if (<= re -70.0) (* 0.0 (+ (+ re 1.0) (* 0.5 (* re re)))) (+ (+ im (* re im)) (* (* re re) (* im 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -70.0) {
tmp = 0.0 * ((re + 1.0) + (0.5 * (re * re)));
} else {
tmp = (im + (re * im)) + ((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 <= (-70.0d0)) then
tmp = 0.0d0 * ((re + 1.0d0) + (0.5d0 * (re * re)))
else
tmp = (im + (re * im)) + ((re * re) * (im * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -70.0) {
tmp = 0.0 * ((re + 1.0) + (0.5 * (re * re)));
} else {
tmp = (im + (re * im)) + ((re * re) * (im * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -70.0: tmp = 0.0 * ((re + 1.0) + (0.5 * (re * re))) else: tmp = (im + (re * im)) + ((re * re) * (im * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -70.0) tmp = Float64(0.0 * Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re)))); else tmp = Float64(Float64(im + Float64(re * im)) + Float64(Float64(re * re) * Float64(im * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -70.0) tmp = 0.0 * ((re + 1.0) + (0.5 * (re * re))); else tmp = (im + (re * im)) + ((re * re) * (im * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -70.0], N[(0.0 * N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -70:\\
\;\;\;\;0 \cdot \left(\left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(im + re \cdot im\right) + \left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -70Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
*-commutative2.2%
associate-*l*2.2%
distribute-lft-out2.2%
distribute-lft-out2.2%
associate-+l+2.2%
+-commutative2.2%
*-commutative2.2%
unpow22.2%
Simplified2.2%
expm1-log1p-u2.2%
expm1-udef26.3%
log1p-udef26.3%
add-exp-log26.3%
Applied egg-rr26.3%
Taylor expanded in im around 0 49.3%
if -70 < re Initial program 100.0%
Taylor expanded in re around 0 81.3%
*-rgt-identity81.3%
*-commutative81.3%
associate-*l*81.3%
distribute-lft-out81.3%
distribute-lft-out81.3%
associate-+l+81.3%
+-commutative81.3%
*-commutative81.3%
unpow281.3%
Simplified81.3%
Taylor expanded in im around 0 47.1%
distribute-lft-in47.1%
+-commutative47.1%
distribute-rgt-in47.1%
*-un-lft-identity47.1%
*-commutative47.1%
*-commutative47.1%
associate-*l*47.1%
Applied egg-rr47.1%
Final simplification47.6%
(FPCore (re im) :precision binary64 (if (<= re -440.0) (* (/ im re) (+ (* re re) -1.0)) (* im (+ (+ re 1.0) (* 0.5 (* re re))))))
double code(double re, double im) {
double tmp;
if (re <= -440.0) {
tmp = (im / re) * ((re * re) + -1.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 <= (-440.0d0)) then
tmp = (im / re) * ((re * re) + (-1.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 <= -440.0) {
tmp = (im / re) * ((re * re) + -1.0);
} else {
tmp = im * ((re + 1.0) + (0.5 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -440.0: tmp = (im / re) * ((re * re) + -1.0) else: tmp = im * ((re + 1.0) + (0.5 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -440.0) tmp = Float64(Float64(im / re) * Float64(Float64(re * re) + -1.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 <= -440.0) tmp = (im / re) * ((re * re) + -1.0); else tmp = im * ((re + 1.0) + (0.5 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -440.0], N[(N[(im / re), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] + -1.0), $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}
\mathbf{if}\;re \leq -440:\\
\;\;\;\;\frac{im}{re} \cdot \left(re \cdot re + -1\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 < -440Initial program 100.0%
Taylor expanded in re around 0 2.9%
+-commutative2.9%
*-rgt-identity2.9%
distribute-lft-out2.9%
Simplified2.9%
Taylor expanded in im around 0 2.7%
+-commutative2.7%
*-commutative2.7%
+-commutative2.7%
flip-+2.3%
associate-*r/2.3%
metadata-eval2.3%
Applied egg-rr2.3%
associate-/l*2.3%
associate-/r/9.1%
Simplified9.1%
Taylor expanded in re around inf 9.1%
associate-*r/9.1%
neg-mul-19.1%
Simplified9.1%
if -440 < re Initial program 100.0%
Taylor expanded in re around 0 81.3%
*-rgt-identity81.3%
*-commutative81.3%
associate-*l*81.3%
distribute-lft-out81.3%
distribute-lft-out81.3%
associate-+l+81.3%
+-commutative81.3%
*-commutative81.3%
unpow281.3%
Simplified81.3%
Taylor expanded in im around 0 47.1%
Final simplification37.1%
(FPCore (re im) :precision binary64 (if (<= re -390.0) (* (- 1.0 (* re re)) (/ im (- 1.0 re))) (* im (+ (+ re 1.0) (* 0.5 (* re re))))))
double code(double re, double im) {
double tmp;
if (re <= -390.0) {
tmp = (1.0 - (re * re)) * (im / (1.0 - re));
} 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 <= (-390.0d0)) then
tmp = (1.0d0 - (re * re)) * (im / (1.0d0 - re))
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 <= -390.0) {
tmp = (1.0 - (re * re)) * (im / (1.0 - re));
} else {
tmp = im * ((re + 1.0) + (0.5 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -390.0: tmp = (1.0 - (re * re)) * (im / (1.0 - re)) else: tmp = im * ((re + 1.0) + (0.5 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -390.0) tmp = Float64(Float64(1.0 - Float64(re * re)) * Float64(im / Float64(1.0 - re))); 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 <= -390.0) tmp = (1.0 - (re * re)) * (im / (1.0 - re)); else tmp = im * ((re + 1.0) + (0.5 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -390.0], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(im / N[(1.0 - re), $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}
\mathbf{if}\;re \leq -390:\\
\;\;\;\;\left(1 - re \cdot re\right) \cdot \frac{im}{1 - re}\\
\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.9%
+-commutative2.9%
*-rgt-identity2.9%
distribute-lft-out2.9%
Simplified2.9%
Taylor expanded in im around 0 2.7%
+-commutative2.7%
*-commutative2.7%
+-commutative2.7%
flip-+2.3%
associate-*r/2.3%
metadata-eval2.3%
Applied egg-rr2.3%
associate-/l*2.3%
associate-/r/9.1%
Simplified9.1%
if -390 < re Initial program 100.0%
Taylor expanded in re around 0 81.3%
*-rgt-identity81.3%
*-commutative81.3%
associate-*l*81.3%
distribute-lft-out81.3%
distribute-lft-out81.3%
associate-+l+81.3%
+-commutative81.3%
*-commutative81.3%
unpow281.3%
Simplified81.3%
Taylor expanded in im around 0 47.1%
Final simplification37.1%
(FPCore (re im) :precision binary64 (if (<= re -600.0) (/ (- 1.0 (* re re)) (/ (- 1.0 re) im)) (* im (+ (+ re 1.0) (* 0.5 (* re re))))))
double code(double re, double im) {
double tmp;
if (re <= -600.0) {
tmp = (1.0 - (re * re)) / ((1.0 - re) / 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) :: tmp
if (re <= (-600.0d0)) then
tmp = (1.0d0 - (re * re)) / ((1.0d0 - re) / 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 tmp;
if (re <= -600.0) {
tmp = (1.0 - (re * re)) / ((1.0 - re) / im);
} else {
tmp = im * ((re + 1.0) + (0.5 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -600.0: tmp = (1.0 - (re * re)) / ((1.0 - re) / im) else: tmp = im * ((re + 1.0) + (0.5 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -600.0) tmp = Float64(Float64(1.0 - Float64(re * re)) / Float64(Float64(1.0 - re) / 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) tmp = 0.0; if (re <= -600.0) tmp = (1.0 - (re * re)) / ((1.0 - re) / im); else tmp = im * ((re + 1.0) + (0.5 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -600.0], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - re), $MachinePrecision] / im), $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}
\mathbf{if}\;re \leq -600:\\
\;\;\;\;\frac{1 - re \cdot re}{\frac{1 - re}{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 < -600Initial program 100.0%
Taylor expanded in re around 0 2.9%
+-commutative2.9%
*-rgt-identity2.9%
distribute-lft-out2.9%
Simplified2.9%
Taylor expanded in im around 0 2.7%
+-commutative2.7%
*-commutative2.7%
+-commutative2.7%
flip-+2.3%
associate-*r/2.3%
metadata-eval2.3%
Applied egg-rr2.3%
associate-/l*2.3%
associate-/r/9.1%
Simplified9.1%
*-commutative9.1%
clear-num12.0%
un-div-inv12.0%
Applied egg-rr12.0%
if -600 < re Initial program 100.0%
Taylor expanded in re around 0 81.3%
*-rgt-identity81.3%
*-commutative81.3%
associate-*l*81.3%
distribute-lft-out81.3%
distribute-lft-out81.3%
associate-+l+81.3%
+-commutative81.3%
*-commutative81.3%
unpow281.3%
Simplified81.3%
Taylor expanded in im around 0 47.1%
Final simplification37.9%
(FPCore (re im) :precision binary64 (let* ((t_0 (+ (+ re 1.0) (* 0.5 (* re re))))) (if (<= re -24.5) (* 0.0 t_0) (* im t_0))))
double code(double re, double im) {
double t_0 = (re + 1.0) + (0.5 * (re * re));
double tmp;
if (re <= -24.5) {
tmp = 0.0 * t_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 = (re + 1.0d0) + (0.5d0 * (re * re))
if (re <= (-24.5d0)) then
tmp = 0.0d0 * t_0
else
tmp = im * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (re + 1.0) + (0.5 * (re * re));
double tmp;
if (re <= -24.5) {
tmp = 0.0 * t_0;
} else {
tmp = im * t_0;
}
return tmp;
}
def code(re, im): t_0 = (re + 1.0) + (0.5 * (re * re)) tmp = 0 if re <= -24.5: tmp = 0.0 * t_0 else: tmp = im * t_0 return tmp
function code(re, im) t_0 = Float64(Float64(re + 1.0) + Float64(0.5 * Float64(re * re))) tmp = 0.0 if (re <= -24.5) tmp = Float64(0.0 * t_0); else tmp = Float64(im * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = (re + 1.0) + (0.5 * (re * re)); tmp = 0.0; if (re <= -24.5) tmp = 0.0 * t_0; else tmp = im * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(re + 1.0), $MachinePrecision] + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -24.5], N[(0.0 * t$95$0), $MachinePrecision], N[(im * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(re + 1\right) + 0.5 \cdot \left(re \cdot re\right)\\
\mathbf{if}\;re \leq -24.5:\\
\;\;\;\;0 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;im \cdot t_0\\
\end{array}
\end{array}
if re < -24.5Initial program 100.0%
Taylor expanded in re around 0 2.2%
*-rgt-identity2.2%
*-commutative2.2%
associate-*l*2.2%
distribute-lft-out2.2%
distribute-lft-out2.2%
associate-+l+2.2%
+-commutative2.2%
*-commutative2.2%
unpow22.2%
Simplified2.2%
expm1-log1p-u2.2%
expm1-udef26.3%
log1p-udef26.3%
add-exp-log26.3%
Applied egg-rr26.3%
Taylor expanded in im around 0 49.3%
if -24.5 < re Initial program 100.0%
Taylor expanded in re around 0 81.3%
*-rgt-identity81.3%
*-commutative81.3%
associate-*l*81.3%
distribute-lft-out81.3%
distribute-lft-out81.3%
associate-+l+81.3%
+-commutative81.3%
*-commutative81.3%
unpow281.3%
Simplified81.3%
Taylor expanded in im around 0 47.1%
Final simplification47.6%
(FPCore (re im) :precision binary64 (if (<= re 0.72) im (* im (+ re (* re (* re 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= 0.72) {
tmp = im;
} else {
tmp = 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 <= 0.72d0) then
tmp = im
else
tmp = im * (re + (re * (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.72) {
tmp = im;
} else {
tmp = im * (re + (re * (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.72: tmp = im else: tmp = im * (re + (re * (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.72) tmp = im; else tmp = 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 <= 0.72) tmp = im; else tmp = im * (re + (re * (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.72], im, N[(im * N[(re + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.72:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(re + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < 0.71999999999999997Initial program 100.0%
Taylor expanded in re around 0 66.2%
Taylor expanded in im around 0 34.5%
if 0.71999999999999997 < re Initial program 100.0%
Taylor expanded in re around 0 42.6%
*-rgt-identity42.6%
*-commutative42.6%
associate-*l*42.6%
distribute-lft-out42.6%
distribute-lft-out42.6%
associate-+l+42.6%
+-commutative42.6%
*-commutative42.6%
unpow242.6%
Simplified42.6%
Taylor expanded in im around 0 39.3%
Taylor expanded in re around inf 39.3%
unpow239.3%
associate-*r*39.3%
*-commutative39.3%
associate-*r*39.3%
distribute-rgt-out39.3%
Simplified39.3%
Final simplification35.6%
(FPCore (re im) :precision binary64 (if (<= re 1.4) im (* im (* re (* re 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= 1.4) {
tmp = im;
} else {
tmp = 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.4d0) then
tmp = im
else
tmp = im * (re * (re * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.4) {
tmp = im;
} else {
tmp = im * (re * (re * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.4: tmp = im else: tmp = im * (re * (re * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.4) tmp = im; else tmp = Float64(im * Float64(re * Float64(re * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.4) tmp = im; else tmp = im * (re * (re * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.4], im, N[(im * N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.4:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < 1.3999999999999999Initial program 100.0%
Taylor expanded in re around 0 66.2%
Taylor expanded in im around 0 34.5%
if 1.3999999999999999 < re Initial program 100.0%
Taylor expanded in re around 0 42.6%
*-rgt-identity42.6%
*-commutative42.6%
associate-*l*42.6%
distribute-lft-out42.6%
distribute-lft-out42.6%
associate-+l+42.6%
+-commutative42.6%
*-commutative42.6%
unpow242.6%
Simplified42.6%
Taylor expanded in im around 0 39.3%
Taylor expanded in re around inf 39.3%
*-commutative39.3%
unpow239.3%
*-commutative39.3%
associate-*r*39.3%
associate-*r*39.3%
Simplified39.3%
Final simplification35.6%
(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 re around 0 66.2%
Taylor expanded in im around 0 34.5%
if 1 < re Initial program 100.0%
Taylor expanded in re around 0 4.1%
+-commutative4.1%
*-rgt-identity4.1%
distribute-lft-out4.1%
Simplified4.1%
Taylor expanded in im around 0 11.1%
Taylor expanded in re around inf 11.1%
Final simplification29.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 52.0%
+-commutative52.0%
*-rgt-identity52.0%
distribute-lft-out52.0%
Simplified52.0%
Taylor expanded in im around 0 29.0%
Final simplification29.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.8%
Taylor expanded in re around 0 29.0%
Final simplification29.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 re around 0 51.8%
Taylor expanded in im around 0 27.2%
Final simplification27.2%
herbie shell --seed 2023224
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))