21

Quit the kernel before each test. This is on MMA 10.3 on Mac OS X. Simplify the problem We can simplify so that tmp is much much smaller and easier to analyse: rot1 = RotationTransform[{{1, 0, 1}, {0, 0, -1}}, {0, 0, 0}]; tmp = rot1@Tuples[Range[3, 6], 3]; grouptmp1 = GroupBy[tmp, N[Last[#], 8] &]; grouptmp2 = GroupBy[tmp, N[Last[#], 8] &]; ...


19

It looks like a problem of numeric cache: SetSystemOptions["CacheOptions" -> {"Numeric" -> {"Cache" -> False}}]; tmp = {3/Sqrt[2] + 3 Sqrt[2], 3/Sqrt[2] + 3 Sqrt[2]}; grouptmp1 = GroupBy[tmp, N[#, 8] &]; grouptmp2 = GroupBy[tmp, N[#, 8] &]; grouptmp1 === grouptmp2 (* True *) With caching I get False. See also Simon Woods's comment. There ...


17

To get exact output, use exact input (and please input your question using plain text Mathematica code that one can easily copy). Clear[t]; x = Rationalize[3.33333]; eq = x*10^(-15) - x*Exp[-t/5000000]*10^(-15) == 10^(-122); sol = t /. First@Solve[eq, t]; sol = sol /. C[1] -> 0 eq /. t -> sol t should be positive. Since $MaxExtraPrecision = 1000; N[...


15

There are infinitely many (continuum) solutions and basically one cannot list them all e.g. because of the Cantor theorem. This is the reason why numerical approach is unsatisfactory. However we can make use of FindRoot to find a finite numerical subset of the solution space. Numerical solutions First we set up a net of values of x and starting point of y ...


14

lst = {{2, -2}, {1, 5}, {1, -3}, {-3, 3}}; Pick[lst, Total[lst, {2}], 0] {{2,-2}, {-3,3}} First @ Timing[res0 = Pick[Ta, Total[Ta, {2}], 0];] 0.093750 First @ Timing[res0a = Pick[Ta, Total /@ Ta, 0];] 0.187500 First @ Timing[res0b = Pick[Ta, Plus @@ Transpose[Ta], 0];] (*thanks: 2012rcampion *) 0.062500 First @ Timing[res1 = DeleteCases[Ta,...


14

I think it is better to use Cartesian coordinates because one does not have to deal with the periodicity in p. To have control on the meshing of the the region, we tell Mathematica explicitly to discretize it. PrecisionGoal -> 6 controls the meshing at the boundary. But this does not always work. Alternatively, one can use MaxCellMeasure -> 0.001 or a ...


13

Here is a analysis of all the problems related to Mathematica in your question. Briefly summarized, These are 3 problems : the lack of build-in tools to visualize the potential and vector field in polar coordinates. boundary problems : Whatever is the real geometry you are interested (not clear in your question, especially you want to optain 1.9 pF/m),...


12

I've now created https://github.com/barrycarter/bcapps/blob/master/MATHEMATICA/nearestPhysicalConstant.mx as a first cut at doing this. Important notes/caveats: This is not a professional/"real" package. To use, do math -initfile PhysicalConstant.mx on the command line or <<PhysicalConstant.mx after starting Mathematical. The function ...


12

The problems at hand comes from using inadequate numerical approximation. The equation behind is quite simple and it can be solved exactly, we put 10/3 instead of 3.33333 (if usual mathematical meaning is assumed use 333333/100000 instead of 10/3) : t0 = t /. Solve[10/3 (1 - Exp[-(t/5000000)]) 10^-15 == 10^-122, t, Reals]//First 5000000 (108 Log[2] + 108 ...


11

Yes, by doing this (similar to this): Unprotect[Power]; Power[0|0., 0|0.] = 1; Protect[Power]; If you want to revert to normal: Unprotect[Power]; ClearAll[Power]; Protect[Power]; The downside is that it doesn't make sense mathematically, and from a false premise you could reach a false conclusion. You better constrain your function in some other way. Try ...


11

Your numericRoots are OK. The core of your problem is that you use Expand to put your polynomial into power series form. High order power series are numerically unstable. The form your z function yields by itself is much better: z[8, c] /. numericRoots // Abs // Max (* 9.87841*10^-11 *) Expanding on my answer here: "I can see that what you're saying is ...


11

direct implementation of Chudnovsky formula for reference: a[0] = 1; a[k_] := a[k] = a[k - 1] (-(((-1 + 2 k) (-5 + 6 k) (-1 + 6 k) (13591409 +545140134 k))/ (10939058860032000 k^3 (-531548725 + 545140134 k)))) (pi1 = N[((426880 Sqrt[10005])/(13591409 Sum[ a[k], {k, 0, 500}])),10000]) // AbsoluteTiming // First ...


8

You can use ChartElementFunction: For Version 9: f[{{xmin_, xmax_}, {ymin_, ymax_}}, a_ , b_] := {Rectangle[{xmin, ymin}, {xmax, ymax}, RoundingRadius -> 0.2], Text[Style[Length@a, Large, Bold, Black], Mean /@ {{xmin, xmax}, {ymin, ymax}}]} DensityHistogram[a, {{{.0001, .001, .01, .1, 1, 10, 100}}, {{.01, .1, 1, 10, ...


8

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, ϵ = 10^-...


8

Here is an adaptation of MATLAB code from Trefethen, Ten Digit Algorithms (2005), based on Borwein & Borwein, The Arithmetic-Geometric Mean and Fast Computation of Elementary Functions (1984) that calculates $\pi$ via the AGM method. ClearAll[npi]; npi[digits_] := Block[{two, iter}, iter[{x_, y_, p_}] := With[{s = Sqrt@x}, {(s + 1/s)/2, ...


8

The documentation for N says that N[expr, n] attempts to give a result with n-digit precision. In the Wolfram Language, or any language, precision is not the same as decimal places. While it might seem like N is there to give us results with a certain number of decimal places, it actually has more to do with the amount of precision used in calculations ...


8

But a 0 / 1 error warning was generated. The error is 1/0 and not 0/1, it happened because you used machine floating point numbers. f[k_] := (4^k (4^k - 1.) Abs[BernoulliB[2 k]])/(2 k)!; n = 89; 1/Power[f[n], (2 n - 1)^-1] gives is too small to represent as a normalized machine number; precision \ may be lost Power::infy But if you change the ...


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 -0....


7

BarChart[Counts[{"a", "a", "b", "c"}], ChartLabels -> Automatic] By using Counts instead of Tally, we get an Association that BarChart knows how to handle automatically.


7

This is a good candidate for NestList e = 0.05; f = 0; g = 1; n = 100; ListLinePlot[ Transpose@Most@NestList[{First@# + e Last@#, Last@# - e First@#} &, {f, g}, n], DataRange -> {e, e*n}, PlotLegends -> {"f", "g"}]


7

Your problem is similar to a wave spectra problem and a regression problem, and I have both types of problems going on at work right now which is why I've thought about your problem a bit. Here is an approach with bootstrapping. I used FourierDCT because I don't want to figure out the circular statistics of complex numbers... bootStrapUDList[listFuncHead_,...


7

PossibleZeroQ is rather fast and does precisely what you're looking for: RepeatedTiming[PossibleZeroQ[a - b]] {3.2*10^-6, True} @JM's difficult case is handled correctly: PossibleZeroQ[Sin[2017 2^(1/5)] - (-1)] False The limits of PossibleZeroQ can be fine-tuned with $MaxExtraPrecision.


6

"Memoize" your recursion (if you search the docs for "recursion", you'll see a hit for Functions That Remember Values They Have Found. Read it if the concept is new to you. ) (*Euler's Method*) Timing[ a = 15; h1 = 2./(a); f1[t_, x_] := 2 x - 2 t^2 - 3; t1[k_] := t1[k - 1] + h1; y1[k_] := y1[k - 1] + h1*f1[t1[k - 1], y1[k - 1]]; t1[0] = 0; y1[0] = 2; ...


6

As L.S. said, using MMA like C is a path to poor performance. Based on the OP content, I took the liberty of assuming you want the Mean of remaining tuple values appended to the first: d = {{1, 2}, {1, 3}, {3, 4}, {5, 1}, {6, 9}, {6, 8}, {6, 1}}; Map[{#[[1, 1]], Mean[#[[All, 2]]]} &, GatherBy[d, First]] test = RandomInteger[{1, 20}, {100000, 2}]; Map[{...


6

Answering my own question from a while ago. Turns out the easiest method is using MMA’s built-in Computer Arithmetic package << ComputerArithmetic` (*Set Math Parameters*) SetArithmetic[6, 10, ExponentRange -> {-20, 20}]; fpConvert[x_, integerbits_, fractionbits_] := ComputerNumber[IntegerPart[x] + Round[FractionalPart[x], 2^-fractionbits]]; ...


6

As J. M. already suggested, this is a machine precision issue. So let us do your computation with arbitrary precision numbers. For doing so, all machine numbers have to be replaced with arbitrary precision numbers, otherwise the computation falls back to machine numbers. In the following command I have done this by placing `30 after each machine number. ...


6

This should get you started. First the basic definitions to keep this self contained. F1[a1_, b1_, b2_, c2_] = -(41/4) + Cos[a1] (10 + 3 Cos[b1]) - Cos[b2] (4 + (7 Cos[c2])/2) + 1/4 (50 - 10 Cos[a1] - 3 Cos[a1] Cos[b1] - 10 Sin[a1] - 3 Cos[b1] Sin[a1] - 3 Sin[b1]) + 1/16 (-159 + 16 Cos[b2] + 14 Cos[b2] Cos[c2] + 16 Sin[b2] + 14 Cos[...


6

Read any basic article or chapter about rounding error. When substituting back, the computation that occurs is subtraction $10^{-15}$ (with 16 significant figures, hence 31 correct digits in the fractional part) from something very similarly. At the end you still have about 31 correct digits in the fractional part, which is why you are not able to obtain $...


6

Because there are no elements in your matrix. So there is no element which is not numeric and real. MatrixQ[{{}, {}}, False &] returns True too. So you have to exclude that case: MatrixQ[##, NumericQ[#] && MatchQ[#, _Real] &] && !MatrixQ[##, False &] &


6

I think, the answer to your question is a straight forward one. You wanted to plot the solutions of your system, which can be done like this, {c1sol, c2sol, c3sol} = DSolveValue[{I c1'[t] == c2[t] + .125 c3[t], I c2'[t] == c1[t] + c3[t], I c3'[t] == .125 c1[t] + c2[t], c1[0] == 1, c2[0] == 0, c3[0] == 0}, {c1[t], c2[t], c3[t]}, t]; Plot[...


Only top voted, non community-wiki answers of a minimum length are eligible