# Tag Info

## Hot answers tagged numerics

8

Try WolframAlpha guess[x_]:=WolframAlpha["identify "<>ToString@x]

8

You can use FEMAddOns to join two boundary meshes and create an ElementMesh. The following will issue a warning that seems to be safely ignored. (*Uncommented the following function if FEMAddOns not installed*) (*ResourceFunction["FEMAddOnsInstall"][]*) Needs["FEMAddOns"]; ℛ = ParametricRegion[(4 + 1/2*Cos[t] + 3/2*Cos[2*t]) {Cos[t], ...

7

We can use FEM to discretize region and DiscretizeRegion[] as well Needs["NDSolveFEM"] tocartesian = {t -> ArcTan[y, x], r -> Sqrt[x^2 + y^2]}; guitarregion = ImplicitRegion[ 1 <= r <= (4 + 1/2*Cos[t] + 3/2*Cos[2*t]) /. tocartesian // Simplify, {x, y}]; mesh = ToElementMesh[guitarregion, MaxCellMeasure -> .01] {mesh[&...

5

AskConstants is extremely powerful. For the second example it gives several results: (-1 + Sqrt[2]) \[Pi] \[Pi] Tanh[ArcCosh[3]/4] \[Pi] Sqrt[ModularLambda[I Sqrt[2]]] (1 + Sqrt[2]) \[Pi] Sqrt[ModularLambda[2 I]] 1/2 \[Pi] Tanh[ArcCoth[2 + Sqrt[2]] + ArcCsch[1]]

4

The error FEMStiffnessElements operator failure comes up when K is not defined properly. The first application example from the DiffusionPDETerm model = DiffusionPDETerm[{u[x], {x}}, {{If[x <= 3/4, 1, 2]}}] It's impossible to be more specific unless you provide your specific equation and code that you have.

3

sol = x /. Solve[36 Cos[(3 x)/4] Cos[(27 x)/20] (Cos[(3 x)/5] + 2 Cos[(21 x)/10]) == 0&& 0 < x < 4 Pi] Plot[36 Cos[(3 x)/4] Cos[(27 x)/20] (Cos[(3 x)/5] + 2 Cos[(21 x)/10]), {x, 0, 4 Pi}, Epilog -> {Red, Point[Transpose[{sol, ConstantArray[0, Length@sol]}]]}] If you desire only roots that are rational multiples of Pi, you can ...

3

In this case it really helps to use an explicit formula for $U(2,b,z)$, which can be expressed in terms of the much more stable exponential integral function: U2[b_, z_] = HypergeometricU[2, b, z] // FullSimplify (* (1 - E^z (2 - b + z) ExpIntegralE[2 - b, z])/(-2 + b) *) U2[-97., 177.] (* 0.0000130837 *) Such transformations exist very often ...

3

$Version (* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *) Clear["Global*"] HypergeometricU[2., -97., 177.] (* -1.18092*10^64 *) Any calculation done with machine precision is done with the understanding that "you get what you get." Machine precision is fast but neither tracks nor attempts to control precision. ... 3 The above expression for EisensteinE[2, q] is a bit slow. Here is a faster version using double precision arithmetic: EisensteinE[2, tau_Complex /; Im[tau] > 0] := ee2Upper[tau]; ee2Upper = Compile[ {{tauIn, _Complex}}, Block[{tau = tauIn, f, k, q, qp, s}, tau -= Round[Re[tau]]; If[7 Im[tau] < 6, f = ee2Upper[-1/... 3 Mathematica doesn't know LogLogas function. Try gstarELogLog =Interpolation[Map[Log, Transpose[{T, ge}]], InterpolationOrder -> 1] gstarE[T_] := Exp[gstarELogLog[Log[T]]] // Quiet; The equation gstarE[Tpt] == 10 has no real positive solution,because gstarE[Tpt]>10 . Try instead FindRoot[gstarE[Tpt] == 12 , {Tpt, 1/10, 10^-5 , 1} ] (*{Tpt -> 0.... 2 The computation in the question can be performed by using a higher WorkingPrecison, which in turn requires rationalizing all decimals and employing the option, Method -> "StiffnessSwitching", to avoid the inexplicable NDSolveValue::nderr (Error test failure). rate[x_] := Rationalize[(0.28*(12 + 6*x + x^2))/x^5, 0] hubble[x_] := Rationalize[1.73*^... 2 Here a version whithout multiple redefinitions of fraction[]: rate[x_] := ( 28/100*(12 + 6*x + x^2))/x^5 hubble[x_] := hub equation :=Derivative[1][fraction][ x] == (rate[x]/(x*hubble[x]))*((1 - fraction[x])/E^x - fraction[x]); initialConditions := fraction[0.12] == 46/100 fractionN =ParametricNDSolveValue[{equation, initialConditions}, fraction , {x, 0.3, ... 2 Yeah, well, bug or not here is a workaround. Take the logarithm base 10 of the values, then no matter how small or large they are, you can still plot them. For example, consider this plot with some really huge values, circa$10^{1500}$, co-plotted, with some incredibly small ones$10^{-1500}$. Only problem is when the numbers are negative, but even those can ... 2 Some comments: (1) When you pass a function to a plotting routine, in general the routine will use a significant number of points for the plot, perhaps many more than you want so I just set up a table of 12 zz points below, (2) Next, your integration as it stands is a bit troublesome so I included "Method->LocalAdaptive" which significantly ... 2 You can use a different representation of the skew harmonic numbers in terms of harmonic numbers: $$\bar{H}_n=\frac{1}{2} (-1)^n \left(H_{\frac{n-1}{2}}-H_{\frac{n}{2}}\right)+\log (2)$$ This expression can be expanded around infinity f[n_] := HarmonicNumber[(n - 1)/2] - HarmonicNumber[n/2] Series[f[n], {n, Infinity, 6}]$\$-\frac{1}{n}+\frac{1}{2 n^2}-\...

2

All of the integrals can be integrated symbolically in one dimension. The one-dimensional integrals can be integrated completely and the two-dimensional integrals can be reduce to one-dimensional numerical integrals. u0[p_, al_] := (1 - E^((-al)*p))/1; K1[y_, al_] := E^(al*(-1 + y))*(Gamma[0, -al] - Gamma[0, al*(-1 + y)]) - Log[1 - y]; nIntegrate[args___]...

2

This might be considered a bug, but the behavior of NIntegrate follows the "GlobalAdaptive" strategy. The integral, in fact, exposes a weakness in the strategy. With the exact form with (0 - x)^2, NIntegrate takes advantage of the symmetry to multiply the integrand by 2 and integrate over {0, Infinity}. With the inexact form with (0.0 - x)^2, ...

2

Seems that the default error estimation of NDSolve doesn't work well for your initial value problem (IVP), and this turns out to be a (relatively) rare case that AccuracyGoal option helps. With f = 0.01: s1 = NDSolve[{A2[t] == 0, C1[t] == 0, P1[t] == 0, α[0] == -110, α'[0] == Sqrt[A1[0]], ψ[0] == ((Ω^4 Sin[(5*10^-4)/f])/(3 g λ Sqrt[A1[0]]))^(...

1

Clear["Global`*"] Functions should use explicit arguments for all variables. g[bi_, β_] := (β*BesselJ[1, β]) - (bi*BesselJ[0, β]); A function that uses a numeric technique (e.g., NSolve) should use SetDelayed rather than Set and have its arguments restricted to numeric values. EDIT: Used Rationalize on argument and used Solve rather than NSolve ...

1

Update 1: I made a mistake in my function sum of original post: I had coded (f1f2)-f3-f3 when it should have been (f1f2)-f3-f4. Made the correction below and still plotting a discontinuity. Please feel free to remove upvote or I'll remove it in a bit. Update 2: Since f3[x] is causing the problem I tried separating this double integral into two integral ...

1

With differences of numbers of the order of E^3000 you are in danger to overshoot machine precision. You can see this e.g.: f[a_, b_, A_, m1_, x_] := Sum[2^(3 + 4 m) (1/a + 1/b)^(-2 (1 + m)) Gamma[ 2 + 2 m] Hypergeometric1F1[2 (1 + m), 1/2, -((a b x^2)/(A^2 (a + b)))], {m, 0, m1}]; q = f[2, 3, 2, 3, x]; f[2, 3, 2, 3, 100] == q /. x -> 100 ...

1

Use Element[{x, y}, Rectangle[{0, -200}, {5, 200}]]

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