
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.999995) (not (<= (exp re) 1.0))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.999995) || !(exp(re) <= 1.0)) {
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.0d0))) 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.0)) {
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.0): 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.0)) 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.0))) 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.0]], $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\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.99999499999999997 or 1 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 89.3%
if 0.99999499999999997 < (exp.f64 re) < 1Initial program 100.0%
Taylor expanded in re around 0 99.1%
Final simplification93.7%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.044) (and (not (<= re 0.076)) (<= re 1.05e+103)))
(* (exp re) im)
(*
(sin im)
(+ (+ re 1.0) (* (* re re) (+ (* re 0.16666666666666666) 0.5))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.044) || (!(re <= 0.076) && (re <= 1.05e+103))) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 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.044d0)) .or. (.not. (re <= 0.076d0)) .and. (re <= 1.05d+103)) then
tmp = exp(re) * im
else
tmp = sin(im) * ((re + 1.0d0) + ((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.044) || (!(re <= 0.076) && (re <= 1.05e+103))) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.044) or (not (re <= 0.076) and (re <= 1.05e+103)): tmp = math.exp(re) * im else: tmp = math.sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.044) || (!(re <= 0.076) && (re <= 1.05e+103))) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.044) || (~((re <= 0.076)) && (re <= 1.05e+103))) tmp = exp(re) * im; else tmp = sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.044], And[N[Not[LessEqual[re, 0.076]], $MachinePrecision], LessEqual[re, 1.05e+103]]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.044 \lor \neg \left(re \leq 0.076\right) \land re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.043999999999999997 or 0.0759999999999999981 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 95.6%
if -0.043999999999999997 < re < 0.0759999999999999981 or 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 99.6%
associate-+r+99.6%
*-commutative99.6%
distribute-rgt1-in99.6%
*-commutative99.6%
+-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
associate-*r*99.6%
distribute-rgt-out99.6%
distribute-lft-out99.6%
+-commutative99.6%
Simplified99.6%
Final simplification98.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))) (t_1 (* (exp re) im)))
(if (<= re -0.043)
t_1
(if (<= re 0.015)
(* (sin im) (+ (+ re 1.0) t_0))
(if (<= re 8.8e+138) t_1 (* (sin im) t_0))))))
double code(double re, double im) {
double t_0 = re * (re * 0.5);
double t_1 = exp(re) * im;
double tmp;
if (re <= -0.043) {
tmp = t_1;
} else if (re <= 0.015) {
tmp = sin(im) * ((re + 1.0) + t_0);
} else if (re <= 8.8e+138) {
tmp = t_1;
} else {
tmp = sin(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) :: t_1
real(8) :: tmp
t_0 = re * (re * 0.5d0)
t_1 = exp(re) * im
if (re <= (-0.043d0)) then
tmp = t_1
else if (re <= 0.015d0) then
tmp = sin(im) * ((re + 1.0d0) + t_0)
else if (re <= 8.8d+138) then
tmp = t_1
else
tmp = sin(im) * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (re * 0.5);
double t_1 = Math.exp(re) * im;
double tmp;
if (re <= -0.043) {
tmp = t_1;
} else if (re <= 0.015) {
tmp = Math.sin(im) * ((re + 1.0) + t_0);
} else if (re <= 8.8e+138) {
tmp = t_1;
} else {
tmp = Math.sin(im) * t_0;
}
return tmp;
}
def code(re, im): t_0 = re * (re * 0.5) t_1 = math.exp(re) * im tmp = 0 if re <= -0.043: tmp = t_1 elif re <= 0.015: tmp = math.sin(im) * ((re + 1.0) + t_0) elif re <= 8.8e+138: tmp = t_1 else: tmp = math.sin(im) * t_0 return tmp
function code(re, im) t_0 = Float64(re * Float64(re * 0.5)) t_1 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.043) tmp = t_1; elseif (re <= 0.015) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + t_0)); elseif (re <= 8.8e+138) tmp = t_1; else tmp = Float64(sin(im) * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = re * (re * 0.5); t_1 = exp(re) * im; tmp = 0.0; if (re <= -0.043) tmp = t_1; elseif (re <= 0.015) tmp = sin(im) * ((re + 1.0) + t_0); elseif (re <= 8.8e+138) tmp = t_1; else tmp = sin(im) * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.043], t$95$1, If[LessEqual[re, 0.015], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 8.8e+138], t$95$1, N[(N[Sin[im], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(re \cdot 0.5\right)\\
t_1 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.043:\\
\;\;\;\;t_1\\
\mathbf{elif}\;re \leq 0.015:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + t_0\right)\\
\mathbf{elif}\;re \leq 8.8 \cdot 10^{+138}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot t_0\\
\end{array}
\end{array}
if re < -0.042999999999999997 or 0.014999999999999999 < re < 8.8000000000000003e138Initial program 100.0%
Taylor expanded in im around 0 94.1%
if -0.042999999999999997 < re < 0.014999999999999999Initial program 100.0%
Taylor expanded in re around 0 99.0%
associate-+r+99.0%
+-commutative99.0%
*-commutative99.0%
distribute-lft1-in99.0%
*-commutative99.0%
associate-*r*99.0%
distribute-rgt-out99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.0%
Simplified99.0%
if 8.8000000000000003e138 < re Initial program 100.0%
Taylor expanded in re around 0 97.0%
associate-+r+97.0%
+-commutative97.0%
*-commutative97.0%
distribute-lft1-in97.0%
*-commutative97.0%
associate-*r*97.0%
distribute-rgt-out97.0%
*-commutative97.0%
unpow297.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in re around inf 97.0%
unpow297.0%
*-commutative97.0%
associate-*r*97.0%
Simplified97.0%
Final simplification96.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.0028)
t_0
(if (<= re 8.7e-16)
(* (sin im) (+ re 1.0))
(if (<= re 8.8e+138) 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.0028) {
tmp = t_0;
} else if (re <= 8.7e-16) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 8.8e+138) {
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.0028d0)) then
tmp = t_0
else if (re <= 8.7d-16) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 8.8d+138) 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.0028) {
tmp = t_0;
} else if (re <= 8.7e-16) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 8.8e+138) {
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.0028: tmp = t_0 elif re <= 8.7e-16: tmp = math.sin(im) * (re + 1.0) elif re <= 8.8e+138: 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.0028) tmp = t_0; elseif (re <= 8.7e-16) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 8.8e+138) 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.0028) tmp = t_0; elseif (re <= 8.7e-16) tmp = sin(im) * (re + 1.0); elseif (re <= 8.8e+138) 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.0028], t$95$0, If[LessEqual[re, 8.7e-16], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 8.8e+138], 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.0028:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 8.7 \cdot 10^{-16}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 8.8 \cdot 10^{+138}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.00279999999999999997 or 8.70000000000000036e-16 < re < 8.8000000000000003e138Initial program 100.0%
Taylor expanded in im around 0 93.3%
if -0.00279999999999999997 < re < 8.70000000000000036e-16Initial program 100.0%
Taylor expanded in re around 0 99.2%
*-commutative99.2%
distribute-rgt1-in99.1%
Simplified99.1%
if 8.8000000000000003e138 < re Initial program 100.0%
Taylor expanded in re around 0 97.0%
associate-+r+97.0%
+-commutative97.0%
*-commutative97.0%
distribute-lft1-in97.0%
*-commutative97.0%
associate-*r*97.0%
distribute-rgt-out97.0%
*-commutative97.0%
unpow297.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in re around inf 97.0%
unpow297.0%
*-commutative97.0%
associate-*r*97.0%
Simplified97.0%
Final simplification96.4%
(FPCore (re im) :precision binary64 (if (or (<= re -0.00375) (not (<= re 8.7e-16))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.00375) || !(re <= 8.7e-16)) {
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.00375d0)) .or. (.not. (re <= 8.7d-16))) 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.00375) || !(re <= 8.7e-16)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.00375) or not (re <= 8.7e-16): 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.00375) || !(re <= 8.7e-16)) 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.00375) || ~((re <= 8.7e-16))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.00375], N[Not[LessEqual[re, 8.7e-16]], $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.00375 \lor \neg \left(re \leq 8.7 \cdot 10^{-16}\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -0.0037499999999999999 or 8.70000000000000036e-16 < re Initial program 100.0%
Taylor expanded in im around 0 89.8%
if -0.0037499999999999999 < re < 8.70000000000000036e-16Initial program 100.0%
Taylor expanded in re around 0 99.2%
*-commutative99.2%
distribute-rgt1-in99.1%
Simplified99.1%
Final simplification94.0%
(FPCore (re im) :precision binary64 (if (<= re -9.6e+120) (- (* re (* re (/ (- im) (- 1.0 re)))) (/ im (+ re -1.0))) (if (<= re 3.1) (sin im) (* im (* (* re re) 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -9.6e+120) {
tmp = (re * (re * (-im / (1.0 - re)))) - (im / (re + -1.0));
} else if (re <= 3.1) {
tmp = sin(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 <= (-9.6d+120)) then
tmp = (re * (re * (-im / (1.0d0 - re)))) - (im / (re + (-1.0d0)))
else if (re <= 3.1d0) then
tmp = sin(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 <= -9.6e+120) {
tmp = (re * (re * (-im / (1.0 - re)))) - (im / (re + -1.0));
} else if (re <= 3.1) {
tmp = Math.sin(im);
} else {
tmp = im * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -9.6e+120: tmp = (re * (re * (-im / (1.0 - re)))) - (im / (re + -1.0)) elif re <= 3.1: tmp = math.sin(im) else: tmp = im * ((re * re) * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= -9.6e+120) tmp = Float64(Float64(re * Float64(re * Float64(Float64(-im) / Float64(1.0 - re)))) - Float64(im / Float64(re + -1.0))); elseif (re <= 3.1) tmp = sin(im); else tmp = Float64(im * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -9.6e+120) tmp = (re * (re * (-im / (1.0 - re)))) - (im / (re + -1.0)); elseif (re <= 3.1) tmp = sin(im); else tmp = im * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -9.6e+120], N[(N[(re * N[(re * N[((-im) / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im / N[(re + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.1], N[Sin[im], $MachinePrecision], N[(im * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -9.6 \cdot 10^{+120}:\\
\;\;\;\;re \cdot \left(re \cdot \frac{-im}{1 - re}\right) - \frac{im}{re + -1}\\
\mathbf{elif}\;re \leq 3.1:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -9.60000000000000004e120Initial program 100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 2.5%
distribute-lft1-in2.5%
+-commutative2.5%
*-commutative2.5%
flip-+1.9%
associate-*r/1.9%
metadata-eval1.9%
Applied egg-rr1.9%
*-commutative1.9%
associate-/l*9.9%
Simplified9.9%
div-sub9.9%
frac-2neg9.9%
associate-/r/9.9%
fma-neg9.9%
div-inv9.9%
clear-num9.9%
Applied egg-rr9.9%
fma-udef9.9%
+-commutative9.9%
distribute-rgt-neg-out9.9%
associate-/r/9.9%
unsub-neg9.9%
distribute-rgt-neg-in9.9%
associate-*l*55.3%
distribute-neg-frac55.3%
associate-/r/55.3%
associate-*l/55.3%
*-lft-identity55.3%
sub-neg55.3%
+-commutative55.3%
distribute-neg-in55.3%
remove-double-neg55.3%
metadata-eval55.3%
Simplified55.3%
if -9.60000000000000004e120 < re < 3.10000000000000009Initial program 100.0%
Taylor expanded in re around 0 76.6%
if 3.10000000000000009 < re Initial program 100.0%
Taylor expanded in re around 0 53.5%
associate-+r+53.5%
+-commutative53.5%
*-commutative53.5%
distribute-lft1-in53.5%
*-commutative53.5%
associate-*r*53.5%
distribute-rgt-out53.5%
*-commutative53.5%
unpow253.5%
associate-*l*53.5%
Simplified53.5%
Taylor expanded in re around inf 53.5%
unpow253.5%
*-commutative53.5%
associate-*r*53.5%
Simplified53.5%
Taylor expanded in im around 0 47.7%
*-commutative47.7%
associate-*l*47.7%
unpow247.7%
Simplified47.7%
Taylor expanded in re around 0 47.7%
unpow247.7%
associate-*r*47.7%
*-commutative47.7%
Simplified47.7%
Final simplification66.3%
(FPCore (re im) :precision binary64 (if (<= re 0.84) (- (* re (* re (/ (- im) (- 1.0 re)))) (/ im (+ re -1.0))) (* im (* (* re re) 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 0.84) {
tmp = (re * (re * (-im / (1.0 - re)))) - (im / (re + -1.0));
} 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 <= 0.84d0) then
tmp = (re * (re * (-im / (1.0d0 - re)))) - (im / (re + (-1.0d0)))
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 <= 0.84) {
tmp = (re * (re * (-im / (1.0 - re)))) - (im / (re + -1.0));
} else {
tmp = im * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.84: tmp = (re * (re * (-im / (1.0 - re)))) - (im / (re + -1.0)) else: tmp = im * ((re * re) * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.84) tmp = Float64(Float64(re * Float64(re * Float64(Float64(-im) / Float64(1.0 - re)))) - Float64(im / Float64(re + -1.0))); else tmp = Float64(im * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.84) tmp = (re * (re * (-im / (1.0 - re)))) - (im / (re + -1.0)); else tmp = im * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.84], N[(N[(re * N[(re * N[((-im) / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im / N[(re + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.84:\\
\;\;\;\;re \cdot \left(re \cdot \frac{-im}{1 - re}\right) - \frac{im}{re + -1}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 0.839999999999999969Initial program 100.0%
Taylor expanded in im around 0 69.0%
Taylor expanded in re around 0 30.7%
distribute-lft1-in30.7%
+-commutative30.7%
*-commutative30.7%
flip-+30.6%
associate-*r/30.6%
metadata-eval30.6%
Applied egg-rr30.6%
*-commutative30.6%
associate-/l*32.8%
Simplified32.8%
div-sub32.8%
frac-2neg32.8%
associate-/r/32.8%
fma-neg32.8%
div-inv32.8%
clear-num32.4%
Applied egg-rr32.4%
fma-udef32.4%
+-commutative32.4%
distribute-rgt-neg-out32.4%
associate-/r/32.3%
unsub-neg32.3%
distribute-rgt-neg-in32.3%
associate-*l*42.5%
distribute-neg-frac42.5%
associate-/r/42.6%
associate-*l/42.6%
*-lft-identity42.6%
sub-neg42.6%
+-commutative42.6%
distribute-neg-in42.6%
remove-double-neg42.6%
metadata-eval42.6%
Simplified42.6%
if 0.839999999999999969 < re Initial program 100.0%
Taylor expanded in re around 0 53.0%
associate-+r+53.0%
+-commutative53.0%
*-commutative53.0%
distribute-lft1-in53.0%
*-commutative53.0%
associate-*r*53.0%
distribute-rgt-out53.0%
*-commutative53.0%
unpow253.0%
associate-*l*53.0%
Simplified53.0%
Taylor expanded in re around inf 52.9%
unpow252.9%
*-commutative52.9%
associate-*r*52.9%
Simplified52.9%
Taylor expanded in im around 0 47.0%
*-commutative47.0%
associate-*l*47.0%
unpow247.0%
Simplified47.0%
Taylor expanded in re around 0 47.0%
unpow247.0%
associate-*r*47.0%
*-commutative47.0%
Simplified47.0%
Final simplification43.6%
(FPCore (re im) :precision binary64 (if (<= re 0.84) (/ (- 1.0 (* re re)) (- (/ 1.0 im) (/ re im))) (* im (* (* re re) 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 0.84) {
tmp = (1.0 - (re * re)) / ((1.0 / im) - (re / 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 <= 0.84d0) then
tmp = (1.0d0 - (re * re)) / ((1.0d0 / im) - (re / 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 <= 0.84) {
tmp = (1.0 - (re * re)) / ((1.0 / im) - (re / im));
} else {
tmp = im * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.84: tmp = (1.0 - (re * re)) / ((1.0 / im) - (re / im)) else: tmp = im * ((re * re) * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.84) tmp = Float64(Float64(1.0 - Float64(re * re)) / Float64(Float64(1.0 / im) - Float64(re / im))); else tmp = Float64(im * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.84) tmp = (1.0 - (re * re)) / ((1.0 / im) - (re / im)); else tmp = im * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.84], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / im), $MachinePrecision] - N[(re / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.84:\\
\;\;\;\;\frac{1 - re \cdot re}{\frac{1}{im} - \frac{re}{im}}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 0.839999999999999969Initial program 100.0%
Taylor expanded in im around 0 69.0%
Taylor expanded in re around 0 30.7%
distribute-lft1-in30.7%
+-commutative30.7%
*-commutative30.7%
flip-+30.6%
associate-*r/30.6%
metadata-eval30.6%
Applied egg-rr30.6%
*-commutative30.6%
associate-/l*32.8%
Simplified32.8%
div-sub32.8%
Applied egg-rr32.8%
if 0.839999999999999969 < re Initial program 100.0%
Taylor expanded in re around 0 53.0%
associate-+r+53.0%
+-commutative53.0%
*-commutative53.0%
distribute-lft1-in53.0%
*-commutative53.0%
associate-*r*53.0%
distribute-rgt-out53.0%
*-commutative53.0%
unpow253.0%
associate-*l*53.0%
Simplified53.0%
Taylor expanded in re around inf 52.9%
unpow252.9%
*-commutative52.9%
associate-*r*52.9%
Simplified52.9%
Taylor expanded in im around 0 47.0%
*-commutative47.0%
associate-*l*47.0%
unpow247.0%
Simplified47.0%
Taylor expanded in re around 0 47.0%
unpow247.0%
associate-*r*47.0%
*-commutative47.0%
Simplified47.0%
Final simplification36.1%
(FPCore (re im) :precision binary64 (if (<= re 0.84) (/ (- 1.0 (* re re)) (/ (- 1.0 re) im)) (* im (* (* re re) 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 0.84) {
tmp = (1.0 - (re * re)) / ((1.0 - re) / 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 <= 0.84d0) then
tmp = (1.0d0 - (re * re)) / ((1.0d0 - re) / 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 <= 0.84) {
tmp = (1.0 - (re * re)) / ((1.0 - re) / im);
} else {
tmp = im * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.84: tmp = (1.0 - (re * re)) / ((1.0 - re) / im) else: tmp = im * ((re * re) * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.84) tmp = Float64(Float64(1.0 - Float64(re * re)) / Float64(Float64(1.0 - re) / im)); else tmp = Float64(im * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.84) tmp = (1.0 - (re * re)) / ((1.0 - re) / im); else tmp = im * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.84], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - re), $MachinePrecision] / im), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.84:\\
\;\;\;\;\frac{1 - re \cdot re}{\frac{1 - re}{im}}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 0.839999999999999969Initial program 100.0%
Taylor expanded in im around 0 69.0%
Taylor expanded in re around 0 30.7%
distribute-lft1-in30.7%
+-commutative30.7%
*-commutative30.7%
flip-+30.6%
associate-*r/30.6%
metadata-eval30.6%
Applied egg-rr30.6%
*-commutative30.6%
associate-/l*32.8%
Simplified32.8%
if 0.839999999999999969 < re Initial program 100.0%
Taylor expanded in re around 0 53.0%
associate-+r+53.0%
+-commutative53.0%
*-commutative53.0%
distribute-lft1-in53.0%
*-commutative53.0%
associate-*r*53.0%
distribute-rgt-out53.0%
*-commutative53.0%
unpow253.0%
associate-*l*53.0%
Simplified53.0%
Taylor expanded in re around inf 52.9%
unpow252.9%
*-commutative52.9%
associate-*r*52.9%
Simplified52.9%
Taylor expanded in im around 0 47.0%
*-commutative47.0%
associate-*l*47.0%
unpow247.0%
Simplified47.0%
Taylor expanded in re around 0 47.0%
unpow247.0%
associate-*r*47.0%
*-commutative47.0%
Simplified47.0%
Final simplification36.1%
(FPCore (re im) :precision binary64 (if (<= re 0.84) im (* im (* (* re re) 0.5))))
double code(double re, double im) {
double tmp;
if (re <= 0.84) {
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 <= 0.84d0) 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 <= 0.84) {
tmp = im;
} else {
tmp = im * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.84: tmp = im else: tmp = im * ((re * re) * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.84) tmp = im; else tmp = Float64(im * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.84) tmp = im; else tmp = im * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.84], im, N[(im * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.84:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 0.839999999999999969Initial program 100.0%
Taylor expanded in im around 0 69.0%
Taylor expanded in re around 0 30.8%
if 0.839999999999999969 < re Initial program 100.0%
Taylor expanded in re around 0 53.0%
associate-+r+53.0%
+-commutative53.0%
*-commutative53.0%
distribute-lft1-in53.0%
*-commutative53.0%
associate-*r*53.0%
distribute-rgt-out53.0%
*-commutative53.0%
unpow253.0%
associate-*l*53.0%
Simplified53.0%
Taylor expanded in re around inf 52.9%
unpow252.9%
*-commutative52.9%
associate-*r*52.9%
Simplified52.9%
Taylor expanded in im around 0 47.0%
*-commutative47.0%
associate-*l*47.0%
unpow247.0%
Simplified47.0%
Taylor expanded in re around 0 47.0%
unpow247.0%
associate-*r*47.0%
*-commutative47.0%
Simplified47.0%
Final simplification34.6%
(FPCore (re im) :precision binary64 (if (<= re 0.84) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 0.84) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 0.84d0) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.84) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.84: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 0.84) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.84) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.84], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.84:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 0.839999999999999969Initial program 100.0%
Taylor expanded in im around 0 69.0%
Taylor expanded in re around 0 30.8%
if 0.839999999999999969 < re Initial program 100.0%
Taylor expanded in im around 0 78.4%
Taylor expanded in re around 0 15.2%
Taylor expanded in re around inf 15.2%
Final simplification27.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 47.9%
*-commutative47.9%
distribute-rgt1-in47.9%
Simplified47.9%
Taylor expanded in im around 0 27.1%
Final simplification27.1%
(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 71.2%
Taylor expanded in re around 0 27.1%
Final simplification27.1%
(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 71.2%
Taylor expanded in re around 0 24.4%
Final simplification24.4%
herbie shell --seed 2023201
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))