# Tag Info

2

Mathematical overview You seem to be using NDSolve perfectly well, and this differential equation does not seem to pose any special problems for NDSolve. There seems to be two issues raised, the oscillatory solutions and the square root solutions. It is not uncommon for differential equations to have an isolated non-oscillatory solution among oscillatory ...

1

Ok, so as mentioned in the comments, you can go either of two ways. With your definitions (note I omitted tmax): rr = 1; p = 0; x[r_, t_, p_] = r Cos[(2 π)/tmax t + p]; z[r_, t_, p_] = r Sin[(2 π)/tmax t + p]; g[r_, t_, p_] = ((1 + z[r, t, p]) D[x[r, t, p], t] - (I + x[r, t, p]) D[ z[r, t, p], t])/(2 ((1 + z[r, t, p]^2) + (I + x[r, t, p]^2))); b[r_, ...

0

Is this what you want ? Manipulate[ tmax = endpoint; sol1 = NDSolve[{c1'[t] == -g[rr, t, p] Exp[-2 I b[rr, t]] c2[t], c2'[t] == g[rr, t, p] Exp[2 I b[rr, t]] c1[t], c1[0] == 1, c2[0] == 0}, {c1, c2}, {t, 0, tmax}]; sol2 = NDSolve[{c1'[t] == -g[rr, t, p] Exp[-2 I b[rr, t]] c2[t], c2'[t] == g[rr, t, p] Exp[2 I b[rr, t]] c1[t], c1[0] ...

3

Just spelunking a little I got this for the harmonic oscillator problem: eqs = {y[1]'[T] == y[2][T], y[2]'[T] == -y[1][T]}; iniconds = {y[1][0] == 1, y[2][0] == 0}; invariants = {1/2 (y[1][T]^2 + y[2][T]^2)}; vars = {y[1][T], y[2][T]}; system = {eqs, iniconds, vars, {T, 0, 10}, {}, invariants, {}}; erksol = NDSolve[NDSolveProblem@system, Method -> ...

0

You can simply plug the general solution into the boundary condition: pde = D[S[x, y, z], x] + D[S[x, y, z], y] + D[S[x, y, z], z] - A*S[x, y, z] - B == 0 sol = DSolve[pde, S, {x, y, z}]; bc = {S[0, y, z] == 0, S[x, y, 0] == 0, S[x, 0, z] == 0}; bc /. sol {{(-B + A C[1][y, z])/A == 0, (-B + A E^(A x) C[1][-x + y, -x])/A == 0, (-B + A E^(A x) ...

1

As it is already mentioned in the comments, the initial condition Derivative[1, 0][u][0.001, x] == 0, should not appear there. After it removal the equation is solved as expected: eps4 = 0; phi6m4V = NDSolveValue[{D[u[t, x], x, x] - D[u[t, x], t]/ Sqrt[t^2 + x^2] == -6 u[t, x]^5 + (8 + 4 eps4) u[t, x]^3 - (2 + 4 eps4) u[t, x], ...

7

You can use the options VectorScale and VectorStyle of VectorPlot. To create the slope field for the first order equation $y'=f(x,y)$, I usually do something like so. f = Exp[-x] - y; VectorPlot[{1, f}, {x, -2, 2}, {y, -2, 2}, VectorScale -> {0.03, Automatic, None}, VectorStyle -> {Gray, Arrowheads[0]}]

7

Yes, you can simply replace each occurrence of Arrow with Line like this: VectorPlot[{y, -x}, {x, -3, 3}, {y, -3, 3}] /. Arrow -> Line To understand how this works, please read the documentation for ReplaceAll and also take a look at FullForm[VectorPlot[...]]. The point is to see that the plot is just a bunch of graphics directives and therefore we ...

0

I suggest you take a crack at using RecurrenceTable first. But if you want to build up a lot of symbol definitions with recursive calls to T[n,i], you're not far off. The definition for the initial condition should be T[0, _] := 300 This will evaluate for T[0,1], while your definition will not match i to 1. Check out the Introduction to Patterns. For your ...

0

It's usually much better in my experience to scale the variables. You get no underflow this way, and stiffness is partially ameliorated, although if a system is stiff it will probably stay that way. As an example, try to be as a-dimensional as possible. Take some main unit/molecule/entity/whatever magnitude as your reference scale, and then work everything ...

12

While the other answers are nice, the icon deserves a closer look: Note, in particular, that four of the six edges are not constrained by the ostensible Dirichlet boundary conditions, nor is it clear that they solve a Neumann problem. And indeed, as I noted in the comments this is supported by the OP's first link. In short, to produce the logo, they took ...

1

This is the procedure. Just ask if you have questions regarding details. params = {{1, 5, 1, 3}, {2, 3, 2, 2}, {3, 3, 3, 1}} sol = ParametricNDSolve[system, {x, y}, {t, 0, 10}, {a, b, c, d}] Table[ Plot[{(x @@ p)[t], (y @@ p)[t]} /. sol // Evaluate, {t, 0, 10}], {p, params} ] For more examples check here: ParametricNDSolve.

3

It seems you're back =) Well the problem with your code up there is that Mathematica is not expanding "Abs'[x[t]]" as well as you're missing "Needs["VariationalMethods"]". One variant is to "Trick" Mathematica a bit and change the potential energy term in the Lagrangian by writing $\left|x\right|$ as $\sqrt{x^2}$. Using "EulerEquations" you could then do ...

3

You can just solve it like we do by hand. Finding equation of motion from Lagrangian is really only one line: Clear[x, t, n] ke = 0.5*x'[t]^2; pe = Sqrt[x[t]^2]^n; lagrangian = ke - pe; eq = D[D[lagrangian, x'[t]], t] - D[lagrangian, x[t]] == 0; sol[p_] := x[t] /. First@NDSolve[{eq /. n -> p, x[0] == 2, x'[0] == 0}, x, {t, 0, 10}] Plot[Evaluate[sol[2]], ...

5

Not sure if I understand the physics of the problem. But to use the EulerEquations, you need to call the VariationalMethods. Below is my edit of your code: Needs["VariationalMethods"] lim = 6 T = 0.5*x'[t]^2 V = Sqrt[x[t]^2]^n L = T - V eqn[n_] = EulerEquations[L, x[t], t] soln = x[t] /. (First@ NDSolve[{eqn[#], x[0] == 2, x'[0] == 0}, x, {t, 0, 10}] ...

2

No direct way I'm aware of to do this: as far as I know, when the initial NDSolve is evaluated, those options a plugged into an internal slot and can't be tinkered. However, perhaps something like this would serve your purpose: low = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 5}, WorkingPrecision -> $MachinePrecision, ... 7 I agree with Rahul that, since you've got a single, one dimensional equation indexed by a single parameter, a bifurcation diagram is a natural way to visualize this situation. If you want an animation or dynamic image, you might highlight one particular phase line as a function of$a$. You could also display the slope field of the system right along side of ... 3 Since you have just two variables,$x$and$a$, you can make a 2D plot: f[x_, a_] := -x^4 + 5 a x^2 - 4 a^2; Show[StreamPlot[{f[x, a], 0}, {x, -4, 4}, {a, -1, 1}, StreamPoints -> Fine], ContourPlot[f[x, a] == 0, {x, -4, 4}, {a, -1, 1}, ContourStyle -> ColorData[1, 2]]] My explanatory comment below was incorrect, so I'm including a corrected ... 15 Here's my attempt. To get the matrix representing the Laplacian I use LaplacianFilter on an array of symbols and CoefficientArrays to extract the coefficients. n = 200; shape = ArrayPad[ConstantArray[0, {n/2, n/2}], {{0, n/2}, {0, n/2}}, 1]; shapeVector = Flatten @ Position[Flatten @ shape, 1]; symbolArray = Array[x, {n, n}]; symbolLaplacian = ... 11 I had this laying around from a course in numerical linear algebra I taught a few years ago. Here's a matrix whose nonzero elements describe the basic shape. size = 50; nw = Partition[Table[i, {i, 1, size^2}], size]; sw = Partition[Table[i, {i, size^2 + 1, 2*size^2}], size]; se = Partition[Table[i, {i, 2*size^2 + 1, 3*size^2}], size]; L = ... 0 Some remarks: Do not use %-operators successively, as they only work as expected if input/output are in separate cells. You don't have to define A with SetDelayed, as it is constant. Use options for the Plot to set size and padding. Take the first solution (there is only one, but is wrapped in list), and do a multiple replacement for the$c_i\$. Easiest is ...

5

Let' s do this problem using just quaternions. First, let's see how we multiply quaternions together, remember that each component has those "imaginary" objects that multiply in a specific way, this can be replaced by just defining a new quarternion cross product that behaves the same way. We will keep the differential equations real so we ...

4

You have written cosinstead of Cos[], and also forgotten to enclose the objective functions in a list: sol = NDSolve[{l1 (m1 (g*Sin[P[t]] + l1*P''[t]) + m2 (g*Sin[P[t]] + l1*P''[t] + l2 (Sin[P[t] - Q[t]] Q'[t]^2 + Cos[P[t] - Q[t]] Q''[t]))) == 0, l2 m2 (g*Sin[P[t]] + l1 (-Sin[P[t] - Q[t]] P'[t]^2 + Cos[Q[t] - Q[t]] P''[t]) + ...

0

Once the trivial things are fixed -- I borrowed the definition of Pl from the Wolfram Community posting -- the problem is that NDSolve has trouble setting up the initial conditions from r[0] == 0.000025, in particular, I suppose for Pb[0]. The solution is to specify both r[0] and Pb[0]. OP's setup I converted each parameter setting to a Rule, so I could ...

1

If sol = DSolve[..] returns the input, then Head[sol] === DSolve will be True (otherwise, sol would be a list of Rule). For more explanation, this elementary aspect of Mathematica is covered in the tutorials ExpressionsOverview. The test === is covered in SameQ.

8

One can get a hint of the issue by seeing that DSolve[{1/a D[f[a, b], a] == 1, D[f[a, b], b] == 1}, f[a, b], {a, b}] can't be solved, but DSolve[{ D[f[a, b], a] == a, D[f[a, b], b] == 1}, f[a, b], {a, b}] (* {f[a, b] -> a^2/2 + b + C[1]}} *) can. But there are the same system! (multiplying by a both sides of the first equation in the first case ...

2

That means the boundary conditions defined should fit the the range of t and r in NDSolve command. You have 4 values: {t,0,10} and {r,0,100}, so you have to define the conditions at these 4 values. Here you define at r = s = 1 but you run r from 0 to 100. You need to define the boundary condition at r = 0 and at r = 100. But I don't know which boundary ...

Top 50 recent answers are included