
(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 11 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.0) (not (<= (exp re) 1.1))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.0) || !(exp(re) <= 1.1)) {
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 ((exp(re) <= 0.0d0) .or. (.not. (exp(re) <= 1.1d0))) 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 ((Math.exp(re) <= 0.0) || !(Math.exp(re) <= 1.1)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.0) or not (math.exp(re) <= 1.1): tmp = math.exp(re) * im else: tmp = math.sin(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.0) || !(exp(re) <= 1.1)) 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 ((exp(re) <= 0.0) || ~((exp(re) <= 1.1))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.1]], $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}\;e^{re} \leq 0 \lor \neg \left(e^{re} \leq 1.1\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 1.1000000000000001 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 85.7%
if 0.0 < (exp.f64 re) < 1.1000000000000001Initial program 100.0%
Taylor expanded in re around 0 99.4%
distribute-rgt1-in99.4%
Simplified99.4%
Final simplification92.7%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 1.0) (not (<= (exp re) 1.1))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 1.0) || !(exp(re) <= 1.1)) {
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) <= 1.0d0) .or. (.not. (exp(re) <= 1.1d0))) 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) <= 1.0) || !(Math.exp(re) <= 1.1)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 1.0) or not (math.exp(re) <= 1.1): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 1.0) || !(exp(re) <= 1.1)) 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) <= 1.0) || ~((exp(re) <= 1.1))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.1]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1 \lor \neg \left(e^{re} \leq 1.1\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 1.1000000000000001 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 69.8%
if 1 < (exp.f64 re) < 1.1000000000000001Initial program 100.0%
Taylor expanded in re around 0 63.1%
Final simplification69.7%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.025) (and (not (<= re 0.06)) (<= re 1.05e+103)))
(* (exp re) im)
(*
(sin im)
(+ (* (* re re) (+ (* re 0.16666666666666666) 0.5)) (+ re 1.0)))))
double code(double re, double im) {
double tmp;
if ((re <= -0.025) || (!(re <= 0.06) && (re <= 1.05e+103))) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (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.025d0)) .or. (.not. (re <= 0.06d0)) .and. (re <= 1.05d+103)) then
tmp = exp(re) * im
else
tmp = sin(im) * (((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)) + (re + 1.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.025) || (!(re <= 0.06) && (re <= 1.05e+103))) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.025) or (not (re <= 0.06) and (re <= 1.05e+103)): tmp = math.exp(re) * im else: tmp = math.sin(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.025) || (!(re <= 0.06) && (re <= 1.05e+103))) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)) + Float64(re + 1.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.025) || (~((re <= 0.06)) && (re <= 1.05e+103))) tmp = exp(re) * im; else tmp = sin(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.025], And[N[Not[LessEqual[re, 0.06]], $MachinePrecision], LessEqual[re, 1.05e+103]]], N[(N[Exp[re], $MachinePrecision] * im), $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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.025 \lor \neg \left(re \leq 0.06\right) \land re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right) + \left(re + 1\right)\right)\\
\end{array}
\end{array}
if re < -0.025000000000000001 or 0.059999999999999998 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 91.8%
if -0.025000000000000001 < re < 0.059999999999999998 or 1.0500000000000001e103 < 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%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
Simplified100.0%
Final simplification97.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))) (t_1 (* (exp re) im)))
(if (<= re -0.0075)
t_1
(if (<= re 0.0055)
(* (sin im) (+ (+ re 1.0) t_0))
(if (<= re 4.9e+151) 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.0075) {
tmp = t_1;
} else if (re <= 0.0055) {
tmp = sin(im) * ((re + 1.0) + t_0);
} else if (re <= 4.9e+151) {
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.0075d0)) then
tmp = t_1
else if (re <= 0.0055d0) then
tmp = sin(im) * ((re + 1.0d0) + t_0)
else if (re <= 4.9d+151) 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.0075) {
tmp = t_1;
} else if (re <= 0.0055) {
tmp = Math.sin(im) * ((re + 1.0) + t_0);
} else if (re <= 4.9e+151) {
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.0075: tmp = t_1 elif re <= 0.0055: tmp = math.sin(im) * ((re + 1.0) + t_0) elif re <= 4.9e+151: 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.0075) tmp = t_1; elseif (re <= 0.0055) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + t_0)); elseif (re <= 4.9e+151) 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.0075) tmp = t_1; elseif (re <= 0.0055) tmp = sin(im) * ((re + 1.0) + t_0); elseif (re <= 4.9e+151) 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.0075], t$95$1, If[LessEqual[re, 0.0055], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 4.9e+151], 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.0075:\\
\;\;\;\;t_1\\
\mathbf{elif}\;re \leq 0.0055:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + t_0\right)\\
\mathbf{elif}\;re \leq 4.9 \cdot 10^{+151}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot t_0\\
\end{array}
\end{array}
if re < -0.0074999999999999997 or 0.0054999999999999997 < re < 4.8999999999999999e151Initial program 100.0%
Taylor expanded in im around 0 88.4%
if -0.0074999999999999997 < re < 0.0054999999999999997Initial 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%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
unpow2100.0%
*-commutative100.0%
associate-*r*100.0%
Simplified100.0%
if 4.8999999999999999e151 < 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%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 97.2%
associate-+r+97.2%
+-commutative97.2%
unpow297.2%
*-commutative97.2%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in re around inf 97.2%
unpow297.2%
*-commutative97.2%
associate-*r*97.2%
Simplified97.2%
Final simplification95.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.0022)
t_0
(if (<= re 0.00175)
(* (sin im) (+ re 1.0))
(if (<= re 4.9e+151) 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.0022) {
tmp = t_0;
} else if (re <= 0.00175) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 4.9e+151) {
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.0022d0)) then
tmp = t_0
else if (re <= 0.00175d0) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 4.9d+151) 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.0022) {
tmp = t_0;
} else if (re <= 0.00175) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 4.9e+151) {
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.0022: tmp = t_0 elif re <= 0.00175: tmp = math.sin(im) * (re + 1.0) elif re <= 4.9e+151: 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.0022) tmp = t_0; elseif (re <= 0.00175) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 4.9e+151) 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.0022) tmp = t_0; elseif (re <= 0.00175) tmp = sin(im) * (re + 1.0); elseif (re <= 4.9e+151) 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.0022], t$95$0, If[LessEqual[re, 0.00175], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 4.9e+151], 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.0022:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 0.00175:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 4.9 \cdot 10^{+151}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.00220000000000000013 or 0.00175000000000000004 < re < 4.8999999999999999e151Initial program 100.0%
Taylor expanded in im around 0 88.4%
if -0.00220000000000000013 < re < 0.00175000000000000004Initial program 100.0%
Taylor expanded in re around 0 99.4%
distribute-rgt1-in99.4%
Simplified99.4%
if 4.8999999999999999e151 < 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%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 97.2%
associate-+r+97.2%
+-commutative97.2%
unpow297.2%
*-commutative97.2%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in re around inf 97.2%
unpow297.2%
*-commutative97.2%
associate-*r*97.2%
Simplified97.2%
Final simplification95.1%
(FPCore (re im) :precision binary64 (if (<= re 0.00045) (sin im) (* im (+ (+ re 1.0) (* (* re re) 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= 0.00045) {
tmp = sin(im);
} else {
tmp = im * ((re + 1.0) + ((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.00045d0) then
tmp = sin(im)
else
tmp = im * ((re + 1.0d0) + ((re * re) * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.00045) {
tmp = Math.sin(im);
} else {
tmp = im * ((re + 1.0) + ((re * re) * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.00045: tmp = math.sin(im) else: tmp = im * ((re + 1.0) + ((re * re) * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.00045) tmp = sin(im); else tmp = Float64(im * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.00045) tmp = sin(im); else tmp = im * ((re + 1.0) + ((re * re) * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.00045], N[Sin[im], $MachinePrecision], N[(im * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.00045:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < 4.4999999999999999e-4Initial program 100.0%
Taylor expanded in re around 0 67.1%
if 4.4999999999999999e-4 < re Initial program 100.0%
Taylor expanded in re around 0 68.3%
associate-+r+68.3%
+-commutative68.3%
associate-+r+68.3%
distribute-rgt1-in68.3%
associate-*r*68.3%
associate-*r*68.3%
distribute-rgt-out68.3%
*-commutative68.3%
distribute-rgt-out68.3%
+-commutative68.3%
Simplified68.3%
Taylor expanded in re around 0 51.4%
associate-+r+51.4%
+-commutative51.4%
unpow251.4%
*-commutative51.4%
associate-*r*51.4%
Simplified51.4%
Taylor expanded in im around 0 47.0%
associate-+r+47.0%
+-commutative47.0%
unpow247.0%
Simplified47.0%
Final simplification62.3%
(FPCore (re im) :precision binary64 (* im (+ (+ re 1.0) (* (* re re) 0.5))))
double code(double re, double im) {
return im * ((re + 1.0) + ((re * re) * 0.5));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * ((re + 1.0d0) + ((re * re) * 0.5d0))
end function
public static double code(double re, double im) {
return im * ((re + 1.0) + ((re * re) * 0.5));
}
def code(re, im): return im * ((re + 1.0) + ((re * re) * 0.5))
function code(re, im) return Float64(im * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * 0.5))) end
function tmp = code(re, im) tmp = im * ((re + 1.0) + ((re * re) * 0.5)); end
code[re_, im_] := N[(im * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot 0.5\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 67.6%
associate-+r+67.6%
+-commutative67.6%
associate-+r+67.6%
distribute-rgt1-in67.6%
associate-*r*67.6%
associate-*r*67.6%
distribute-rgt-out67.6%
*-commutative67.6%
distribute-rgt-out67.6%
+-commutative67.6%
Simplified67.8%
Taylor expanded in re around 0 63.7%
associate-+r+63.7%
+-commutative63.7%
unpow263.7%
*-commutative63.7%
associate-*r*63.7%
Simplified63.7%
Taylor expanded in im around 0 39.0%
associate-+r+39.0%
+-commutative39.0%
unpow239.0%
Simplified39.0%
Final simplification39.0%
(FPCore (re im) :precision binary64 (if (<= im -2.6e+24) (* re im) im))
double code(double re, double im) {
double tmp;
if (im <= -2.6e+24) {
tmp = re * im;
} else {
tmp = im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-2.6d+24)) then
tmp = re * im
else
tmp = im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -2.6e+24) {
tmp = re * im;
} else {
tmp = im;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -2.6e+24: tmp = re * im else: tmp = im return tmp
function code(re, im) tmp = 0.0 if (im <= -2.6e+24) tmp = Float64(re * im); else tmp = im; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -2.6e+24) tmp = re * im; else tmp = im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -2.6e+24], N[(re * im), $MachinePrecision], im]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.6 \cdot 10^{+24}:\\
\;\;\;\;re \cdot im\\
\mathbf{else}:\\
\;\;\;\;im\\
\end{array}
\end{array}
if im < -2.5999999999999998e24Initial program 100.0%
Taylor expanded in im around 0 31.9%
Taylor expanded in re around 0 9.6%
Taylor expanded in re around inf 10.7%
*-commutative10.7%
Simplified10.7%
if -2.5999999999999998e24 < im Initial program 100.0%
Taylor expanded in im around 0 79.7%
Taylor expanded in re around 0 35.4%
Final simplification30.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 69.2%
Taylor expanded in re around 0 30.0%
Final simplification30.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 69.2%
Taylor expanded in re around 0 28.2%
Final simplification28.2%
herbie shell --seed 2023271
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))