Tag Info

New answers tagged

0

Below I give some code for cvt that converts a number string to a number with the same accuracy as the string. Example: datastring = "8.2457409790900005e+08\n8.2457409810599995e+08"; StringCases[datastring, s : floatpat :> cvt[StringSplit[s, "e" | "E"]]] (* {8.2457409790900005*10^8, 8.2457409810599995*10^8} *) Some slight variations: ...


0

Note that the trick of adding a zero only works for numbers in scientific notation: This is a convoluted approach that works with arbitrary floats: toarbprecision[string_] := Module[{dp, ep, firstnonzero, mend, pow, dig}, dp = StringPosition[string, "."][[1, 1]]; ep = StringPosition[string, "e" | "E"]; firstnonzero = ...


3

You need to have sufficient precision in your input file to trigger an arbitrary precision representation automatically. In your example, you just need one more digit as, I believe, one digit past machine doesn't typically do it. ImportString[ "8.24574097909000040e+08,8.2457409790900004e+08", "CSV"] (* Out: {{8.2457409790900004*10^8, 8.24574*10^8}} *) ...


7

Update: I think this is a numeric precision problem rather than a matter of the behavior of Re. I don't know if I should leave my original answer below for reference or remove it. Consider: expr = MathieuC[MathieuCharacteristicA[-(19999999999/10000000000), -2], -2, 5]; N[expr] N[expr, 15] SetPrecision[expr, 15] -9.85323*10^-16 + 3.39211*10^-8 I ...


6

I think your problems are made by order of appling Re and N. Re@Bloch is not yet a state before the computation. So you have to apply the computation by Re@Norder. Block[{$MaxExtraPrecision = 500, ϵ = 10^-10}, Re@N@BlochΚ[-2 + ϵ, -1, -10]] Block[{$MaxExtraPrecision = 1000, ϵ = 10^-20}, Re@N@BlochΚ[-2 + ϵ, -1, -10]] Block[{$MaxExtraPrecision = 500, ϵ = ...


3

If we compare N on the exact values with the MachinePrecision values, we see that the second two graphs (of the first quartet) look correct and the first two are wrong. Block[{z = 0}, Table[With[{V0 = -1, κ = 2 - ϵ}, Re@MathieuC[MathieuCharacteristicA[κ, V0], V0, z]], {ϵ, {15/10*10^-8, 18/10*10^-8}}] ] N[%, 6] (* ...


2

In Mathematica 10.0: MandelbrotSetPlot[{-2 - I, 1 + I}] (Admittedly, this doesn't address what's wrong with the code in the original question, but if you just want to get a Mandelbrot set plot, surely a built-in function is likely to be reasonably efficient.)



Top 50 recent answers are included