
(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 12 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.5%
+-commutative94.5%
unpow294.5%
unpow294.5%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.04)
(sin th)
(if (<= (sin th) 0.003)
(* th (/ (sin ky) (hypot (sin kx) (sin ky))))
(* (sin ky) (fabs (/ (sin th) (sin kx)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.04) {
tmp = sin(th);
} else if (sin(th) <= 0.003) {
tmp = th * (sin(ky) / hypot(sin(kx), sin(ky)));
} else {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.04) {
tmp = Math.sin(th);
} else if (Math.sin(th) <= 0.003) {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky)));
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.04: tmp = math.sin(th) elif math.sin(th) <= 0.003: tmp = th * (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.04) tmp = sin(th); elseif (sin(th) <= 0.003) tmp = Float64(th * Float64(sin(ky) / hypot(sin(kx), sin(ky)))); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.04) tmp = sin(th); elseif (sin(th) <= 0.003) tmp = th * (sin(ky) / hypot(sin(kx), sin(ky))); else tmp = sin(ky) * abs((sin(th) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.04], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.003], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.04:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin th \leq 0.003:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.0400000000000000008Initial program 94.7%
+-commutative94.7%
unpow294.7%
unpow294.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 27.5%
if -0.0400000000000000008 < (sin.f64 th) < 0.0030000000000000001Initial program 95.1%
associate-*l/90.6%
*-commutative90.6%
associate-*l/95.0%
+-commutative95.0%
unpow295.0%
unpow295.0%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 93.9%
*-commutative93.9%
+-commutative93.9%
Simplified93.9%
expm1-log1p-u93.9%
expm1-udef23.4%
Applied egg-rr24.6%
expm1-def99.4%
expm1-log1p99.4%
Simplified99.4%
if 0.0030000000000000001 < (sin.f64 th) Initial program 93.3%
associate-*l/93.3%
*-commutative93.3%
associate-*l/93.1%
+-commutative93.1%
unpow293.1%
unpow293.1%
hypot-def99.3%
Simplified99.3%
Taylor expanded in ky around 0 24.8%
add-sqr-sqrt23.9%
sqrt-unprod35.3%
pow235.3%
Applied egg-rr35.3%
unpow235.3%
rem-sqrt-square40.2%
Simplified40.2%
Final simplification68.5%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin kx) (sin ky))))
(if (<= (sin ky) -0.0001)
(* th (/ (sin ky) t_1))
(if (<= (sin ky) 4e-7) (/ (* ky (sin th)) t_1) (sin th)))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(kx), sin(ky));
double tmp;
if (sin(ky) <= -0.0001) {
tmp = th * (sin(ky) / t_1);
} else if (sin(ky) <= 4e-7) {
tmp = (ky * sin(th)) / t_1;
} 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.0001) {
tmp = th * (Math.sin(ky) / t_1);
} else if (Math.sin(ky) <= 4e-7) {
tmp = (ky * Math.sin(th)) / t_1;
} 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.0001: tmp = th * (math.sin(ky) / t_1) elif math.sin(ky) <= 4e-7: tmp = (ky * math.sin(th)) / t_1 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.0001) tmp = Float64(th * Float64(sin(ky) / t_1)); elseif (sin(ky) <= 4e-7) tmp = Float64(Float64(ky * sin(th)) / t_1); 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.0001) tmp = th * (sin(ky) / t_1); elseif (sin(ky) <= 4e-7) tmp = (ky * sin(th)) / t_1; 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.0001], N[(th * N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-7], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $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.0001:\\
\;\;\;\;th \cdot \frac{\sin ky}{t_1}\\
\mathbf{elif}\;\sin ky \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{ky \cdot \sin th}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -1.00000000000000005e-4Initial program 99.7%
associate-*l/99.5%
*-commutative99.5%
associate-*l/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 55.9%
*-commutative55.9%
+-commutative55.9%
Simplified55.9%
expm1-log1p-u55.1%
expm1-udef6.3%
Applied egg-rr6.3%
expm1-def55.4%
expm1-log1p56.2%
Simplified56.2%
if -1.00000000000000005e-4 < (sin.f64 ky) < 3.9999999999999998e-7Initial program 89.1%
+-commutative89.1%
unpow289.1%
unpow289.1%
hypot-def99.8%
Simplified99.8%
associate-*l/91.3%
hypot-udef84.3%
unpow284.3%
unpow284.3%
+-commutative84.3%
unpow284.3%
unpow284.3%
hypot-def91.3%
Applied egg-rr91.3%
Taylor expanded in ky around 0 91.0%
if 3.9999999999999998e-7 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 66.7%
Final simplification76.0%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) 1e-179)
(* (sin th) (/ (sin ky) (sin kx)))
(if (<= (sin ky) 2e-92)
(/ (* (sin ky) (sin th)) (sin ky))
(if (<= (sin ky) 2e-66) (* th (/ ky (sin kx))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-179) {
tmp = sin(th) * (sin(ky) / sin(kx));
} else if (sin(ky) <= 2e-92) {
tmp = (sin(ky) * sin(th)) / sin(ky);
} else if (sin(ky) <= 2e-66) {
tmp = 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 (sin(ky) <= 1d-179) then
tmp = sin(th) * (sin(ky) / sin(kx))
else if (sin(ky) <= 2d-92) then
tmp = (sin(ky) * sin(th)) / sin(ky)
else if (sin(ky) <= 2d-66) then
tmp = 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 (Math.sin(ky) <= 1e-179) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else if (Math.sin(ky) <= 2e-92) {
tmp = (Math.sin(ky) * Math.sin(th)) / Math.sin(ky);
} else if (Math.sin(ky) <= 2e-66) {
tmp = th * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-179: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) elif math.sin(ky) <= 2e-92: tmp = (math.sin(ky) * math.sin(th)) / math.sin(ky) elif math.sin(ky) <= 2e-66: tmp = th * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-179) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); elseif (sin(ky) <= 2e-92) tmp = Float64(Float64(sin(ky) * sin(th)) / sin(ky)); elseif (sin(ky) <= 2e-66) tmp = Float64(th * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-179) tmp = sin(th) * (sin(ky) / sin(kx)); elseif (sin(ky) <= 2e-92) tmp = (sin(ky) * sin(th)) / sin(ky); elseif (sin(ky) <= 2e-66) tmp = th * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-179], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-92], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sin[ky], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-66], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-179}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{\sin ky}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-66}:\\
\;\;\;\;th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1e-179Initial program 92.2%
Taylor expanded in ky around 0 32.6%
if 1e-179 < (sin.f64 ky) < 1.99999999999999998e-92Initial program 89.3%
+-commutative89.3%
unpow289.3%
unpow289.3%
hypot-def99.7%
Simplified99.7%
associate-*l/89.9%
hypot-udef89.1%
unpow289.1%
unpow289.1%
+-commutative89.1%
unpow289.1%
unpow289.1%
hypot-def89.9%
Applied egg-rr89.9%
Taylor expanded in kx around 0 60.3%
if 1.99999999999999998e-92 < (sin.f64 ky) < 2e-66Initial program 100.0%
associate-*l/100.0%
*-commutative100.0%
associate-*l/100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-def100.0%
Simplified100.0%
Taylor expanded in th around 0 99.6%
*-commutative99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in ky around 0 100.0%
associate-/l*100.0%
Simplified100.0%
associate-/r/100.0%
Applied egg-rr100.0%
if 2e-66 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 65.4%
Final simplification46.5%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-179) (* (sin th) (/ (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-179) {
tmp = sin(th) * (sin(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 (sin(ky) <= 1d-179) then
tmp = sin(th) * (sin(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 (Math.sin(ky) <= 1e-179) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-179: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-179) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-179) tmp = sin(th) * (sin(ky) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-179], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-179}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1e-179Initial program 92.2%
Taylor expanded in ky around 0 32.6%
if 1e-179 < (sin.f64 ky) Initial program 97.9%
+-commutative97.9%
unpow297.9%
unpow297.9%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 61.4%
Final simplification44.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -5e-295) (* th (/ ky (sin kx))) (if (<= (sin ky) 1e-161) (/ (* ky (sin th)) kx) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -5e-295) {
tmp = th * (ky / sin(kx));
} else if (sin(ky) <= 1e-161) {
tmp = (ky * sin(th)) / 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 (sin(ky) <= (-5d-295)) then
tmp = th * (ky / sin(kx))
else if (sin(ky) <= 1d-161) then
tmp = (ky * sin(th)) / kx
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -5e-295) {
tmp = th * (ky / Math.sin(kx));
} else if (Math.sin(ky) <= 1e-161) {
tmp = (ky * Math.sin(th)) / kx;
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -5e-295: tmp = th * (ky / math.sin(kx)) elif math.sin(ky) <= 1e-161: tmp = (ky * math.sin(th)) / kx else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -5e-295) tmp = Float64(th * Float64(ky / sin(kx))); elseif (sin(ky) <= 1e-161) tmp = Float64(Float64(ky * sin(th)) / kx); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -5e-295) tmp = th * (ky / sin(kx)); elseif (sin(ky) <= 1e-161) tmp = (ky * sin(th)) / kx; else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -5e-295], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-161], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / kx), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -5 \cdot 10^{-295}:\\
\;\;\;\;th \cdot \frac{ky}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 10^{-161}:\\
\;\;\;\;\frac{ky \cdot \sin th}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -5.00000000000000008e-295Initial program 96.0%
associate-*l/91.2%
*-commutative91.2%
associate-*l/95.9%
+-commutative95.9%
unpow295.9%
unpow295.9%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 52.5%
*-commutative52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in ky around 0 15.5%
associate-/l*17.6%
Simplified17.6%
associate-/r/17.6%
Applied egg-rr17.6%
if -5.00000000000000008e-295 < (sin.f64 ky) < 1.00000000000000003e-161Initial program 74.6%
associate-*l/74.4%
*-commutative74.4%
associate-*l/74.4%
+-commutative74.4%
unpow274.4%
unpow274.4%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 64.3%
Taylor expanded in kx around 0 49.2%
Taylor expanded in ky around 0 49.2%
if 1.00000000000000003e-161 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 62.3%
Final simplification39.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-179) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-179) {
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 (sin(ky) <= 1d-179) 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 (Math.sin(ky) <= 1e-179) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-179: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-179) 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 (sin(ky) <= 1e-179) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-179], 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}\;\sin ky \leq 10^{-179}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1e-179Initial program 92.2%
Taylor expanded in ky around 0 30.4%
if 1e-179 < (sin.f64 ky) Initial program 97.9%
+-commutative97.9%
unpow297.9%
unpow297.9%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 61.4%
Final simplification43.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-179) (/ (sin th) (/ (sin kx) ky)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-179) {
tmp = sin(th) / (sin(kx) / ky);
} 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 (sin(ky) <= 1d-179) then
tmp = sin(th) / (sin(kx) / ky)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 1e-179) {
tmp = Math.sin(th) / (Math.sin(kx) / ky);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-179: tmp = math.sin(th) / (math.sin(kx) / ky) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-179) tmp = Float64(sin(th) / Float64(sin(kx) / ky)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-179) tmp = sin(th) / (sin(kx) / ky); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-179], N[(N[Sin[th], $MachinePrecision] / N[(N[Sin[kx], $MachinePrecision] / ky), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-179}:\\
\;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1e-179Initial program 92.2%
+-commutative92.2%
unpow292.2%
unpow292.2%
hypot-def99.7%
Simplified99.7%
*-commutative99.7%
clear-num99.6%
un-div-inv99.7%
hypot-udef92.1%
unpow292.1%
unpow292.1%
+-commutative92.1%
unpow292.1%
unpow292.1%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 30.4%
if 1e-179 < (sin.f64 ky) Initial program 97.9%
+-commutative97.9%
unpow297.9%
unpow297.9%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 61.4%
Final simplification43.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-183) (* th (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-183) {
tmp = 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 (sin(ky) <= 1d-183) then
tmp = 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 (Math.sin(ky) <= 1e-183) {
tmp = th * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-183: tmp = th * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-183) tmp = Float64(th * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-183) tmp = th * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-183], N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-183}:\\
\;\;\;\;th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1.00000000000000001e-183Initial program 92.0%
associate-*l/88.1%
*-commutative88.1%
associate-*l/91.9%
+-commutative91.9%
unpow291.9%
unpow291.9%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 49.8%
*-commutative49.8%
+-commutative49.8%
Simplified49.8%
Taylor expanded in ky around 0 20.5%
associate-/l*22.8%
Simplified22.8%
associate-/r/22.9%
Applied egg-rr22.9%
if 1.00000000000000001e-183 < (sin.f64 ky) Initial program 97.9%
+-commutative97.9%
unpow297.9%
unpow297.9%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.4%
Final simplification38.9%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -1.7e+21) (not (<= ky 6.5e-181))) (sin th) (* th (/ ky kx))))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -1.7e+21) || !(ky <= 6.5e-181)) {
tmp = sin(th);
} else {
tmp = th * (ky / 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 ((ky <= (-1.7d+21)) .or. (.not. (ky <= 6.5d-181))) then
tmp = sin(th)
else
tmp = th * (ky / kx)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -1.7e+21) || !(ky <= 6.5e-181)) {
tmp = Math.sin(th);
} else {
tmp = th * (ky / kx);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -1.7e+21) or not (ky <= 6.5e-181): tmp = math.sin(th) else: tmp = th * (ky / kx) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -1.7e+21) || !(ky <= 6.5e-181)) tmp = sin(th); else tmp = Float64(th * Float64(ky / kx)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -1.7e+21) || ~((ky <= 6.5e-181))) tmp = sin(th); else tmp = th * (ky / kx); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -1.7e+21], N[Not[LessEqual[ky, 6.5e-181]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1.7 \cdot 10^{+21} \lor \neg \left(ky \leq 6.5 \cdot 10^{-181}\right):\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\
\end{array}
\end{array}
if ky < -1.7e21 or 6.4999999999999997e-181 < ky Initial program 98.5%
+-commutative98.5%
unpow298.5%
unpow298.5%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 41.0%
if -1.7e21 < ky < 6.4999999999999997e-181Initial program 87.5%
associate-*l/81.3%
*-commutative81.3%
associate-*l/87.4%
+-commutative87.4%
unpow287.4%
unpow287.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 46.9%
*-commutative46.9%
+-commutative46.9%
Simplified46.9%
Taylor expanded in ky around 0 31.2%
associate-/l*34.9%
Simplified34.9%
Taylor expanded in kx around 0 28.6%
associate-/l*32.3%
Simplified32.3%
associate-/r/32.4%
Applied egg-rr32.4%
Final simplification37.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky -1.7e+21) th (if (<= ky 3.3e-148) (* th (/ ky kx)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1.7e+21) {
tmp = th;
} else if (ky <= 3.3e-148) {
tmp = th * (ky / kx);
} else {
tmp = 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 <= (-1.7d+21)) then
tmp = th
else if (ky <= 3.3d-148) then
tmp = th * (ky / kx)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1.7e+21) {
tmp = th;
} else if (ky <= 3.3e-148) {
tmp = th * (ky / kx);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -1.7e+21: tmp = th elif ky <= 3.3e-148: tmp = th * (ky / kx) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -1.7e+21) tmp = th; elseif (ky <= 3.3e-148) tmp = Float64(th * Float64(ky / kx)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -1.7e+21) tmp = th; elseif (ky <= 3.3e-148) tmp = th * (ky / kx); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -1.7e+21], th, If[LessEqual[ky, 3.3e-148], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1.7 \cdot 10^{+21}:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 3.3 \cdot 10^{-148}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -1.7e21 or 3.29999999999999974e-148 < ky Initial program 99.7%
associate-*l/99.4%
*-commutative99.4%
associate-*l/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.5%
Simplified99.5%
Taylor expanded in th around 0 55.3%
*-commutative55.3%
+-commutative55.3%
Simplified55.3%
Taylor expanded in kx around 0 23.7%
if -1.7e21 < ky < 3.29999999999999974e-148Initial program 86.5%
associate-*l/80.8%
*-commutative80.8%
associate-*l/86.4%
+-commutative86.4%
unpow286.4%
unpow286.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 46.2%
*-commutative46.2%
+-commutative46.2%
Simplified46.2%
Taylor expanded in ky around 0 31.9%
associate-/l*35.3%
Simplified35.3%
Taylor expanded in kx around 0 29.6%
associate-/l*33.0%
Simplified33.0%
associate-/r/33.0%
Applied egg-rr33.0%
Final simplification27.3%
(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.5%
associate-*l/92.1%
*-commutative92.1%
associate-*l/94.4%
+-commutative94.4%
unpow294.4%
unpow294.4%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 51.8%
*-commutative51.8%
+-commutative51.8%
Simplified51.8%
Taylor expanded in kx around 0 17.1%
Final simplification17.1%
herbie shell --seed 2023320
(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)))