private static void BesselLimitConvergenceSummary <N>(string filepath) where N : struct, IConstant { using (StreamWriter sw = new StreamWriter(filepath)) { sw.WriteLine($"bits: {MultiPrecision<N>.Bits}"); sw.WriteLine("nu,z,terms"); for (decimal nu = 0; nu <= 4; nu += 1 / 32m) { Console.WriteLine(nu); int z, terms; for (z = 1; z <= 65536; z *= 2) { terms = BesselLimitApprox <N> .BesselTermConvergence(nu, z); Console.WriteLine($"{z},{terms}"); if (terms < int.MaxValue) { break; } } while (z >= 4) { z = z * 7 / 8; terms = BesselLimitApprox <N> .BesselTermConvergence(nu, z); Console.WriteLine($"{z},{terms}"); if (terms >= int.MaxValue) { break; } } z = z / 4 * 4; while (true) { z += 4; terms = BesselLimitApprox <N> .BesselTermConvergence(nu, z); Console.WriteLine($"{z},{terms}"); if (terms < int.MaxValue) { break; } } sw.WriteLine($"{nu},{z},{terms}"); Console.WriteLine($"{nu},{z},{terms}"); } } }
private static void BesselNearZeroConvergenceSummary <N, M>(string filepath, int z_init, int terms) where N : struct, IConstant where M : struct, IConstant { using (StreamWriter sw = new StreamWriter(filepath)) { sw.WriteLine($"bits: {MultiPrecision<N>.Bits}"); int min_matchbits = MultiPrecision <N> .Bits; for (decimal nu = 0; nu <= 2; nu += 1 / 16m) { sw.WriteLine($"nu: {nu}"); for (decimal z = z_init - 4; z <= z_init + 4; z += 1 / 32m) { MultiPrecision <N> t = BesselLimitApprox <N> .Value(nu, z, terms); MultiPrecision <N> s = BesselNearZeroApprox <N, M> .Value(nu, z); sw.WriteLine($" z: {z}"); sw.WriteLine($" LM : {t}"); sw.WriteLine($" NZ : {s}"); sw.WriteLine($" LM : {t.ToHexcode()}"); sw.WriteLine($" NZ : {s.ToHexcode()}"); MultiPrecision <N> err = MultiPrecision <N> .Abs(t - s); sw.WriteLine($" err : {err}"); for (int keepbits = MultiPrecision <N> .Bits; keepbits >= 0; keepbits--) { if (keepbits == 0) { min_matchbits = 0; } else if (MultiPrecision <N> .RoundMantissa(t, MultiPrecision <N> .Bits - keepbits) == MultiPrecision <N> .RoundMantissa(s, MultiPrecision <N> .Bits - keepbits)) { sw.WriteLine($" matchbits : {keepbits}"); if (keepbits < min_matchbits) { min_matchbits = keepbits; } break; } } } } sw.WriteLine($"min matchbits : {min_matchbits}"); } }
private static void BesselLimitValuesSummary <N>(string filepath, int z_init, int terms) where N : struct, IConstant { using (StreamWriter sw = new StreamWriter(filepath)) { sw.WriteLine($"bits: {MultiPrecision<N>.Bits}"); for (decimal nu = 0; nu <= 2; nu += 1 / 32m) { sw.WriteLine($"nu: {nu}"); for (decimal z = z_init; z <= z_init + 4; z += 0.25m) { MultiPrecision <N> t = BesselLimitApprox <N> .Value(nu, z, terms); sw.WriteLine($" z: {z}"); sw.WriteLine($" {t}"); sw.WriteLine($" {t.ToHexcode()}"); } } } }