New answers tagged

2

As others have said, the issue with NSolve is loss of precision. By the way, well done for at least back-substituting your answer to test it -- good idea! You can get a correct answer with pencil and paper, and this is a good skill to practise. Let x = (t/5e6). Divide everything by 3.33333e-15 and rearrange: exp(-x) = 1 - 1e-107/3.33333. Now it should ...


1

Timing results in Mathematica 10.1.0 under Windows 7 x64: {0.0660777, Null} {0.0303608, Null} {0.190943, Null} {1.46382, Null} {1.41635, Null} {0.183233, Null} So I confirm MatrixExp[s1, v] and MatrixExp[s1, v, Method -> "Krylov"] as being slower on my system. ( Use this Community Wiki to share any other timing results of interest. )


11

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] + ...


15

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


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


8

Given $d\in\mathbb{N}_0$, the Taylor series about $i/2^d$ is a polynomial of degree at most $d$ for all $i\in\mathbb{Z}$. Let $S_d$ be the set of such Taylor series. There exist unique polynomials $pol_0,pol_1,\ ...\ ,pol_d$ of degree $0,1,\ ...\ ,d$ and a function $c:\mathbb{N}\times\mathbb{R}\mapsto\{-1,0,1\}$ such that for all $x\in\mathbb{R}$, the ...


1

The difficulty of doing numerical calculation with the 4th power as opposed to the square is immense. This easily demonstrated by doing a couple of exact computations. With[{x = (12/10)*10^15}, Exp[-((x - (121/100)*10^15)^2/(2*10^25))]] 1/E^5 With[{x = (12/10)*10^15}, Exp[-((x - (121/100)*10^15)^4/(2*10^25))]] 1/E^500000000000000000000000000 ...


3

Try changing the method of summation: Clear["Global`*"] β = 1; d = 12; V = 1/4; Σf = 1 + I; ω[m_] := ((2*m + 1)*π) ν[n_] := (2*n*π)/β F1[n_] := NSum[(V^2*8)/ d^2*(I*ω[m] - I*Sign[ω[m]]* Sqrt[(ω[m])^2 + (d/2)^2])*1/(I*ω[m] + I*ν[n] - Σf), {m, -Infinity, Infinity}, Method -> "WynnEpsilon", WorkingPrecision -> 30] 0....


3

In version 10.4.1 the support for complex valued PDEs to be solved via FEM has been improved. So this works in 10.4.1: res = NDEigensystem[-1/2 \[Psi]''[x] + 0.15 I \[Psi]'[x] + 1/2 x^2 \[Psi][x], \[Psi], {x, -15, 15}, 5]; res[[1]] {0.49806057220719635` + 4.192136700091489`*^-15 I, 1.494775497407078` + 7.331246737662917`*^-15 I, 2.688987707562188` +...


4

It's the result of error accumulation of float number: Nest[# + 0.01 &, -1, 100] % == 0 (* 7.5287*10^-16 *) (* False *) There're many ways to fix this, for example, using arbitrary-precision number. In your case a Precision of 1. is enough: 0.01`1 // Precision Nest[# + 0.01`1 &, -1, 100] % == 0 (* 1. *) (* 0.*10^-1 *) (* True *) Or simply use ...


2

I offer the following slightly modified version as a better illustration of the problem: Clear["Global`*"] guess = N[3/2, 300]; iter = 1000; n = Table[j, {j, 0, iter}]; y = Sin[4^n guess]^2; Grid[Transpose[{n, y}], Frame -> All] ListPlot[y] What see from the Grid is that at each iteration the number of residual digits of precision decreases - we have 2 ...


2

The problem is that the first argument in Plot must have a constant form. In your example sometimes 2 solutions are found and sometimes 1 solution only. Hence the form varies between {_,_} and {_}. With the following modification, the form {_,_} occurs Lebesgue almost surely, which suffices: f[x_, a_] := Sin[x] - a g[a_] := NSolve[f[x, a] == 0 && x &...


2

The output means that the result accuracy of the result is around 435. The actual result can be inspect with either InputForm or FullForm. The number you see after the 0``... is the Accuracy of the result. As defined by Mathematica, this means that the computed result is zero with an uncertainty of roughly 10^435. In the example above, the computed ...


0

Adding this as an answer since it's too long for a comment. m_goldberg suggests that all pairs must be compared but that's not the full story, consider In[1]:= a == 2 == 3 (* Expect False *) Out[1]= a == 2 == 3 In[2]:= 2 == 3 == a Out[2]= False Doing some experiments it appears that all pairs of arguments are compared in lexicographic order; if two ...


2

It's all explained in the Documentation Center. Equal Subscript[e, 1] == Subscript[e, 2] == Subscript[e, 3] gives True if all the Subscript[e, i] are equal. LessEqual Subscript[x, 1] <= Subscript[x, 2] <= Subscript[x, 3] yields True if the Subscript[x, i] form a nondecreasing sequence. That is, the three arguments in Equal must be equal ...


3

It happens if there is a diverging term appears in the middle. For your case If we consider FourierTransform[f, x, y, FourierParameters -> {0, -2 Pi}] = [Pi]^(1/4)/ Sqrt@2 (c1 + c2 + c3 + c4) c1 = Cosh[1/2 \[Pi]^2 (-2 y + Sqrt[2/Log[2]])^2] c2 = Cosh[1/2 \[Pi]^2 (2 y + Sqrt[2/Log[2]])^2] c3 = -Sinh[1/2 \[Pi]^2 (-2 y + Sqrt[2/Log[2]])^2] c4 = -Sinh[1/...


3

What happens here is that Association has attribute HoldAllComplete and hence does not evaluate x[1] to a numerical value: Clear[x]; assoc = <|"x" -> x[1]|>; x[1] = 0; assoc <|"x" -> x[1]|> Numerical functions work by assigning values to the variables and then evaluating the objective function, they don't perform replacement like in ...



Top 50 recent answers are included