
(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 13 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 94.4%
+-commutative94.4%
unpow294.4%
unpow294.4%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.0001)
(- (sin th))
(if (<= (sin ky) 0.005)
(* (sin th) (/ (sin ky) (hypot ky (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0001) {
tmp = -sin(th);
} else if (sin(ky) <= 0.005) {
tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0001) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 0.005) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0001: tmp = -math.sin(th) elif math.sin(ky) <= 0.005: tmp = math.sin(th) * (math.sin(ky) / math.hypot(ky, math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0001) tmp = Float64(-sin(th)); elseif (sin(ky) <= 0.005) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0001) tmp = -sin(th); elseif (sin(ky) <= 0.005) tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0001], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 0.005], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0001:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 0.005:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.00000000000000005e-4Initial program 99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 7.3%
Taylor expanded in ky around 0 38.3%
Taylor expanded in ky around -inf 66.3%
neg-mul-166.3%
Simplified66.3%
if -1.00000000000000005e-4 < (sin.f64 ky) < 0.0050000000000000001Initial program 90.6%
+-commutative90.6%
unpow290.6%
unpow290.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 99.5%
if 0.0050000000000000001 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 64.0%
Final simplification85.2%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.0001)
(* (sin th) (fma 0.5 (/ (pow (sin kx) 2.0) (* ky ky)) -1.0))
(if (<= (sin ky) 0.005)
(* (sin th) (/ (sin ky) (hypot ky (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0001) {
tmp = sin(th) * fma(0.5, (pow(sin(kx), 2.0) / (ky * ky)), -1.0);
} else if (sin(ky) <= 0.005) {
tmp = sin(th) * (sin(ky) / hypot(ky, sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0001) tmp = Float64(sin(th) * fma(0.5, Float64((sin(kx) ^ 2.0) / Float64(ky * ky)), -1.0)); elseif (sin(ky) <= 0.005) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(ky, sin(kx)))); else tmp = sin(th); end return tmp end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0001], N[(N[Sin[th], $MachinePrecision] * N[(0.5 * N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] / N[(ky * ky), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 0.005], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0001:\\
\;\;\;\;\sin th \cdot \mathsf{fma}\left(0.5, \frac{{\sin kx}^{2}}{ky \cdot ky}, -1\right)\\
\mathbf{elif}\;\sin ky \leq 0.005:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.00000000000000005e-4Initial program 99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 7.3%
Taylor expanded in ky around 0 38.3%
Taylor expanded in ky around -inf 66.3%
fma-neg66.3%
unpow266.3%
metadata-eval66.3%
Simplified66.3%
if -1.00000000000000005e-4 < (sin.f64 ky) < 0.0050000000000000001Initial program 90.6%
+-commutative90.6%
unpow290.6%
unpow290.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 99.5%
if 0.0050000000000000001 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 64.0%
Final simplification85.2%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.08) (- (sin th)) (if (<= (sin ky) 0.005) (* (sin th) (/ ky (hypot ky (sin kx)))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.08) {
tmp = -sin(th);
} else if (sin(ky) <= 0.005) {
tmp = sin(th) * (ky / hypot(ky, sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.08) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 0.005) {
tmp = Math.sin(th) * (ky / Math.hypot(ky, Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.08: tmp = -math.sin(th) elif math.sin(ky) <= 0.005: tmp = math.sin(th) * (ky / math.hypot(ky, math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.08) tmp = Float64(-sin(th)); elseif (sin(ky) <= 0.005) tmp = Float64(sin(th) * Float64(ky / hypot(ky, sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.08) tmp = -sin(th); elseif (sin(ky) <= 0.005) tmp = sin(th) * (ky / hypot(ky, sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.08], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 0.005], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sqrt[ky ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.08:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 0.005:\\
\;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0800000000000000017Initial program 99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 6.2%
Taylor expanded in ky around 0 36.0%
Taylor expanded in ky around -inf 65.1%
neg-mul-165.1%
Simplified65.1%
if -0.0800000000000000017 < (sin.f64 ky) < 0.0050000000000000001Initial program 90.7%
+-commutative90.7%
unpow290.7%
unpow290.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 98.7%
Taylor expanded in ky around 0 98.9%
if 0.0050000000000000001 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 64.0%
Final simplification84.8%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -1e-96)
(- (sin th))
(if (<= (sin ky) 2e-148)
(/ ky (/ (sin kx) (sin th)))
(/ (* (sin ky) (sin th)) (sin ky)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-96) {
tmp = -sin(th);
} else if (sin(ky) <= 2e-148) {
tmp = ky / (sin(kx) / sin(th));
} else {
tmp = (sin(ky) * sin(th)) / sin(ky);
}
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(ky) <= (-1d-96)) then
tmp = -sin(th)
else if (sin(ky) <= 2d-148) then
tmp = ky / (sin(kx) / sin(th))
else
tmp = (sin(ky) * sin(th)) / sin(ky)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -1e-96) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 2e-148) {
tmp = ky / (Math.sin(kx) / Math.sin(th));
} else {
tmp = (Math.sin(ky) * Math.sin(th)) / Math.sin(ky);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-96: tmp = -math.sin(th) elif math.sin(ky) <= 2e-148: tmp = ky / (math.sin(kx) / math.sin(th)) else: tmp = (math.sin(ky) * math.sin(th)) / math.sin(ky) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-96) tmp = Float64(-sin(th)); elseif (sin(ky) <= 2e-148) tmp = Float64(ky / Float64(sin(kx) / sin(th))); else tmp = Float64(Float64(sin(ky) * sin(th)) / sin(ky)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -1e-96) tmp = -sin(th); elseif (sin(ky) <= 2e-148) tmp = ky / (sin(kx) / sin(th)); else tmp = (sin(ky) * sin(th)) / sin(ky); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-96], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-148], N[(ky / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-96}:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-148}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{\sin ky}\\
\end{array}
\end{array}
if (sin.f64 ky) < -9.9999999999999991e-97Initial program 99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 35.1%
Taylor expanded in ky around 0 56.4%
Taylor expanded in ky around -inf 62.6%
neg-mul-162.6%
Simplified62.6%
if -9.9999999999999991e-97 < (sin.f64 ky) < 1.99999999999999987e-148Initial program 83.3%
+-commutative83.3%
unpow283.3%
unpow283.3%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 57.4%
*-commutative57.4%
associate-/l*58.5%
Simplified58.5%
if 1.99999999999999987e-148 < (sin.f64 ky) Initial program 99.7%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 56.7%
Final simplification59.1%
(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 94.4%
associate-*l/92.6%
associate-*r/94.3%
+-commutative94.3%
unpow294.3%
unpow294.3%
hypot-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -1e-96)
(- (sin th))
(if (<= (sin ky) 4e-206)
(* (sin th) (/ ky (sin kx)))
(/ (* ky (sin th)) ky))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-96) {
tmp = -sin(th);
} else if (sin(ky) <= 4e-206) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = (ky * sin(th)) / ky;
}
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(ky) <= (-1d-96)) then
tmp = -sin(th)
else if (sin(ky) <= 4d-206) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = (ky * sin(th)) / ky
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -1e-96) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 4e-206) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = (ky * Math.sin(th)) / ky;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-96: tmp = -math.sin(th) elif math.sin(ky) <= 4e-206: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = (ky * math.sin(th)) / ky return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-96) tmp = Float64(-sin(th)); elseif (sin(ky) <= 4e-206) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = Float64(Float64(ky * sin(th)) / ky); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -1e-96) tmp = -sin(th); elseif (sin(ky) <= 4e-206) tmp = sin(th) * (ky / sin(kx)); else tmp = (ky * sin(th)) / ky; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-96], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-206], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-96}:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 4 \cdot 10^{-206}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky \cdot \sin th}{ky}\\
\end{array}
\end{array}
if (sin.f64 ky) < -9.9999999999999991e-97Initial program 99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 35.1%
Taylor expanded in ky around 0 56.4%
Taylor expanded in ky around -inf 62.6%
neg-mul-162.6%
Simplified62.6%
if -9.9999999999999991e-97 < (sin.f64 ky) < 4.00000000000000011e-206Initial program 82.6%
+-commutative82.6%
unpow282.6%
unpow282.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 55.9%
if 4.00000000000000011e-206 < (sin.f64 ky) Initial program 98.8%
+-commutative98.8%
unpow298.8%
unpow298.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 52.4%
Taylor expanded in ky around inf 28.0%
Taylor expanded in ky around 0 57.7%
Final simplification58.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -1e-96)
(- (sin th))
(if (<= (sin ky) 2e-148)
(/ ky (/ (sin kx) (sin th)))
(/ (* ky (sin th)) ky))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-96) {
tmp = -sin(th);
} else if (sin(ky) <= 2e-148) {
tmp = ky / (sin(kx) / sin(th));
} else {
tmp = (ky * sin(th)) / ky;
}
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(ky) <= (-1d-96)) then
tmp = -sin(th)
else if (sin(ky) <= 2d-148) then
tmp = ky / (sin(kx) / sin(th))
else
tmp = (ky * sin(th)) / ky
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -1e-96) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 2e-148) {
tmp = ky / (Math.sin(kx) / Math.sin(th));
} else {
tmp = (ky * Math.sin(th)) / ky;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-96: tmp = -math.sin(th) elif math.sin(ky) <= 2e-148: tmp = ky / (math.sin(kx) / math.sin(th)) else: tmp = (ky * math.sin(th)) / ky return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-96) tmp = Float64(-sin(th)); elseif (sin(ky) <= 2e-148) tmp = Float64(ky / Float64(sin(kx) / sin(th))); else tmp = Float64(Float64(ky * sin(th)) / ky); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -1e-96) tmp = -sin(th); elseif (sin(ky) <= 2e-148) tmp = ky / (sin(kx) / sin(th)); else tmp = (ky * sin(th)) / ky; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-96], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-148], N[(ky / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-96}:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-148}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\frac{ky \cdot \sin th}{ky}\\
\end{array}
\end{array}
if (sin.f64 ky) < -9.9999999999999991e-97Initial program 99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 35.1%
Taylor expanded in ky around 0 56.4%
Taylor expanded in ky around -inf 62.6%
neg-mul-162.6%
Simplified62.6%
if -9.9999999999999991e-97 < (sin.f64 ky) < 1.99999999999999987e-148Initial program 83.3%
+-commutative83.3%
unpow283.3%
unpow283.3%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 57.4%
*-commutative57.4%
associate-/l*58.5%
Simplified58.5%
if 1.99999999999999987e-148 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 47.8%
Taylor expanded in ky around inf 24.1%
Taylor expanded in ky around 0 56.7%
Final simplification59.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -1e-197) (- (sin th)) (/ (* ky (sin th)) ky)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -1e-197) {
tmp = -sin(th);
} else {
tmp = (ky * sin(th)) / ky;
}
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(ky) <= (-1d-197)) then
tmp = -sin(th)
else
tmp = (ky * sin(th)) / ky
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -1e-197) {
tmp = -Math.sin(th);
} else {
tmp = (ky * Math.sin(th)) / ky;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -1e-197: tmp = -math.sin(th) else: tmp = (ky * math.sin(th)) / ky return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -1e-197) tmp = Float64(-sin(th)); else tmp = Float64(Float64(ky * sin(th)) / ky); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -1e-197) tmp = -sin(th); else tmp = (ky * sin(th)) / ky; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-197], (-N[Sin[th], $MachinePrecision]), N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / ky), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-197}:\\
\;\;\;\;-\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky \cdot \sin th}{ky}\\
\end{array}
\end{array}
if (sin.f64 ky) < -9.9999999999999999e-198Initial program 95.1%
+-commutative95.1%
unpow295.1%
unpow295.1%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 50.9%
Taylor expanded in ky around 0 67.0%
Taylor expanded in ky around -inf 57.5%
neg-mul-157.5%
Simplified57.5%
if -9.9999999999999999e-198 < (sin.f64 ky) Initial program 93.9%
+-commutative93.9%
unpow293.9%
unpow293.9%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 67.5%
Taylor expanded in ky around inf 29.3%
Taylor expanded in ky around 0 49.5%
Final simplification52.8%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (- (sin th))))
(if (<= ky -8.2e-199)
t_1
(if (<= ky 3.3e-141)
(* -0.16666666666666666 (pow th 3.0))
(if (<= ky 9.6e+24) (sin th) t_1)))))
double code(double kx, double ky, double th) {
double t_1 = -sin(th);
double tmp;
if (ky <= -8.2e-199) {
tmp = t_1;
} else if (ky <= 3.3e-141) {
tmp = -0.16666666666666666 * pow(th, 3.0);
} else if (ky <= 9.6e+24) {
tmp = sin(th);
} else {
tmp = 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(th)
if (ky <= (-8.2d-199)) then
tmp = t_1
else if (ky <= 3.3d-141) then
tmp = (-0.16666666666666666d0) * (th ** 3.0d0)
else if (ky <= 9.6d+24) then
tmp = sin(th)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = -Math.sin(th);
double tmp;
if (ky <= -8.2e-199) {
tmp = t_1;
} else if (ky <= 3.3e-141) {
tmp = -0.16666666666666666 * Math.pow(th, 3.0);
} else if (ky <= 9.6e+24) {
tmp = Math.sin(th);
} else {
tmp = t_1;
}
return tmp;
}
def code(kx, ky, th): t_1 = -math.sin(th) tmp = 0 if ky <= -8.2e-199: tmp = t_1 elif ky <= 3.3e-141: tmp = -0.16666666666666666 * math.pow(th, 3.0) elif ky <= 9.6e+24: tmp = math.sin(th) else: tmp = t_1 return tmp
function code(kx, ky, th) t_1 = Float64(-sin(th)) tmp = 0.0 if (ky <= -8.2e-199) tmp = t_1; elseif (ky <= 3.3e-141) tmp = Float64(-0.16666666666666666 * (th ^ 3.0)); elseif (ky <= 9.6e+24) tmp = sin(th); else tmp = t_1; end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = -sin(th); tmp = 0.0; if (ky <= -8.2e-199) tmp = t_1; elseif (ky <= 3.3e-141) tmp = -0.16666666666666666 * (th ^ 3.0); elseif (ky <= 9.6e+24) tmp = sin(th); else tmp = t_1; end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = (-N[Sin[th], $MachinePrecision])}, If[LessEqual[ky, -8.2e-199], t$95$1, If[LessEqual[ky, 3.3e-141], N[(-0.16666666666666666 * N[Power[th, 3.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 9.6e+24], N[Sin[th], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -\sin th\\
\mathbf{if}\;ky \leq -8.2 \cdot 10^{-199}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;ky \leq 3.3 \cdot 10^{-141}:\\
\;\;\;\;-0.16666666666666666 \cdot {th}^{3}\\
\mathbf{elif}\;ky \leq 9.6 \cdot 10^{+24}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if ky < -8.20000000000000043e-199 or 9.6000000000000003e24 < ky Initial program 96.5%
+-commutative96.5%
unpow296.5%
unpow296.5%
hypot-def99.8%
Simplified99.8%
Taylor expanded in ky around 0 36.7%
Taylor expanded in ky around 0 53.4%
Taylor expanded in ky around -inf 40.3%
neg-mul-140.3%
Simplified40.3%
if -8.20000000000000043e-199 < ky < 3.29999999999999999e-141Initial program 84.7%
associate-*l/79.4%
associate-*r/84.8%
+-commutative84.8%
unpow284.8%
unpow284.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 6.5%
Taylor expanded in th around 0 4.1%
Taylor expanded in th around inf 35.1%
if 3.29999999999999999e-141 < ky < 9.6000000000000003e24Initial program 99.8%
+-commutative99.8%
unpow299.8%
unpow299.8%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 44.2%
Final simplification39.8%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -9.6e-297) (not (<= ky 9.6e+24))) (- (sin th)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -9.6e-297) || !(ky <= 9.6e+24)) {
tmp = -sin(th);
} 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 <= (-9.6d-297)) .or. (.not. (ky <= 9.6d+24))) then
tmp = -sin(th)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -9.6e-297) || !(ky <= 9.6e+24)) {
tmp = -Math.sin(th);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -9.6e-297) or not (ky <= 9.6e+24): tmp = -math.sin(th) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -9.6e-297) || !(ky <= 9.6e+24)) tmp = Float64(-sin(th)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -9.6e-297) || ~((ky <= 9.6e+24))) tmp = -sin(th); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -9.6e-297], N[Not[LessEqual[ky, 9.6e+24]], $MachinePrecision]], (-N[Sin[th], $MachinePrecision]), N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -9.6 \cdot 10^{-297} \lor \neg \left(ky \leq 9.6 \cdot 10^{+24}\right):\\
\;\;\;\;-\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -9.5999999999999998e-297 or 9.6000000000000003e24 < ky Initial program 95.0%
+-commutative95.0%
unpow295.0%
unpow295.0%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 45.4%
Taylor expanded in ky around 0 59.9%
Taylor expanded in ky around -inf 36.0%
neg-mul-136.0%
Simplified36.0%
if -9.5999999999999998e-297 < ky < 9.6000000000000003e24Initial program 93.0%
+-commutative93.0%
unpow293.0%
unpow293.0%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 29.0%
Final simplification33.9%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return 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(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 94.4%
+-commutative94.4%
unpow294.4%
unpow294.4%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 22.2%
Final simplification22.2%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 94.4%
associate-*l/92.6%
associate-*r/94.3%
+-commutative94.3%
unpow294.3%
unpow294.3%
hypot-def99.6%
Simplified99.6%
Taylor expanded in kx around 0 22.2%
Taylor expanded in th around 0 9.9%
Final simplification9.9%
herbie shell --seed 2023215
(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)))