Tag Info

Hot answers tagged

15

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


12

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


10

I present in this answer a compiled implementation of one of the simpler algorithms for numerically evaluating a Bessel function of (modestly-sized) integer order and (small to medium-sized) real argument. This uses Miller's algorithm: bessj = With[{bjl = N[Log[1*^16]]}, Compile[{{n, _Integer}, {x, _Real}}, Module[{h, hb, ...


5

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


5

As the old documentation states: $EqualTolerance gives the number of decimal digits by which two numbers can disagree and still be considered equal according to Equal. The default setting is equal to Log[10, 2^7], corresponding to a tolerance of 7 binary digits. On my system $MachinePrecision is ~15.9546 which means there are 53 bits: ...


5

Finding the intersections You can use use Graphics`Mesh`FindIntersections (see Implementation of Balaban's Line intersection algorithm in Mathematica for example) either on the plot or on the points stored in the InterpolatingFunctions in sol: With curvatureConst = -3.5; there are five points of intersection: Here are the two methods: ...


4

For curvatureConst = -2.25 the equations in the Question yield An intersection can be found from First@FindRoot[{(x[t] - x[t2]) /. sol, (y[t] - y[t2]) /. sol}, {{t, 8}, {t2, 10.5}}] (* t -> 7.8869 *) Flatten[{x[t], y[t]} /. sol /. %] (* {-0.0330813, 0.693441} *) Of course, there are multiple intersections, and which is obtained depends on the ...


3

Problem The problem with Log[1. + 1.*^-15] not yielding 1. is not due to Log, but to MachinePrecision inputs, which I think the OP implied in the question statement: 1 + 1.*^-15 % - 1 (* 1. 1.11022*10^-15 *) So Log[1 + 1.*^-15] does return the right answer, 1.11022*10^-15, for the actual input. Solution Here is a simple way to get log1p-type ...


3

Since you are specifically asking about versions below 10, it may be useful to point out that this problem is equivalent to the electrostatics problem of finding the potential in a region bounded by conductors held at fixed voltages. This can be solved, e.g., with the simple relaxation method I implemented in this answer, where I actually allow for lots of ...


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

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


1

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


1

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] ab = f[{1, 0}] (* 2 Cos[x] (1 - 3 Cos[ϕ]^2 Sin[θ]^2) *) ac = f[{0, 1}] (* 2 Cos[y] (1 - 3 Sin[θ]^2 Sin[ϕ]^2) ...


1

If you have v.10 you can explicitly use the finite element method: Needs["NDSolve`FEM`"] mesh = ToElementMesh[Rectangle[{0, 0}, {10, 10}]] sol = First@NDSolveValue[{Laplacian[w[x, y], {x, y}] == 0, DirichletCondition[w[x, y] == 100, y == 0], DirichletCondition[w[x, y] == 400, y == 10], DirichletCondition[w[x, y] == 0, x == 0], ...


1

Here is the method I was alluding to in a comment to DumpsterDoofus's answer: dat = {{0, 0}, {18, 1}, {70, 1/4}, {90, -1}, {110, 2}}; (* DumpsterDoofus's solution *) fd[x_] = Integrate[Interpolation[dat, InterpolationOrder -> 0][x], x]; {xa, ya} = Transpose[dat]; f1 = y /. First[DSolve[{y'[x] == First[ya] + Differences[ya].UnitStep[x - Most[xa]], ...



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