Tag Info

New answers tagged


Vladimir, there is one simple solution: lst = Table[{a, NIntegrate[BesselJ[0, x - a] BesselJ[0,x + a], {x, -\[Infinity], \[Infinity]}, PrecisionGoal -> 5, Compiled -> True]}, {a, 0.84, 0.85, 0.0001}] This visualizes the result: ListPlot[lst, Frame -> True, FrameLabel -> {Style["a", 16], Style["Integral", 16]}, GridLines -> ...


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


If you want to evaluate ChebyshevT polynomials accurately you can consider using the Chebyshev recurrence, using memoization. T[0,x_]:=1; T[1,x_]:=x; T[n_,x_]:= T[n,x]=2*x*T[n-1,x]-T[n-2,x]; This should be fast and stable. If you are doing a lot of these, rearranging the computation working from the low index upward would make memoization unnecessary. ...


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


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


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


You can increase "the precision used in internal computations" with the option WorkingPrecision. This should by default also increase the AccuracyGoal and the PrecisionGoal. Using an other Method could potentially also help.


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`}]] ...


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


t0 = t /. First@N@Solve[{Evaluate[z[t] /. ls0] == 0}, t] 104.606 z[t0] /. ls0 {-7.25357*10^-13} x'[t0] /. ls0 {-26.3732}


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


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

Top 50 recent answers are included