
(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 17 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 (<= re -1.6)
(exp re)
(if (or (<= re 18500.0) (not (<= re 3.2e+97)))
(*
(sin im)
(+ (+ re 1.0) (* (* re re) (+ (* re 0.16666666666666666) 0.5))))
(* (exp re) im))))
double code(double re, double im) {
double tmp;
if (re <= -1.6) {
tmp = exp(re);
} else if ((re <= 18500.0) || !(re <= 3.2e+97)) {
tmp = sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5)));
} 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 = exp(re)
else if ((re <= 18500.0d0) .or. (.not. (re <= 3.2d+97))) then
tmp = sin(im) * ((re + 1.0d0) + ((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)))
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 = Math.exp(re);
} else if ((re <= 18500.0) || !(re <= 3.2e+97)) {
tmp = Math.sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5)));
} else {
tmp = Math.exp(re) * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.6: tmp = math.exp(re) elif (re <= 18500.0) or not (re <= 3.2e+97): tmp = math.sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5))) else: tmp = math.exp(re) * im return tmp
function code(re, im) tmp = 0.0 if (re <= -1.6) tmp = exp(re); elseif ((re <= 18500.0) || !(re <= 3.2e+97)) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)))); else tmp = Float64(exp(re) * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.6) tmp = exp(re); elseif ((re <= 18500.0) || ~((re <= 3.2e+97))) tmp = sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5))); else tmp = exp(re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.6], N[Exp[re], $MachinePrecision], If[Or[LessEqual[re, 18500.0], N[Not[LessEqual[re, 3.2e+97]], $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], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.6:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 18500 \lor \neg \left(re \leq 3.2 \cdot 10^{+97}\right):\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\
\end{array}
\end{array}
if re < -1.6000000000000001Initial program 100.0%
add-exp-log56.1%
prod-exp56.1%
Applied egg-rr56.1%
Taylor expanded in re around inf 100.0%
if -1.6000000000000001 < re < 18500 or 3.20000000000000016e97 < re Initial program 100.0%
Taylor expanded in re around 0 98.7%
associate-+r+98.7%
*-commutative98.7%
distribute-rgt1-in98.7%
*-commutative98.7%
+-commutative98.7%
*-commutative98.7%
associate-*r*98.7%
*-commutative98.7%
associate-*r*98.7%
distribute-rgt-out98.7%
distribute-lft-out98.7%
+-commutative98.7%
Simplified98.7%
if 18500 < re < 3.20000000000000016e97Initial program 100.0%
Taylor expanded in im around 0 80.8%
Final simplification97.1%
(FPCore (re im)
:precision binary64
(if (<= re -40.0)
(exp re)
(if (<= re 18500.0)
(* (sin im) (+ (+ re 1.0) (* re (* re 0.5))))
(if (<= re 8.2e+150) (* (exp re) im) (* (sin im) (* (* re re) 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -40.0) {
tmp = exp(re);
} else if (re <= 18500.0) {
tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 8.2e+150) {
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 <= (-40.0d0)) then
tmp = exp(re)
else if (re <= 18500.0d0) then
tmp = sin(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
else if (re <= 8.2d+150) 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 <= -40.0) {
tmp = Math.exp(re);
} else if (re <= 18500.0) {
tmp = Math.sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 8.2e+150) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -40.0: tmp = math.exp(re) elif re <= 18500.0: tmp = math.sin(im) * ((re + 1.0) + (re * (re * 0.5))) elif re <= 8.2e+150: 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 <= -40.0) tmp = exp(re); elseif (re <= 18500.0) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); elseif (re <= 8.2e+150) 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 <= -40.0) tmp = exp(re); elseif (re <= 18500.0) tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5))); elseif (re <= 8.2e+150) tmp = exp(re) * im; else tmp = sin(im) * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -40.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 18500.0], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 8.2e+150], 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 -40:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 18500:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\mathbf{elif}\;re \leq 8.2 \cdot 10^{+150}:\\
\;\;\;\;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 < -40Initial program 100.0%
add-exp-log56.1%
prod-exp56.1%
Applied egg-rr56.1%
Taylor expanded in re around inf 100.0%
if -40 < re < 18500Initial program 100.0%
Taylor expanded in re around 0 98.8%
associate-+r+98.8%
+-commutative98.8%
*-commutative98.8%
distribute-lft1-in98.8%
*-commutative98.8%
associate-*r*98.8%
distribute-rgt-out98.8%
*-commutative98.8%
unpow298.8%
associate-*l*98.8%
Simplified98.8%
if 18500 < re < 8.19999999999999988e150Initial program 100.0%
Taylor expanded in im around 0 74.4%
if 8.19999999999999988e150 < re Initial program 100.0%
Taylor expanded in re around 0 96.7%
associate-+r+96.7%
+-commutative96.7%
*-commutative96.7%
distribute-lft1-in96.7%
*-commutative96.7%
associate-*r*96.7%
distribute-rgt-out96.7%
*-commutative96.7%
unpow296.7%
associate-*l*96.7%
Simplified96.7%
Taylor expanded in re around inf 96.7%
unpow296.7%
Simplified96.7%
Final simplification95.1%
(FPCore (re im)
:precision binary64
(if (<= re -1.0)
(exp re)
(if (<= re 18500.0)
(* (sin im) (+ re 1.0))
(if (<= re 8.2e+150) (* (exp re) im) (* (sin im) (* (* re re) 0.5))))))
double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = exp(re);
} else if (re <= 18500.0) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 8.2e+150) {
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 = exp(re)
else if (re <= 18500.0d0) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 8.2d+150) 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 = Math.exp(re);
} else if (re <= 18500.0) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 8.2e+150) {
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 = math.exp(re) elif re <= 18500.0: tmp = math.sin(im) * (re + 1.0) elif re <= 8.2e+150: 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 = exp(re); elseif (re <= 18500.0) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 8.2e+150) 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 = exp(re); elseif (re <= 18500.0) tmp = sin(im) * (re + 1.0); elseif (re <= 8.2e+150) 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], N[Exp[re], $MachinePrecision], If[LessEqual[re, 18500.0], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 8.2e+150], 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:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 18500:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 8.2 \cdot 10^{+150}:\\
\;\;\;\;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-exp-log56.1%
prod-exp56.1%
Applied egg-rr56.1%
Taylor expanded in re around inf 100.0%
if -1 < re < 18500Initial program 100.0%
Taylor expanded in re around 0 98.8%
*-commutative98.8%
distribute-rgt1-in98.8%
Simplified98.8%
if 18500 < re < 8.19999999999999988e150Initial program 100.0%
Taylor expanded in im around 0 74.4%
if 8.19999999999999988e150 < re Initial program 100.0%
Taylor expanded in re around 0 96.7%
associate-+r+96.7%
+-commutative96.7%
*-commutative96.7%
distribute-lft1-in96.7%
*-commutative96.7%
associate-*r*96.7%
distribute-rgt-out96.7%
*-commutative96.7%
unpow296.7%
associate-*l*96.7%
Simplified96.7%
Taylor expanded in re around inf 96.7%
unpow296.7%
Simplified96.7%
Final simplification95.1%
(FPCore (re im) :precision binary64 (if (<= re -14.5) (exp re) (if (<= re 18500.0) (* (sin im) (+ re 1.0)) (* (exp re) im))))
double code(double re, double im) {
double tmp;
if (re <= -14.5) {
tmp = exp(re);
} else if (re <= 18500.0) {
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 <= (-14.5d0)) then
tmp = exp(re)
else if (re <= 18500.0d0) 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 <= -14.5) {
tmp = Math.exp(re);
} else if (re <= 18500.0) {
tmp = Math.sin(im) * (re + 1.0);
} else {
tmp = Math.exp(re) * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -14.5: tmp = math.exp(re) elif re <= 18500.0: tmp = math.sin(im) * (re + 1.0) else: tmp = math.exp(re) * im return tmp
function code(re, im) tmp = 0.0 if (re <= -14.5) tmp = exp(re); elseif (re <= 18500.0) 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 <= -14.5) tmp = exp(re); elseif (re <= 18500.0) tmp = sin(im) * (re + 1.0); else tmp = exp(re) * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -14.5], N[Exp[re], $MachinePrecision], If[LessEqual[re, 18500.0], 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 -14.5:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 18500:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re} \cdot im\\
\end{array}
\end{array}
if re < -14.5Initial program 100.0%
add-exp-log56.1%
prod-exp56.1%
Applied egg-rr56.1%
Taylor expanded in re around inf 100.0%
if -14.5 < re < 18500Initial program 100.0%
Taylor expanded in re around 0 98.8%
*-commutative98.8%
distribute-rgt1-in98.8%
Simplified98.8%
if 18500 < re Initial program 100.0%
Taylor expanded in im around 0 72.7%
Final simplification92.3%
(FPCore (re im)
:precision binary64
(if (<= re -1.0)
(exp re)
(if (<= re 3.1e-26)
(+ im (* re im))
(if (<= re 4.4e+140) (exp re) (/ im (/ (- 1.0 re) (- 1.0 (* re re))))))))
double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = exp(re);
} else if (re <= 3.1e-26) {
tmp = im + (re * im);
} else if (re <= 4.4e+140) {
tmp = exp(re);
} else {
tmp = im / ((1.0 - re) / (1.0 - (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 <= (-1.0d0)) then
tmp = exp(re)
else if (re <= 3.1d-26) then
tmp = im + (re * im)
else if (re <= 4.4d+140) then
tmp = exp(re)
else
tmp = im / ((1.0d0 - re) / (1.0d0 - (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.0) {
tmp = Math.exp(re);
} else if (re <= 3.1e-26) {
tmp = im + (re * im);
} else if (re <= 4.4e+140) {
tmp = Math.exp(re);
} else {
tmp = im / ((1.0 - re) / (1.0 - (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.0: tmp = math.exp(re) elif re <= 3.1e-26: tmp = im + (re * im) elif re <= 4.4e+140: tmp = math.exp(re) else: tmp = im / ((1.0 - re) / (1.0 - (re * re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.0) tmp = exp(re); elseif (re <= 3.1e-26) tmp = Float64(im + Float64(re * im)); elseif (re <= 4.4e+140) tmp = exp(re); else tmp = Float64(im / Float64(Float64(1.0 - re) / Float64(1.0 - Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.0) tmp = exp(re); elseif (re <= 3.1e-26) tmp = im + (re * im); elseif (re <= 4.4e+140) tmp = exp(re); else tmp = im / ((1.0 - re) / (1.0 - (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 3.1e-26], N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 4.4e+140], N[Exp[re], $MachinePrecision], N[(im / N[(N[(1.0 - re), $MachinePrecision] / N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 3.1 \cdot 10^{-26}:\\
\;\;\;\;im + re \cdot im\\
\mathbf{elif}\;re \leq 4.4 \cdot 10^{+140}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\frac{im}{\frac{1 - re}{1 - re \cdot re}}\\
\end{array}
\end{array}
if re < -1 or 3.09999999999999983e-26 < re < 4.3999999999999997e140Initial program 100.0%
add-exp-log55.6%
prod-exp55.7%
Applied egg-rr55.7%
Taylor expanded in re around inf 79.1%
if -1 < re < 3.09999999999999983e-26Initial program 100.0%
Taylor expanded in im around 0 56.3%
Taylor expanded in re around 0 56.3%
if 4.3999999999999997e140 < re Initial program 100.0%
Taylor expanded in re around 0 5.0%
*-commutative5.0%
distribute-rgt1-in5.0%
Simplified5.0%
Taylor expanded in im around 0 19.0%
*-commutative19.0%
flip-+66.9%
associate-*r/66.9%
metadata-eval66.9%
Applied egg-rr66.9%
associate-/l*66.9%
Simplified66.9%
Final simplification66.2%
(FPCore (re im)
:precision binary64
(if (<= re -38.0)
(exp re)
(if (<= re 18500.0)
(sin im)
(if (<= re 4.4e+140) (exp re) (/ im (/ (- 1.0 re) (- 1.0 (* re re))))))))
double code(double re, double im) {
double tmp;
if (re <= -38.0) {
tmp = exp(re);
} else if (re <= 18500.0) {
tmp = sin(im);
} else if (re <= 4.4e+140) {
tmp = exp(re);
} else {
tmp = im / ((1.0 - re) / (1.0 - (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 <= (-38.0d0)) then
tmp = exp(re)
else if (re <= 18500.0d0) then
tmp = sin(im)
else if (re <= 4.4d+140) then
tmp = exp(re)
else
tmp = im / ((1.0d0 - re) / (1.0d0 - (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -38.0) {
tmp = Math.exp(re);
} else if (re <= 18500.0) {
tmp = Math.sin(im);
} else if (re <= 4.4e+140) {
tmp = Math.exp(re);
} else {
tmp = im / ((1.0 - re) / (1.0 - (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -38.0: tmp = math.exp(re) elif re <= 18500.0: tmp = math.sin(im) elif re <= 4.4e+140: tmp = math.exp(re) else: tmp = im / ((1.0 - re) / (1.0 - (re * re))) return tmp
function code(re, im) tmp = 0.0 if (re <= -38.0) tmp = exp(re); elseif (re <= 18500.0) tmp = sin(im); elseif (re <= 4.4e+140) tmp = exp(re); else tmp = Float64(im / Float64(Float64(1.0 - re) / Float64(1.0 - Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -38.0) tmp = exp(re); elseif (re <= 18500.0) tmp = sin(im); elseif (re <= 4.4e+140) tmp = exp(re); else tmp = im / ((1.0 - re) / (1.0 - (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -38.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 18500.0], N[Sin[im], $MachinePrecision], If[LessEqual[re, 4.4e+140], N[Exp[re], $MachinePrecision], N[(im / N[(N[(1.0 - re), $MachinePrecision] / N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -38:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 18500:\\
\;\;\;\;\sin im\\
\mathbf{elif}\;re \leq 4.4 \cdot 10^{+140}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\frac{im}{\frac{1 - re}{1 - re \cdot re}}\\
\end{array}
\end{array}
if re < -38 or 18500 < re < 4.3999999999999997e140Initial program 100.0%
add-exp-log54.8%
prod-exp54.8%
Applied egg-rr54.8%
Taylor expanded in re around inf 81.7%
if -38 < re < 18500Initial program 100.0%
Taylor expanded in re around 0 98.4%
if 4.3999999999999997e140 < re Initial program 100.0%
Taylor expanded in re around 0 5.0%
*-commutative5.0%
distribute-rgt1-in5.0%
Simplified5.0%
Taylor expanded in im around 0 19.0%
*-commutative19.0%
flip-+66.9%
associate-*r/66.9%
metadata-eval66.9%
Applied egg-rr66.9%
associate-/l*66.9%
Simplified66.9%
Final simplification88.7%
(FPCore (re im) :precision binary64 (if (or (<= re -2.4e-12) (not (<= re 18500.0))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((re <= -2.4e-12) || !(re <= 18500.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 ((re <= (-2.4d-12)) .or. (.not. (re <= 18500.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 ((re <= -2.4e-12) || !(re <= 18500.0)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -2.4e-12) or not (re <= 18500.0): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((re <= -2.4e-12) || !(re <= 18500.0)) tmp = Float64(exp(re) * im); else tmp = sin(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -2.4e-12) || ~((re <= 18500.0))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -2.4e-12], N[Not[LessEqual[re, 18500.0]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.4 \cdot 10^{-12} \lor \neg \left(re \leq 18500\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if re < -2.39999999999999987e-12 or 18500 < re Initial program 100.0%
Taylor expanded in im around 0 85.5%
if -2.39999999999999987e-12 < re < 18500Initial program 100.0%
Taylor expanded in re around 0 98.6%
Final simplification92.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- 1.0 (* re re))))
(if (<= re -5e+36)
(* t_0 (* (+ re 1.0) (/ im t_0)))
(/ (* im t_0) (- 1.0 re)))))
double code(double re, double im) {
double t_0 = 1.0 - (re * re);
double tmp;
if (re <= -5e+36) {
tmp = t_0 * ((re + 1.0) * (im / t_0));
} else {
tmp = (im * t_0) / (1.0 - re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (re * re)
if (re <= (-5d+36)) then
tmp = t_0 * ((re + 1.0d0) * (im / t_0))
else
tmp = (im * t_0) / (1.0d0 - re)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 1.0 - (re * re);
double tmp;
if (re <= -5e+36) {
tmp = t_0 * ((re + 1.0) * (im / t_0));
} else {
tmp = (im * t_0) / (1.0 - re);
}
return tmp;
}
def code(re, im): t_0 = 1.0 - (re * re) tmp = 0 if re <= -5e+36: tmp = t_0 * ((re + 1.0) * (im / t_0)) else: tmp = (im * t_0) / (1.0 - re) return tmp
function code(re, im) t_0 = Float64(1.0 - Float64(re * re)) tmp = 0.0 if (re <= -5e+36) tmp = Float64(t_0 * Float64(Float64(re + 1.0) * Float64(im / t_0))); else tmp = Float64(Float64(im * t_0) / Float64(1.0 - re)); end return tmp end
function tmp_2 = code(re, im) t_0 = 1.0 - (re * re); tmp = 0.0; if (re <= -5e+36) tmp = t_0 * ((re + 1.0) * (im / t_0)); else tmp = (im * t_0) / (1.0 - re); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -5e+36], N[(t$95$0 * N[(N[(re + 1.0), $MachinePrecision] * N[(im / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(im * t$95$0), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - re \cdot re\\
\mathbf{if}\;re \leq -5 \cdot 10^{+36}:\\
\;\;\;\;t_0 \cdot \left(\left(re + 1\right) \cdot \frac{im}{t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{im \cdot t_0}{1 - re}\\
\end{array}
\end{array}
if re < -4.99999999999999977e36Initial program 100.0%
Taylor expanded in re around 0 2.7%
*-commutative2.7%
distribute-rgt1-in2.7%
Simplified2.7%
Taylor expanded in im around 0 2.5%
*-commutative2.5%
flip-+2.0%
associate-*r/2.0%
metadata-eval2.0%
Applied egg-rr2.0%
associate-/l*2.0%
associate-/r/7.1%
Simplified7.1%
flip--6.5%
metadata-eval6.5%
+-commutative6.5%
associate-/r/12.1%
Applied egg-rr12.1%
if -4.99999999999999977e36 < re Initial program 100.0%
Taylor expanded in re around 0 65.8%
*-commutative65.8%
distribute-rgt1-in65.8%
Simplified65.8%
Taylor expanded in im around 0 41.4%
flip-+48.5%
associate-*l/50.3%
metadata-eval50.3%
Applied egg-rr50.3%
Final simplification42.5%
(FPCore (re im) :precision binary64 (if (<= re 2e+31) (* (- 1.0 (* re re)) (/ im (- 1.0 re))) (/ (- (* im (* re re))) (- 1.0 re))))
double code(double re, double im) {
double tmp;
if (re <= 2e+31) {
tmp = (1.0 - (re * re)) * (im / (1.0 - re));
} else {
tmp = -(im * (re * re)) / (1.0 - re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 2d+31) then
tmp = (1.0d0 - (re * re)) * (im / (1.0d0 - re))
else
tmp = -(im * (re * re)) / (1.0d0 - re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2e+31) {
tmp = (1.0 - (re * re)) * (im / (1.0 - re));
} else {
tmp = -(im * (re * re)) / (1.0 - re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2e+31: tmp = (1.0 - (re * re)) * (im / (1.0 - re)) else: tmp = -(im * (re * re)) / (1.0 - re) return tmp
function code(re, im) tmp = 0.0 if (re <= 2e+31) tmp = Float64(Float64(1.0 - Float64(re * re)) * Float64(im / Float64(1.0 - re))); else tmp = Float64(Float64(-Float64(im * Float64(re * re))) / Float64(1.0 - re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2e+31) tmp = (1.0 - (re * re)) * (im / (1.0 - re)); else tmp = -(im * (re * re)) / (1.0 - re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2e+31], N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(im / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision]) / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2 \cdot 10^{+31}:\\
\;\;\;\;\left(1 - re \cdot re\right) \cdot \frac{im}{1 - re}\\
\mathbf{else}:\\
\;\;\;\;\frac{-im \cdot \left(re \cdot re\right)}{1 - re}\\
\end{array}
\end{array}
if re < 1.9999999999999999e31Initial program 100.0%
Taylor expanded in re around 0 67.6%
*-commutative67.6%
distribute-rgt1-in67.6%
Simplified67.6%
Taylor expanded in im around 0 38.3%
*-commutative38.3%
flip-+38.2%
associate-*r/38.2%
metadata-eval38.2%
Applied egg-rr38.2%
associate-/l*38.2%
associate-/r/39.5%
Simplified39.5%
if 1.9999999999999999e31 < re Initial program 100.0%
Taylor expanded in re around 0 4.2%
*-commutative4.2%
distribute-rgt1-in4.2%
Simplified4.2%
Taylor expanded in im around 0 17.6%
flip-+41.9%
associate-*l/48.2%
metadata-eval48.2%
Applied egg-rr48.2%
Taylor expanded in re around inf 48.2%
mul-1-neg48.2%
unpow248.2%
*-commutative48.2%
distribute-rgt-neg-out48.2%
distribute-rgt-neg-in48.2%
Simplified48.2%
Final simplification41.5%
(FPCore (re im) :precision binary64 (if (<= re 18500.0) im (/ (- (* im (* re re))) (- 1.0 re))))
double code(double re, double im) {
double tmp;
if (re <= 18500.0) {
tmp = im;
} else {
tmp = -(im * (re * re)) / (1.0 - re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 18500.0d0) then
tmp = im
else
tmp = -(im * (re * re)) / (1.0d0 - re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 18500.0) {
tmp = im;
} else {
tmp = -(im * (re * re)) / (1.0 - re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 18500.0: tmp = im else: tmp = -(im * (re * re)) / (1.0 - re) return tmp
function code(re, im) tmp = 0.0 if (re <= 18500.0) tmp = im; else tmp = Float64(Float64(-Float64(im * Float64(re * re))) / Float64(1.0 - re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 18500.0) tmp = im; else tmp = -(im * (re * re)) / (1.0 - re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 18500.0], im, N[((-N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision]) / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 18500:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;\frac{-im \cdot \left(re \cdot re\right)}{1 - re}\\
\end{array}
\end{array}
if re < 18500Initial program 100.0%
Taylor expanded in im around 0 68.3%
Taylor expanded in re around 0 39.5%
if 18500 < re Initial program 100.0%
Taylor expanded in re around 0 4.1%
*-commutative4.1%
distribute-rgt1-in4.1%
Simplified4.1%
Taylor expanded in im around 0 17.5%
flip-+39.2%
associate-*l/44.8%
metadata-eval44.8%
Applied egg-rr44.8%
Taylor expanded in re around inf 44.8%
mul-1-neg44.8%
unpow244.8%
*-commutative44.8%
distribute-rgt-neg-out44.8%
distribute-rgt-neg-in44.8%
Simplified44.8%
Final simplification40.8%
(FPCore (re im) :precision binary64 (if (<= re 18500.0) im (* (/ im re) (+ (* re re) -1.0))))
double code(double re, double im) {
double tmp;
if (re <= 18500.0) {
tmp = im;
} else {
tmp = (im / re) * ((re * 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 <= 18500.0d0) then
tmp = im
else
tmp = (im / re) * ((re * re) + (-1.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 18500.0) {
tmp = im;
} else {
tmp = (im / re) * ((re * re) + -1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 18500.0: tmp = im else: tmp = (im / re) * ((re * re) + -1.0) return tmp
function code(re, im) tmp = 0.0 if (re <= 18500.0) tmp = im; else tmp = Float64(Float64(im / re) * Float64(Float64(re * re) + -1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 18500.0) tmp = im; else tmp = (im / re) * ((re * re) + -1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 18500.0], im, N[(N[(im / re), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 18500:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;\frac{im}{re} \cdot \left(re \cdot re + -1\right)\\
\end{array}
\end{array}
if re < 18500Initial program 100.0%
Taylor expanded in im around 0 68.3%
Taylor expanded in re around 0 39.5%
if 18500 < re Initial program 100.0%
Taylor expanded in re around 0 4.1%
*-commutative4.1%
distribute-rgt1-in4.1%
Simplified4.1%
Taylor expanded in im around 0 17.5%
*-commutative17.5%
flip-+39.2%
associate-*r/44.8%
metadata-eval44.8%
Applied egg-rr44.8%
associate-/l*39.2%
associate-/r/24.1%
Simplified24.1%
Taylor expanded in re around inf 24.1%
associate-*r/24.1%
neg-mul-124.1%
Simplified24.1%
Final simplification35.5%
(FPCore (re im) :precision binary64 (/ (* im (- 1.0 (* re re))) (- 1.0 re)))
double code(double re, double im) {
return (im * (1.0 - (re * re))) / (1.0 - re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (im * (1.0d0 - (re * re))) / (1.0d0 - re)
end function
public static double code(double re, double im) {
return (im * (1.0 - (re * re))) / (1.0 - re);
}
def code(re, im): return (im * (1.0 - (re * re))) / (1.0 - re)
function code(re, im) return Float64(Float64(im * Float64(1.0 - Float64(re * re))) / Float64(1.0 - re)) end
function tmp = code(re, im) tmp = (im * (1.0 - (re * re))) / (1.0 - re); end
code[re_, im_] := N[(N[(im * N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{im \cdot \left(1 - re \cdot re\right)}{1 - re}
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 53.0%
*-commutative53.0%
distribute-rgt1-in53.0%
Simplified53.0%
Taylor expanded in im around 0 33.5%
flip-+39.0%
associate-*l/40.5%
metadata-eval40.5%
Applied egg-rr40.5%
Final simplification40.5%
(FPCore (re im) :precision binary64 (if (<= re 3.1e-26) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 3.1e-26) {
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 <= 3.1d-26) 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 <= 3.1e-26) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.1e-26: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 3.1e-26) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.1e-26) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.1e-26], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.1 \cdot 10^{-26}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 3.09999999999999983e-26Initial program 100.0%
Taylor expanded in im around 0 69.7%
Taylor expanded in re around 0 40.2%
if 3.09999999999999983e-26 < re Initial program 100.0%
Taylor expanded in re around 0 7.2%
*-commutative7.2%
distribute-rgt1-in7.2%
Simplified7.2%
Taylor expanded in im around 0 16.7%
Taylor expanded in re around inf 16.7%
Final simplification33.8%
(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 53.0%
*-commutative53.0%
distribute-rgt1-in53.0%
Simplified53.0%
Taylor expanded in im around 0 33.5%
Final simplification33.5%
(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.4%
Taylor expanded in re around 0 33.5%
Final simplification33.5%
(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.4%
Taylor expanded in re around 0 30.0%
Final simplification30.0%
herbie shell --seed 2023188
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))