Community RSS Feed
https://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Numerical Computation sorted by activeAvoid error while using NDSolve on theses differential equations?
https://community.wolfram.com/groups/-/m/t/1612266
Im trying to solve the differential equations and I keep getting the message error "NDSolve called with 2 arguments; 3 or more arguments are expected". My code is
pend[a0, w0, k, l, wd] =
NDSolve[{a'[t] == w[t], w'[t] == -k w[t] - Sin[a[t]] + l Cos[q[t]],
q'[t] == wd, a[0] == a0, w[0] == w0, q[0] == 0}, {a, w, q}, {t, 0,
100}];
Any help with this is greatly appreciated.Paweł Żukowski2019-02-13T19:58:29ZMaximize the solution of an equation containing an integral?
https://community.wolfram.com/groups/-/m/t/1610261
I have to find `{x,y}` which makes the integral
NIntegrate[(1/(E^((x^2 - 2*x*d + d^2 + y^2 )/(2*(d + r^2)))*
(Sqrt[d]*(d + r^2)))), {d, 0, Infinity}]
equal to `Pi^0.5/Ry`. Among all the possible solutions, I am interested in the one which maximises y, with the constraint `y>0`. I have also a good starting point for y. The problem has to be solved for different values of `r`, say from 0 to 20, and `Ry`, say from 10^-7 to 10^7.
I have set the problem in this way:
f2[x_?NumberQ, y_?NumberQ, r_?NumberQ] :=
NIntegrate[(1/(E^((x^2 - 2*x*d + d^2 + y^2 )/(2*(d + r^2)))*
(Sqrt[d]*(d + r^2)))), {d, 0, Infinity}];
solu2 = Table[
FindMaximum[{y, f2[x, y, r] == Sqrt[\[Pi]]/Ry, y > 0}, {x, y}], {r,
ranger}, {Ry, rangeRy}]
Unfortunately, `NIntegrate` fails to converge to the solution for all the values of `r` and Ry.
Any help?umby piscopo2019-02-11T11:24:01ZSolve numerically a diffusion equation with fully reflecting wall?
https://community.wolfram.com/groups/-/m/t/1610358
I am trying to solve numerically the diffusion equation $\partial_t P(x,t)=\partial_x^2 P(x,t)+ \partial_x V'(x)P(x,t)$. I have a potential that diverges at zero: $V(x)=4((1/x^4)-(1/x^2))$, therefore, I want to set a reflecting wall at, say xc=0.5, and solve only for x>xc.
1. In the code below, you will see my unsuccessful attempt in placing thes boundary conditions.
2. Since I found that I cannot use DiracDelta and HeavisideTheta functions to set my initial condition, I use instead $Pinit(x)=\exp(-(x-8)^2)/\sqrt{\pi}$, which has a negligible contribution from x<=0.
3. It seems that even though, mathematically I believe I am setting a reflecting wall condition, which should not allow any flow to the region below x<xc, it seems that numerically this still happens. And eventually it make the end solution u[x,T] not normalized correctly.
How do I achieve my goal above, to solve this equation only on the positive half-plane?
The following code shows a negative part for $u(x,T)$, which should not have existed, and I belive it is responcible for $\int_0^\infty u(x,T)dx\neq1$.
Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"]
V[x] = ((1/x)^4 - (1/x)^2) 4;
F[x] = -4 (-(4/x^5) + 2/x^3)
x0 = 8;
Pinit[x] = Exp[-(x - x0)^2]/(Sqrt[Pi]);
T = 1000;
BoundaryCondition = 50;
mol[n_Integer, o_: "Pseudospectral"] := {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n,
"MinPoints" -> n, "DifferenceOrder" -> o}}
uval = NDSolveValue[{D[u[x, t], t] + D[F[x]*u[x, t], x] -
D[u[x, t], x, x] == 0,
u[x, 0] == Pinit[x], (D[u[x, t], x] /. x -> 0.5) == 0,
u[0.5, t] == 0}, u, {x, 0.5, BoundaryCondition}, {t, 0, T},
Method -> mol[2000, 4]];
Plot[{uval[x, T]}, {x, -5, 5}, PlotRange -> All,
PlotStyle -> {Automatic, {Thick, Dashed}}]Erez A2019-02-11T10:08:16ZAn algorithm on divisibility
https://community.wolfram.com/groups/-/m/t/1608875
I put on your consideration this algorithm to know if an odd number S is divisible by another number (called "primo" here) :
DivisibleQ[S_, primo_ ] (* S is odd and primo>5 *) :=
Module[{factor = ModularInverse[primo - 10, primo] , numero = S},
While[numero > primo,
numero = FromDigits[Most[IntegerDigits[numero]]] - factor * Last[IntegerDigits[numero]]];
If [numero < 0, While[numero < 0, numero = numero + primo],
While[numero > 0, numero = numero - primo]];
If[numero == 0, True, False]]
Very simple, fast, general and economic. I hope you like it. Free to use naming the source; I named it EGP algorithm. I post it here because I want to share it with all the users of Mathematica.
All suggestions are welcome.Eloy Gonzalez2019-02-09T00:15:32Z[✓] Get hexadecimal representation for a float as a string?
https://community.wolfram.com/groups/-/m/t/1606682
Hello
I wonder how I could use Mathematica commands to do the following:
An irrational number, ir, (a huge expression as a result of iterating a discrete map) is converted to single precision (Real16) and then to hexadecimal as a string. Example single(ir)=0.25=3e800000 (using matlab).
I know single precision is not available on WM 11.3 but Real32, Real64 and Real128 are. As for the hexadecimal representation I have to confess that I could not figure out how to do it even considering, for instance, Real32.
Your help is much appreciated.
Many thanks
EdEduardo Mendes2019-02-06T17:34:05ZSolve system of non-linear differential-algebraic equations using NDSolve?
https://community.wolfram.com/groups/-/m/t/1607771
Hello there,
I am trying to solve a system of non-linear differential-algebraic equations using NDSolve, but keep getting the following error :
NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions.
The code looks like following :
Sol = NDSolve[{DGL, (xp[t] /.
t -> 0) == {-0.05, -0.052, -0.054, -0.06, -0.057, 0, 0, 0, 0, 0,
1, 1.5, 2, 1.1, 1.2}, (D[xp[t], t] /. t -> 0) == {0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Table[\[Omega][t][[k]] == Subscript[L, k][t]/M[[k, k]], {k, 1,
Dimensions[AdjazenzMatrix][[1]], 1}]}, xp[t], {t, 0, 100},
MaxSteps -> 100, AccuracyGoal -> 8]
The system of differential-algebraic equations is defined as :
DGL = Chop[
Table[(D[xp[t], t])[[k]] == (JR.DeltaHpNeu [t])[[k]] +
ColG[t][[k]] + (G.up)[[k]], {k, 1,
3*Dimensions[AdjazenzMatrix][[1]], 1}]]
Does the error mean that there exists no solution for the system or is there something wrong with my code?
Thanks a lot!
P.S. - I am attaching the Mathematica source code.Kirtan Bhatt2019-02-07T15:29:06ZGet a numerical solution of an equation containing an integral?
https://community.wolfram.com/groups/-/m/t/1606568
I have the following problem:
given r, I have to find the {x,y} which satisfies:
Integrate[1/(E^((2*x^2-4*x*d+2*d^2+2*y^2)/(8*d+4*r^2))*(Sqrt[d]*(2*d+r^2))),{d,0,Infinity}]==1
however, of all the solutions, I am interested to find the one which has the maximum y.
Unfortunately, the integral can be solved only numerically.
Any help?
Byeumby piscopo2019-02-06T12:33:03Z