Tag Info

Hot answers tagged

18

We can take advantage of the fact that IntegerDigits is very fast when the base is large. But not too large: no bigger than $2^{63}-1$ on a 64-bit system or $2^{31}-1$ on a 32-bit one, because Mathematica's machine integers are signed. Additionally, non-power-of-two bases require more work to get the result than just partitioning a bit-string, and are ...


13

Starting with a corrected version of your ProbabilityDistribution f[a_, b_, g_, c_, k_] := ProbabilityDistribution[ a b c k x^(c - 1) (1 + x^c)^(k - 1) ((1 + x^c)^k - 1)^(-b - 1) (1 + g ((1 + x^c)^k - 1)^-b)^(-(a/g) - 1), {x, 0, Infinity}, Assumptions -> a > 0 && b > 0 && g > 0 && c > 0 && k > ...


9

Welcome in the amazing world of machine precision arithmetic! If you examine the binary representation of both numbers you see the following: RealDigits[1.2, 2] (* {{1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1}, 1} *) RealDigits[.2, 2] ...


8

Cases[Quiet@{#, Abs[Subtract @@ (x /. NSolve[Sin[x] == # && -Pi <= x <= Pi, x, WorkingPrecision -> 20])]} & /@ Range[-1, 1, 2/100], {_Rational, _Real}] // ListPlot Of course you may do Plot[Abs[Subtract @@ (x /. Solve[Sin[x] == y && ...


8

Two problems are involved here. The electric field is ill-behaved at a sharp point, and computational resolution is limited. The first can be seen by plotting the potential, uval, calculated using the code in the Question, for various values of y. Plot[Table[uval[x, y], {y, 0, .2, .02}], {x, -1, 1}, AxesLabel -> {x, u}] Notice the cusp developing ...


7

In version 10.1 the function Subdivide was introduced which does precisely that. Subdivide[10] (* {0, 1/10, 1/5, 3/10, 2/5, 1/2, 3/5, 7/10, 4/5, 9/10, 1} *) Subdivide[10, 5] (* {0, 2, 4, 6, 8, 10} *) Note that the number 5 equals the number of intervals not the amount of entries in the list (which is higher by one).


7

As indicated in the comments, machine-precision linear algebra operations in Mathematica use the Intel MKL library optimized implementation of BLAS/LAPACK. That is the case for all platforms where MKL is available: Windows, Linux and Mac OS X (there will be no obvious MKL library files present in the layout on OS X in 10.1 or later due to static linking). ...


5

I would say your problems are definitely caused by using machine precision arithmetic. Let's look at your computation with more tractable invariants. Machine precision computing invar1 = WeierstrassInvariants[{.2, .5 I}] // Chop {5073.57, 69539.7} WeierstrassP[2.01, invar1] 10000. + 0. I WeierstrassP[2.01 + 2. I, invar1] 10000. - ...


4

Further edited to simplify results It is not difficult to show that the three eigenvalues, w, of M are equal if and only if M is diagonal; i.e., ab = ac = bc = 0. f[e_] := 2 Norm[e]^-3 (1 - 3 Sin[θ]^2 Cos[ϕ - ArcTan[e[[1]], e[[2]]]]^2) Cos[{x, y}.e] abeval = f[{1, 0}] (* 2 Cos[x] (1 - 3 Cos[ϕ]^2 Sin[θ]^2) *) aceval = f[{0, 1}] (* 2 Cos[y] (1 - 3 Sin[θ]^2 ...


3

Sjoerd C. de Vries correctly diagnoses the problem and provides a resolution. An alternative is to work in exact numbers and convert to floating point at the end. Floor[Range[1, 2, 1/10], 2/10] (* Output: {1, 1, 6/5, 6/5, 7/5, 7/5, 8/5, 8/5, 9/5, 9/5, 2} *) N[Floor[Range[1, 2, 1/10], 2/10]] (* Output: {1., 1., 1.2, 1.2, 1.4, 1.4, 1.6, 1.6, 1.8, 1.8, 2.} ...


3

Starting with bbgodfrey's excellent suggestion to solve ab == ac == bc == 0, we can obtain a fairly compact list of all of the solutions. If we Reduce the equations with conditions on the variables we get a complicated result, so it's easier to Reduce first and apply conditions after: Reduce the equations and throw out some obviously inconsistent results: ...


3

Fractional Iterates A way to obtain an approximate fractional iterate of a function is to use its Carleman matrix, which is formed from its Taylor coefficients, and then taking the appropriate $p$-th power of the matrix to obtain the series coefficients. Note that I never said that $p$ had to be an integer; in the example given in the OP, then, we can take ...


3

This is an incomplete answer, but we will be able to show that there is no solution for most values of θ and ϕ. We will also be able to draw a plot of the regions of interest that you should check further to find solutions, should they exist. M = {{s - w, ab, ac}, {ab, s - w, bc}, {ac, bc, s - w}}; {d, c, b, a} = CoefficientList[Det[M], w]; disc = ...


2

As noted in the comments, there are three main errors: k and k[x, y] are not the same thing in Mathematica. Piecewise should be capitalized. NDSolve returns a list of "rules" for the various solutions of the equations, which need to be "applied" (using /.) to be plotted. Alternately, if you know that there's only going to be one solution of the equations, ...


2

There may infinitely many solutions. This will find some, if you limit the range on k: Block[{θ = π/18, l1 = 0.167, l2 = 0.078596}, NSolve[θ == ArcTan[(1/Sqrt[k] Sin[Sqrt[k] l1] + l2 Cos[Sqrt[k] l1])/(-l2 Sqrt[k] Sin[Sqrt[k] l1] + Cos[Sqrt[k] l1])] && 0 < k < 10000, k] ] Solve::ratnz: Solve was unable to solve ...


2

You can get the set, these are ordered pairs, as you describe $(y,|x_2-x_1|)$ with the code: Table[{y, Abs[Differences[ x /. NSolve[Rationalize[Sin[x] == y] && -Pi <= x <= Pi, x, WorkingPrecision -> 20]]][[1]]}, {y, -.99, .99, .01}] The only problem is that over this interval, there is only one solution at $y=\pm 1$. You see I have ...


1

Apparently, for certain values of v, (the automatic method/options of) NMaximize fail(s) because the objective function becomes too complicated. In addition, your constraints are not set properly. For example, you allow $a_1$ and $a_3$ to be equal to $0$ even though they appear as part of denominators. (The outliers seem to be generated with NMaximize ...


1

For a numerical approximation you may try something like: M = {{s, ab, ac}, {ab, s, bc}, {ac, bc, s}}; disc = Discriminant[CharacteristicPolynomial[M, x], x] // FullSimplify f[e_] := 2 Norm[e]^-3 (1 - 3 Sin[θ]^2 Cos[φ - ArcTan[e[[1]], e[[2]]]]^2) Cos[{x, y}.e]; ab = f[{1, 0}]; ac = f[{0, 1}]; bc = f[{1, 1}] + f[{-1, 1}]; s = f[{2, 0}] + f[{0, 2}]; ...


1

We have the known result (see e.g. Abramowitz and Stegun) $$P_{2n}(0)=\left(-\frac14\right)^n\binom{2n}{n}$$ Substituting this result into your sum (while also exploiting the oddness of the odd-order Legendre polynomials) yields $$\sum_{k=0}^\infty\frac{2k+1}{2k+2}\binom{2k}{k}^2\left(\frac1{16}\right)^k$$ which Mathematica says is divergent, and that is ...


1

The complex results seem to stem from a peculiarity of Mathematica's implementation of EllipticTheta[] and/or Derivative[]. To demonstrate this, let's define the derivative with respect to the third argument: ϑ2p[q_] := Derivative[0, 0, 1][EllipticTheta][2, 0, q] Now an innocent question: what is the numerical value of ϑ2p[1/20]? Let's try: N[ϑ2p[1/20]] ...



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