
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 93.8%
remove-double-neg93.8%
sin-neg93.8%
neg-mul-193.8%
*-commutative93.8%
associate-*l*93.8%
associate-*l/90.7%
associate-/r/90.7%
associate-*l/93.8%
associate-/r/93.4%
sin-neg93.4%
neg-mul-193.4%
associate-/r*93.4%
associate-/r/93.8%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= (sin ky) -0.005)
(/ (sin ky) (* t_1 (+ (/ 1.0 th) (* th 0.16666666666666666))))
(if (<= (sin ky) 0.00027)
(/ (sin th) (* t_1 (+ (* ky 0.16666666666666666) (/ 1.0 ky))))
(sin th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (sin(ky) <= -0.005) {
tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (sin(ky) <= 0.00027) {
tmp = sin(th) / (t_1 * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (Math.sin(ky) <= -0.005) {
tmp = Math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (Math.sin(ky) <= 0.00027) {
tmp = Math.sin(th) / (t_1 * ((ky * 0.16666666666666666) + (1.0 / ky)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if math.sin(ky) <= -0.005: tmp = math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))) elif math.sin(ky) <= 0.00027: tmp = math.sin(th) / (t_1 * ((ky * 0.16666666666666666) + (1.0 / ky))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (sin(ky) <= -0.005) tmp = Float64(sin(ky) / Float64(t_1 * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); elseif (sin(ky) <= 0.00027) tmp = Float64(sin(th) / Float64(t_1 * Float64(Float64(ky * 0.16666666666666666) + Float64(1.0 / ky)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (sin(ky) <= -0.005) tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))); elseif (sin(ky) <= 0.00027) tmp = sin(th) / (t_1 * ((ky * 0.16666666666666666) + (1.0 / ky))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.005], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.00027], N[(N[Sin[th], $MachinePrecision] / N[(t$95$1 * N[(N[(ky * 0.16666666666666666), $MachinePrecision] + N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;\sin ky \leq -0.005:\\
\;\;\;\;\frac{\sin ky}{t_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{elif}\;\sin ky \leq 0.00027:\\
\;\;\;\;\frac{\sin th}{t_1 \cdot \left(ky \cdot 0.16666666666666666 + \frac{1}{ky}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0050000000000000001Initial program 99.6%
associate-*l/99.6%
associate-/l*99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 52.9%
+-commutative52.9%
unpow252.9%
unpow252.9%
hypot-def52.9%
associate-*r*52.9%
unpow252.9%
unpow252.9%
hypot-def52.9%
distribute-rgt-out52.9%
Simplified52.9%
if -0.0050000000000000001 < (sin.f64 ky) < 2.70000000000000003e-4Initial program 88.8%
*-commutative88.8%
clear-num88.7%
un-div-inv88.7%
unpow288.7%
unpow288.7%
hypot-def99.7%
Applied egg-rr99.7%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 98.8%
if 2.70000000000000003e-4 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 61.3%
Final simplification79.2%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= (sin ky) -0.004)
(/ (* (sin ky) th) t_1)
(if (<= (sin ky) 0.00027) (/ (sin th) (* t_1 (/ 1.0 ky))) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (sin(ky) <= -0.004) {
tmp = (sin(ky) * th) / t_1;
} else if (sin(ky) <= 0.00027) {
tmp = sin(th) / (t_1 * (1.0 / ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (Math.sin(ky) <= -0.004) {
tmp = (Math.sin(ky) * th) / t_1;
} else if (Math.sin(ky) <= 0.00027) {
tmp = Math.sin(th) / (t_1 * (1.0 / ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if math.sin(ky) <= -0.004: tmp = (math.sin(ky) * th) / t_1 elif math.sin(ky) <= 0.00027: tmp = math.sin(th) / (t_1 * (1.0 / ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (sin(ky) <= -0.004) tmp = Float64(Float64(sin(ky) * th) / t_1); elseif (sin(ky) <= 0.00027) tmp = Float64(sin(th) / Float64(t_1 * Float64(1.0 / ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (sin(ky) <= -0.004) tmp = (sin(ky) * th) / t_1; elseif (sin(ky) <= 0.00027) tmp = sin(th) / (t_1 * (1.0 / ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.004], N[(N[(N[Sin[ky], $MachinePrecision] * th), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.00027], N[(N[Sin[th], $MachinePrecision] / N[(t$95$1 * N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;\sin ky \leq -0.004:\\
\;\;\;\;\frac{\sin ky \cdot th}{t_1}\\
\mathbf{elif}\;\sin ky \leq 0.00027:\\
\;\;\;\;\frac{\sin th}{t_1 \cdot \frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0040000000000000001Initial program 99.6%
expm1-log1p-u99.6%
expm1-udef51.6%
Applied egg-rr51.6%
expm1-def99.7%
expm1-log1p99.7%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in th around 0 52.0%
if -0.0040000000000000001 < (sin.f64 ky) < 2.70000000000000003e-4Initial program 88.7%
*-commutative88.7%
clear-num88.6%
un-div-inv88.6%
unpow288.6%
unpow288.6%
hypot-def99.7%
Applied egg-rr99.7%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 99.0%
if 2.70000000000000003e-4 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 61.3%
Final simplification78.9%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= (sin ky) -0.004)
(/ (sin ky) (* t_1 (+ (/ 1.0 th) (* th 0.16666666666666666))))
(if (<= (sin ky) 0.00027) (/ (sin th) (* t_1 (/ 1.0 ky))) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (sin(ky) <= -0.004) {
tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (sin(ky) <= 0.00027) {
tmp = sin(th) / (t_1 * (1.0 / ky));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (Math.sin(ky) <= -0.004) {
tmp = Math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else if (Math.sin(ky) <= 0.00027) {
tmp = Math.sin(th) / (t_1 * (1.0 / ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if math.sin(ky) <= -0.004: tmp = math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))) elif math.sin(ky) <= 0.00027: tmp = math.sin(th) / (t_1 * (1.0 / ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (sin(ky) <= -0.004) tmp = Float64(sin(ky) / Float64(t_1 * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); elseif (sin(ky) <= 0.00027) tmp = Float64(sin(th) / Float64(t_1 * Float64(1.0 / ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (sin(ky) <= -0.004) tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))); elseif (sin(ky) <= 0.00027) tmp = sin(th) / (t_1 * (1.0 / ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[Sin[ky], $MachinePrecision], -0.004], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.00027], N[(N[Sin[th], $MachinePrecision] / N[(t$95$1 * N[(1.0 / ky), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;\sin ky \leq -0.004:\\
\;\;\;\;\frac{\sin ky}{t_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{elif}\;\sin ky \leq 0.00027:\\
\;\;\;\;\frac{\sin th}{t_1 \cdot \frac{1}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0040000000000000001Initial program 99.6%
associate-*l/99.5%
associate-/l*99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Applied egg-rr99.4%
Taylor expanded in th around 0 52.1%
+-commutative52.1%
unpow252.1%
unpow252.1%
hypot-def52.1%
associate-*r*52.1%
unpow252.1%
unpow252.1%
hypot-def52.1%
distribute-rgt-out52.1%
Simplified52.1%
if -0.0040000000000000001 < (sin.f64 ky) < 2.70000000000000003e-4Initial program 88.7%
*-commutative88.7%
clear-num88.6%
un-div-inv88.6%
unpow288.6%
unpow288.6%
hypot-def99.7%
Applied egg-rr99.7%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 99.0%
if 2.70000000000000003e-4 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 61.3%
Final simplification78.9%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.005) (* (sin th) (fabs (/ ky (sin kx)))) (if (<= (sin kx) 4e-83) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = sin(th) * fabs((ky / sin(kx)));
} else if (sin(kx) <= 4e-83) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.005d0)) then
tmp = sin(th) * abs((ky / sin(kx)))
else if (sin(kx) <= 4d-83) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else if (Math.sin(kx) <= 4e-83) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) elif math.sin(kx) <= 4e-83: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); elseif (sin(kx) <= 4e-83) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = sin(th) * abs((ky / sin(kx))); elseif (sin(kx) <= 4e-83) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-83], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-83}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.4%
Taylor expanded in ky around 0 13.4%
associate-/l*13.4%
associate-/r/13.4%
Simplified13.4%
add-sqr-sqrt6.0%
sqrt-unprod26.7%
pow226.7%
Applied egg-rr26.7%
unpow226.7%
rem-sqrt-square38.7%
Simplified38.7%
if -0.0050000000000000001 < (sin.f64 kx) < 4.0000000000000001e-83Initial program 86.7%
Taylor expanded in kx around 0 40.7%
if 4.0000000000000001e-83 < (sin.f64 kx) Initial program 99.6%
Taylor expanded in ky around 0 60.2%
Final simplification47.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin ky) (sin kx))))
(if (<= (sin kx) -0.005)
(* (sin th) (fabs t_1))
(if (<= (sin kx) 4e-83) (sin th) (* (sin th) t_1)))))
double code(double kx, double ky, double th) {
double t_1 = sin(ky) / sin(kx);
double tmp;
if (sin(kx) <= -0.005) {
tmp = sin(th) * fabs(t_1);
} else if (sin(kx) <= 4e-83) {
tmp = sin(th);
} else {
tmp = sin(th) * t_1;
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: t_1
real(8) :: tmp
t_1 = sin(ky) / sin(kx)
if (sin(kx) <= (-0.005d0)) then
tmp = sin(th) * abs(t_1)
else if (sin(kx) <= 4d-83) then
tmp = sin(th)
else
tmp = sin(th) * t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(ky) / Math.sin(kx);
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.sin(th) * Math.abs(t_1);
} else if (Math.sin(kx) <= 4e-83) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(ky) / math.sin(kx) tmp = 0 if math.sin(kx) <= -0.005: tmp = math.sin(th) * math.fabs(t_1) elif math.sin(kx) <= 4e-83: tmp = math.sin(th) else: tmp = math.sin(th) * t_1 return tmp
function code(kx, ky, th) t_1 = Float64(sin(ky) / sin(kx)) tmp = 0.0 if (sin(kx) <= -0.005) tmp = Float64(sin(th) * abs(t_1)); elseif (sin(kx) <= 4e-83) tmp = sin(th); else tmp = Float64(sin(th) * t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(ky) / sin(kx); tmp = 0.0; if (sin(kx) <= -0.005) tmp = sin(th) * abs(t_1); elseif (sin(kx) <= 4e-83) tmp = sin(th); else tmp = sin(th) * t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-83], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin ky}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\sin th \cdot \left|t_1\right|\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-83}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot t_1\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.4%
Taylor expanded in ky around 0 13.6%
add-sqr-sqrt6.1%
sqrt-unprod31.0%
pow231.0%
Applied egg-rr31.0%
unpow231.0%
rem-sqrt-square42.7%
Simplified42.7%
if -0.0050000000000000001 < (sin.f64 kx) < 4.0000000000000001e-83Initial program 86.7%
Taylor expanded in kx around 0 40.7%
if 4.0000000000000001e-83 < (sin.f64 kx) Initial program 99.6%
Taylor expanded in ky around 0 60.2%
Final simplification48.4%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 93.8%
expm1-log1p-u93.8%
expm1-udef39.3%
Applied egg-rr42.3%
expm1-def99.7%
expm1-log1p99.7%
*-commutative99.7%
associate-*r/95.0%
associate-*l/99.6%
*-commutative99.6%
hypot-def93.8%
unpow293.8%
unpow293.8%
+-commutative93.8%
unpow293.8%
unpow293.8%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= th 1.02e-8)
(/ (sin ky) (/ (hypot (sin kx) (sin ky)) th))
(if (or (<= th 1.4e+83)
(and (not (<= th 2.5e+178))
(or (<= th 1.55e+259) (not (<= th 5.8e+281)))))
(* (sin th) (fabs (/ (sin ky) (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.02e-8) {
tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th);
} else if ((th <= 1.4e+83) || (!(th <= 2.5e+178) && ((th <= 1.55e+259) || !(th <= 5.8e+281)))) {
tmp = sin(th) * fabs((sin(ky) / sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.02e-8) {
tmp = Math.sin(ky) / (Math.hypot(Math.sin(kx), Math.sin(ky)) / th);
} else if ((th <= 1.4e+83) || (!(th <= 2.5e+178) && ((th <= 1.55e+259) || !(th <= 5.8e+281)))) {
tmp = Math.sin(th) * Math.abs((Math.sin(ky) / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 1.02e-8: tmp = math.sin(ky) / (math.hypot(math.sin(kx), math.sin(ky)) / th) elif (th <= 1.4e+83) or (not (th <= 2.5e+178) and ((th <= 1.55e+259) or not (th <= 5.8e+281))): tmp = math.sin(th) * math.fabs((math.sin(ky) / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 1.02e-8) tmp = Float64(sin(ky) / Float64(hypot(sin(kx), sin(ky)) / th)); elseif ((th <= 1.4e+83) || (!(th <= 2.5e+178) && ((th <= 1.55e+259) || !(th <= 5.8e+281)))) tmp = Float64(sin(th) * abs(Float64(sin(ky) / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 1.02e-8) tmp = sin(ky) / (hypot(sin(kx), sin(ky)) / th); elseif ((th <= 1.4e+83) || (~((th <= 2.5e+178)) && ((th <= 1.55e+259) || ~((th <= 5.8e+281))))) tmp = sin(th) * abs((sin(ky) / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 1.02e-8], N[(N[Sin[ky], $MachinePrecision] / N[(N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[th, 1.4e+83], And[N[Not[LessEqual[th, 2.5e+178]], $MachinePrecision], Or[LessEqual[th, 1.55e+259], N[Not[LessEqual[th, 5.8e+281]], $MachinePrecision]]]], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 1.02 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{th}}\\
\mathbf{elif}\;th \leq 1.4 \cdot 10^{+83} \lor \neg \left(th \leq 2.5 \cdot 10^{+178}\right) \land \left(th \leq 1.55 \cdot 10^{+259} \lor \neg \left(th \leq 5.8 \cdot 10^{+281}\right)\right):\\
\;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if th < 1.02000000000000003e-8Initial program 95.0%
associate-*l/90.9%
associate-/l*94.5%
unpow294.5%
unpow294.5%
hypot-def99.2%
Applied egg-rr99.2%
Taylor expanded in th around 0 64.6%
associate-*l/64.7%
unpow264.7%
unpow264.7%
hypot-def67.9%
*-lft-identity67.9%
Simplified67.9%
if 1.02000000000000003e-8 < th < 1.4e83 or 2.49999999999999995e178 < th < 1.5500000000000002e259 or 5.80000000000000019e281 < th Initial program 89.2%
Taylor expanded in ky around 0 39.4%
add-sqr-sqrt7.1%
sqrt-unprod12.0%
pow212.0%
Applied egg-rr12.0%
unpow212.0%
rem-sqrt-square16.9%
Simplified16.9%
if 1.4e83 < th < 2.49999999999999995e178 or 1.5500000000000002e259 < th < 5.80000000000000019e281Initial program 91.9%
Taylor expanded in kx around 0 15.6%
Final simplification55.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.005) (fabs (* ky (/ (sin th) (sin kx)))) (if (<= (sin kx) 4e-83) (sin th) (* (sin th) (/ ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = fabs((ky * (sin(th) / sin(kx))));
} else if (sin(kx) <= 4e-83) {
tmp = sin(th);
} else {
tmp = sin(th) * (ky / sin(kx));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(kx) <= (-0.005d0)) then
tmp = abs((ky * (sin(th) / sin(kx))))
else if (sin(kx) <= 4d-83) then
tmp = sin(th)
else
tmp = sin(th) * (ky / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.abs((ky * (Math.sin(th) / Math.sin(kx))));
} else if (Math.sin(kx) <= 4e-83) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (ky / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(kx) <= -0.005: tmp = math.fabs((ky * (math.sin(th) / math.sin(kx)))) elif math.sin(kx) <= 4e-83: tmp = math.sin(th) else: tmp = math.sin(th) * (ky / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(kx) <= -0.005) tmp = abs(Float64(ky * Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 4e-83) tmp = sin(th); else tmp = Float64(sin(th) * Float64(ky / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(kx) <= -0.005) tmp = abs((ky * (sin(th) / sin(kx)))); elseif (sin(kx) <= 4e-83) tmp = sin(th); else tmp = sin(th) * (ky / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[Abs[N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 4e-83], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin kx \leq -0.005:\\
\;\;\;\;\left|ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 4 \cdot 10^{-83}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.4%
Taylor expanded in ky around 0 13.4%
associate-/l*13.4%
associate-/r/13.4%
Simplified13.4%
add-sqr-sqrt10.0%
sqrt-unprod19.9%
pow219.9%
div-inv19.9%
associate-*l*19.9%
associate-/r/20.0%
clear-num20.0%
Applied egg-rr20.0%
unpow220.0%
rem-sqrt-square36.9%
Simplified36.9%
if -0.0050000000000000001 < (sin.f64 kx) < 4.0000000000000001e-83Initial program 86.7%
Taylor expanded in kx around 0 40.7%
if 4.0000000000000001e-83 < (sin.f64 kx) Initial program 99.6%
Taylor expanded in ky around 0 51.2%
associate-/l*51.7%
associate-/r/51.8%
Simplified51.8%
Final simplification44.2%
(FPCore (kx ky th) :precision binary64 (let* ((t_1 (hypot (sin kx) (sin ky)))) (if (<= th 3.1e-8) (/ (sin ky) (/ t_1 th)) (/ (* ky (sin th)) t_1))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (th <= 3.1e-8) {
tmp = sin(ky) / (t_1 / th);
} else {
tmp = (ky * sin(th)) / t_1;
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(kx), Math.sin(ky));
double tmp;
if (th <= 3.1e-8) {
tmp = Math.sin(ky) / (t_1 / th);
} else {
tmp = (ky * Math.sin(th)) / t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(kx), math.sin(ky)) tmp = 0 if th <= 3.1e-8: tmp = math.sin(ky) / (t_1 / th) else: tmp = (ky * math.sin(th)) / t_1 return tmp
function code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)) tmp = 0.0 if (th <= 3.1e-8) tmp = Float64(sin(ky) / Float64(t_1 / th)); else tmp = Float64(Float64(ky * sin(th)) / t_1); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(kx), sin(ky)); tmp = 0.0; if (th <= 3.1e-8) tmp = sin(ky) / (t_1 / th); else tmp = (ky * sin(th)) / t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[th, 3.1e-8], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 / th), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\
\mathbf{if}\;th \leq 3.1 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sin ky}{\frac{t_1}{th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\end{array}
\end{array}
if th < 3.1e-8Initial program 95.0%
associate-*l/91.0%
associate-/l*94.5%
unpow294.5%
unpow294.5%
hypot-def99.2%
Applied egg-rr99.2%
Taylor expanded in th around 0 64.8%
associate-*l/64.9%
unpow264.9%
unpow264.9%
hypot-def68.1%
*-lft-identity68.1%
Simplified68.1%
if 3.1e-8 < th Initial program 90.1%
expm1-log1p-u90.0%
expm1-udef53.4%
Applied egg-rr60.7%
expm1-def99.6%
expm1-log1p99.7%
associate-*l/99.4%
Simplified99.4%
Taylor expanded in ky around 0 61.5%
Final simplification66.5%
(FPCore (kx ky th) :precision binary64 (if (<= kx 3.8e-83) (sin th) (* (sin th) (fabs (/ ky (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 3.8e-83) {
tmp = sin(th);
} else {
tmp = sin(th) * fabs((ky / sin(kx)));
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (kx <= 3.8d-83) then
tmp = sin(th)
else
tmp = sin(th) * abs((ky / sin(kx)))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 3.8e-83) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 3.8e-83: tmp = math.sin(th) else: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 3.8e-83) tmp = sin(th); else tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 3.8e-83) tmp = sin(th); else tmp = sin(th) * abs((ky / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 3.8e-83], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 3.8 \cdot 10^{-83}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\end{array}
\end{array}
if kx < 3.79999999999999977e-83Initial program 91.3%
Taylor expanded in kx around 0 28.9%
if 3.79999999999999977e-83 < kx Initial program 99.5%
Taylor expanded in ky around 0 37.1%
associate-/l*37.6%
associate-/r/37.7%
Simplified37.7%
add-sqr-sqrt14.1%
sqrt-unprod26.8%
pow226.8%
Applied egg-rr26.8%
unpow226.8%
rem-sqrt-square36.2%
Simplified36.2%
Final simplification31.1%
(FPCore (kx ky th) :precision binary64 (if (<= ky 5.2e-80) (* ky (/ (sin th) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 5.2e-80) {
tmp = ky * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 5.2d-80) then
tmp = ky * (sin(th) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 5.2e-80) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 5.2e-80: tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 5.2e-80) tmp = Float64(ky * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 5.2e-80) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 5.2e-80], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 5.2 \cdot 10^{-80}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 5.2000000000000002e-80Initial program 91.8%
*-commutative91.8%
clear-num91.8%
un-div-inv91.8%
unpow291.8%
unpow291.8%
hypot-def99.6%
Applied egg-rr99.6%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 31.2%
associate-*r/32.7%
Simplified32.7%
if 5.2000000000000002e-80 < ky Initial program 99.7%
Taylor expanded in kx around 0 41.2%
Final simplification34.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky 6.4e-80) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.4e-80) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 6.4d-80) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.4e-80) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 6.4e-80: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 6.4e-80) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 6.4e-80) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 6.4e-80], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 6.4 \cdot 10^{-80}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 6.3999999999999998e-80Initial program 91.8%
Taylor expanded in ky around 0 31.2%
associate-/l*32.8%
associate-/r/32.8%
Simplified32.8%
if 6.3999999999999998e-80 < ky Initial program 99.7%
Taylor expanded in kx around 0 41.2%
Final simplification35.0%
(FPCore (kx ky th) :precision binary64 (if (<= ky 6.2e-134) (* (sin th) (/ ky kx)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.2e-134) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= 6.2d-134) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= 6.2e-134) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= 6.2e-134: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= 6.2e-134) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= 6.2e-134) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, 6.2e-134], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq 6.2 \cdot 10^{-134}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < 6.20000000000000012e-134Initial program 91.1%
Taylor expanded in ky around 0 30.8%
associate-/l*32.5%
associate-/r/32.6%
Simplified32.6%
Taylor expanded in kx around 0 22.1%
if 6.20000000000000012e-134 < ky Initial program 99.7%
Taylor expanded in kx around 0 41.7%
Final simplification28.3%
(FPCore (kx ky th) :precision binary64 (if (<= kx 9.6e-39) (sin th) (/ ky (/ kx th))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 9.6e-39) {
tmp = sin(th);
} else {
tmp = ky / (kx / th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (kx <= 9.6d-39) then
tmp = sin(th)
else
tmp = ky / (kx / th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 9.6e-39) {
tmp = Math.sin(th);
} else {
tmp = ky / (kx / th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 9.6e-39: tmp = math.sin(th) else: tmp = ky / (kx / th) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 9.6e-39) tmp = sin(th); else tmp = Float64(ky / Float64(kx / th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 9.6e-39) tmp = sin(th); else tmp = ky / (kx / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 9.6e-39], N[Sin[th], $MachinePrecision], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 9.6 \cdot 10^{-39}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\end{array}
\end{array}
if kx < 9.60000000000000063e-39Initial program 91.9%
Taylor expanded in kx around 0 29.7%
if 9.60000000000000063e-39 < kx Initial program 99.4%
Taylor expanded in ky around 0 33.6%
associate-/l*34.2%
associate-/r/34.3%
Simplified34.3%
Taylor expanded in kx around 0 22.7%
Taylor expanded in th around 0 19.3%
associate-/l*19.9%
Simplified19.9%
Final simplification27.2%
(FPCore (kx ky th) :precision binary64 (/ ky (/ kx th)))
double code(double kx, double ky, double th) {
return ky / (kx / th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky / (kx / th)
end function
public static double code(double kx, double ky, double th) {
return ky / (kx / th);
}
def code(kx, ky, th): return ky / (kx / th)
function code(kx, ky, th) return Float64(ky / Float64(kx / th)) end
function tmp = code(kx, ky, th) tmp = ky / (kx / th); end
code[kx_, ky_, th_] := N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{\frac{kx}{th}}
\end{array}
Initial program 93.8%
Taylor expanded in ky around 0 26.2%
associate-/l*27.3%
associate-/r/27.3%
Simplified27.3%
Taylor expanded in kx around 0 17.6%
Taylor expanded in th around 0 13.3%
associate-/l*14.6%
Simplified14.6%
Final simplification14.6%
herbie shell --seed 2023334
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))