Tag Info

Hot answers tagged

7

Arbitrary and machine precision It is important to understand that there are two different and in some respects separate numeric systems within Mathematica: machine-precision and arbitrary-precision. (I described this in brief here.) Machine-precision numerics are much faster than arbitrary precision numerics, therefore it is normally undesirable to ...


7

The sign of the radial coordinate is of course supposed to be non-negative, and indeed your example shows that the sign flips to a negative value after some time. However, this is an artifact of the special case you considered in the example: the case of zero angular momentum, pPhi = 0. If you give the angular momentum any arbitrarily small non-zero value, ...


5

Define the helper functions and variables like this: F[x_] := {x[[2]] x[[3]], -x[[1]] x[[3]], -0.51 x[[1]] x[[2]]} dt = 0.1; xi = {0, 1, 1}; Do not define xj since you need to use that as a single symbol in FindRoot. Now this equation, xj == xi + dt F[xj] makes sense if we substitute a concrete vector value for xj. If we don't the equation will still ...


4

For the question of "why N function cannot work well", according to the documentation (Examples -> Scope -> Machine and Adaptive Precision): N[e,p] works adaptively using arbitrary-precision numbers when p is not MachinePrecision. Now the RandomReal[ ] function returns exactly MachinePrecision number(s), so I think that's why you can't use N[data, 4] ...


3

Plot[2 x - Sinh[x], {x, -Pi, Pi}] FindRoot[2 x == Sinh[x], {x, #}] & /@ {-2, 0, 2} {{x -> -2.17732}, {x -> 0.}, {x -> 2.17732}}


3

Mathematica 10 introduces Indexed allowing this without error messages: FindMinimum[(Sum[Indexed[a, i]*Cos[1.3], {i, 1, 2}])^2, {a, {2, 0}}] {3.97214*10^-18, {a -> {1., -1.}}}


2

Using Experimental`NumericalFunction framework directly (FindMinimum uses it under the hood) it is straightforward to get the numerical approximation of the Hessian: f = Experimental`CreateNumericalFunction[{x, y}, Cos[x^2 - 3 y] + Sin[x^2 + y^2], {1}, Hessian -> FiniteDifference]; f["Hessian"[{1.376384972443001`, 1.6786760817546214`}]] ...


1

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



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