Tag Info

Hot answers tagged

14

When you work with machine numbers the precision depends on the order of summation. The built-in functions Plus and Total are more intelligent then straightforward summation. It can be shown by the following example x = RandomInteger[{-100, 100}, {10000}]/RandomInteger[{1, 100}, {10000}]; res = Accumulate[x]; nx = N[x]; s[n_] := Sum[nx[[k]], {k, 1, n}]; ...


6

This (or an appropriately written variant) works: myRegionMember[a_, b_] := With[{threshold = 10^-6}, If[ RegionDistance[a, b] < threshold, True, False ] ]


5

Use AbsoluteTime :- DateObject[Min[Map[AbsoluteTime, DateRange[DateObject[{2000, 1, 1}], DateObject[{2014, 10, 1}], "Month"]]]]


4

The magical words are Singular Value Decomposition. The singular vectors corresponding to small singular values form the kernel. Of course, Singular Value Decomposition is available in Mathematica as SingularValueDecomposition[]. As confirmed by Daniel Lichtblau, the built-in Tolerance option to NullSpace[] does it this exact way.


4

You mean like this? Reduce[x^4 == 1 - I, x] // N x==-1.06955+0.212748 I||x==-0.212748-1.06955 I||x==0.212748+1.06955 I||x==1.06955-0.212748 I


3

These sums are conditionally convergent, so you have to specify a summation order that suits your purpose. See Wikipedia. Since the question seems to be focused on the issue of dropping a term in a sum, here is one way of doing it, without making any claim that the resulting sum is of any use: Chop[NSum[ If[i == j == k == 0, 0, (-1)^(i + j + ...


2

Here is a case where you should take a close look at the magniture of your quantities and do some manipulation to normalize things before throwing the system at the computer: Zl = 2.05*10^-15 \[Alpha] = 1.6381 \[Rho] = 0.326*10^-10 k = 8.9875517873681764*10^9 e = 1.602176565*10^\[Minus]19 divide both of your expressions by ( \[Rho] e ) : ...


2

The code NSolve[Rationalize[f1[x] == f2[x], 0], x, Reals], 100] yields three solutions (with or without N), which is the minimum number of solutions if Zl ρ is positive. The following, which sets the precision of the input to match the working precision, NSolve[SetPrecision[f1[x] == f2[x], 100], x, Reals, WorkingPrecision -> 100] also yields three ...


2

There were a couple issues. First, your definitions of tPx were done using :=, and they contained an integral. Ordinarily this is not a problem, but if tPx is used in NIntegrate (or any other function which calls it repeatedly!), then the kernel will symbolically evaluate the integral tPx at every datapoint in the integration, which is a recipe for ...


2

f1 = RegionDistance[#, #2] < #3]& f1[Line[{{0, 0}, {1, 10.^-7}}], {.5, 0}, 10^-6] (* True *) f2 = Chop[RegionDistance[#, #2] ,#3] == 0& f2[Line[{{0, 0}, {1, 10.^-7}}], {.5, 0}, 10^-6] (* True *)


1

This is the most efficient I can think of: With[{vars = (δA | δB | δC)}, expr /. {x: vars * y: vars -> 0, vars^n_ /; n>1 -> 0}]


1

There's Internal`$EqualTolerance. See How to make the computer consider two numbers equal up to a certain precision and its reference. Block[{Internal`$EqualTolerance = 9.}, RegionMember[Line[{{0, 0}, {1, 10.^-7}}], {.5, 0}] ] (* True *) It's a relative tolerance, whereas gpap's & kguler's answers give absolute ones. The setting above, which is ...


1

Here is my first pass at implementing what you describe. If you find that it deviates from your intended behavior let me know and I shall attempt to refine it. MakeBoxes[foo_, form_] /; format`hex =!= True := Block[{format`hex = True}, ToBoxes[foo, form] /. s_String?DigitQ :> With[{n = FromDigits@s}, InterpretationBox[StyleBox[#, RGBColor[1, ...



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