# Tag Info

9

Here is what I think the issue is: Let's look at what NDSolve parses. Needs["NDSolveFEM"] {state} = NDSolveProcessEquations[{op == 0, bc}, u, {x, y} \[Element] reg, Method -> {"FiniteElement", "MeshOptions" -> {MaxCellMeasure -> 0.005}}]; femData = state["FiniteElementData"]; femData["PDECoefficientData"]["All"] {{{{0}}, {{{{0}, ...

8

The problem - Genericity of soutions The problem we encounter here is that DSolve can return only a general solution however that general solution cannot satisfy such an initial condition as y'[0] == 1. The issue is related to an arbitrary choice of constants of integration i.e. such constants that are specific to certain types of a differential equations ...

7

Your ODE $$u''(x)+\frac{1}{A} u(x) = 0$$ with constant coefficients has the characteristic polynomial $$p(\lambda)=\lambda^2 + \frac{1}{A} \stackrel{!}{=} 0$$ with the corresponding zeros $\lambda_{1/2} = \pm \frac{i}{\sqrt{A}}$. The general (real) solution can be written as $$u(x) = U_1 \sin{\frac{x}{\sqrt{A}}} + U_2 \cos{\frac{x}{\sqrt{A}}}$$. Your ...

6

With eqn[{k_, r_, H0_, P0_}] := {H'[t] == r (1 - H[t]/k) - d H[t] P[t], P'[t] == -s P[t] + e H[t] P[t], H[0] == H0, P[0] == P0} d = 0.01; s = 0.3; e = 0.02; I would define one simulation as sim := Module[ {k = RandomVariate[NormalDistribution[150, 20]], r = RandomVariate[NormalDistribution[0.4, 0.003]], H0 = RandomVariate[UniformDistribution[{50, ...

5

Use the method option Method -> {"IndexReduction" -> {Automatic, "ConstraintMethod" -> "Projection"}} This forces the equations to be incorporated as constraints. See tutorial/NDSolveDAE#128085219. Depending on the version, you might need to us Rationalize to make the coefficients exact to avoid 1/0 errors. (In general, I avoid machine ...

5

You can use ParametricNDSolve to implement a shooting method. Define a finite version of "infinity". inf = 5; Define the differential equation and its initial conditions, parameterised by the initial gradient y'[0] == dy0. For simplicity, I set y[0] == 1. deqn = {y''[x] - x y[x] == 0, y[0] == 1, y'[0] == dy0}; Compute the numerical solution ...

5

As @b.gatessucks said in the comments, there are two issues with your code. First, you'll need to define z as a function with SetDelayed, and also add in ComplexExpand: z[x_, y_] := ComplexExpand @ Abs[((1/3 x + I y) - 2 x)/(I y + 1/x)]; z[x,y] Sqrt[(25 x^2)/9 + y^2] / Sqrt[x^-2 + y^2] Additionally, ContourPlot holds its arguments (i.e. it doesn't ...

5

You can use Method -> "FiniteElement" such as: h = 10.6; F = 0.001; d = 1.0; L = 100*d; phi[x_] := Piecewise[{{0.5*(1 - Tanh[x]), x < L*0.5/d}, {0.5*(1 + Tanh[x - L/d]), x > L*0.5/d}}] s = NDSolveValue[{u''[x] == (h)*phi[x]*phi[x]*u[x] - F*d*d*(1 - phi[x]), u[-2.5] == 0.0, u[L + 2.5] == 0.0}, u, {x, -2.5, L + 2.5}, Method -> ...

4

This ODE system can't be solved symbolically with the given information. First let's define the differential equations: dg1 = y1'[t] == -k1 y1[t] - k2 y1[t] dg2 = y2'[t] == k2 y1[t] - k3 y2[t] dg3 = y3'[t] == k1 y1[t] + k3 y2[t] - k4 y3[t] dg4 = y4'[t] == k4 y3[t] - k5 y2[t] y4[t] + k6 y5[t] dg5 = y5'[t] == k5 y2[t] y4[t] - k6 y5[t] Now the first three ...

4

NDSolve has already detected the largest such intervals for you, which is why the resulting InterpolatingFunctions have restricted domains. You can use InterpolatingFunctionDomain to extract those domains. I'd do something like so Clear[x1, x2, y] eqn = {x1'[t] == -x1[t]^2 - x2[t] + y[t]^3, x2'[t] == x1[t] - x2[t] + x1[t]^2 x2[t]^2, y'[t] == x2[t]^2 ...

4

eqn1[w_, x_, y_, z_] := 3 x y'[x] - 2 z^2 + 3 w y[x] == 5 x eqn2 = eqn1[1, x, y, 2] sol = NDSolve[{eqn2, y[1] == 2}, y, {x, 1, 2}] Then, to get x when y[x] is 3: Solve[(y[x] /. sol) == 3, x] {{x -> 1.556466}} OR as suggested by Mr.Wizard, you can use FindRoot FindRoot[(y[x] /. sol) == 3, {x, 1}] {x -> 1.556466}

4

If you replace your input with pdes = { \!$$\*SubscriptBox[\(\[PartialD]$$, $$t$$]$$u[t, x, y]$$\) - Laplacian[u[t, x, y], {x, y}] == 0.6 u[t, x, y] - v[t, x, y] - u[t, x, y]^3, \!$$\*SubscriptBox[\(\[PartialD]$$, $$t$$]$$v[t, x, y]$$\) - Laplacian[v[t, x, y], {x, y}] == 1.5 u[t, x, y] - 2 v[t, x, y] ...

4

From the comments, we can set up the OP's DEs as follows and show they can be solved exactly. First the system is the direct product of two independent systems, so let's separated them. γ = 6; g = -98/10; yIVP = {y''[t] + γ*(y'[t])^2 == g, y[0] == 0, y'[0] == 15/10}; qIVP = {q''[t] == -γ*(q'[t])^2, q[0] == 0, q'[0] == 7}; nysol0 = NDSolve[yIVP, {y}, {t, ...

3

As it is (unspecified k[t], A) NDSolve will not work. However the equations can be handled analytically. After a simple manipulation you can decouple them and get : rawx[t_] = x[t] /. DSolve[{k[t] x'''[t] - k'[t] x''[t] == -k[t]^3 x'[t]}, x[t], t] rawy[t_] = y[t] /. First@DSolve[{D[#, {t, 2}]/k[t] == y'[t]}, y[t], t] & /@ rawx[t] Now you can check ...

3

An extended comment that is too long for the comment section. Amplifying on the comment by Stephen Luttrell: eqn = y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x; The generic solution solnG = DSolve[eqn, y[x], x][[1, 1]] y[x] -> E^x + 1/(-x + C[1]) Verifying that the generic solution satisfies the equation eqn /. NestList[D[#, x] &, solnG, 1] ...

3

Here is a systematic approach to this problem, starting from the Lagrangian: I denote the initial radial distance by r0 = 5. and use this value in writing the initial values for the other variables. The time of the simulation is tmax = 30. Everything starts by defining the radius vector rVec in terms of spherical coordinates. Inserting this into the kinetic ...

3

With the slightly modified input pde1 = 3*D[z[w, x, y], y] == 2 (z[w, x, y] - 1) + (1 - y^2 w) x soln1 = z[w, x, y] /. First@DSolve[pde1, z[w, x, y], {w, x, y}] soln5 = soln1 /. {x -> 0} eqn1 = soln5 == 2.7*soln1 and a replacement of the integration constant ContourPlot[ x /. Solve[eqn1 /. {C[1][w, 0] -> 1, C[1][w, x] -> 1}, x, Method -> ...

3

InterpretationBox holds its arguments (it has HoldAllComplete). You must evaluate ToBoxes[f] outside of this head, easily accomplished with Function as follows: supressVariable[f_Symbol] := f /: MakeBoxes[f[t, x], TraditionalForm] := InterpretationBox[#, f[t, x]] & @ ToBoxes[f]

3

It seems to me that using MakeBoxes in this case is overkill. How about this simpler definition? supressVariable[f_Symbol] := Format[f[t, x], TraditionalForm] := Interpretation[f, f[t, x]] SetAttributes[supressVariable, Listable] supressVariable[{v, ρ, p, f}]; This doesn't encounter the issue you faced, because the symbol f is passed directly to ...

2

Your post indicates that this is a question about differential equations, so I assume you are attempting to plot a slope field of some type for the DE $y'=sin(x-y)$. In that case, you will want to use the second of your two lines of code. The functions VectorPlot, StreamPlot, etc. all expect vector input. The direction field / slope field / whatever at any ...

2

If you do not define all constants Plot cannot produce any points - how woud it know what to compute? Try sol = DSolve[y'[x] == r y[x] (1 - y[x]/k) (y[x]/a - 1), y, x]; Plot[Evaluate[ y[x] /. sol /. {C[1] -> 1, a -> 1, k -> 1/2, r -> 1}], {x, .51, 1}, PlotRange -> All]

2

Another remedy is to take the limit as y'[0] -> 1: sol = DSolve[{y'[x] + 2 E^x y[x] - y[x]^2 == E^(2 x) + E^x, y'[0] == a}, y[x], x]; Limit[y[x] /. sol, a -> 1] (* {E^x, E^x} *)

2

added some numeric interval limits for y Clear@"*" eqn2[w_, x_, y_, z_] := 3*z'[y] == 2 (z[y] - 1) + (1 - y^2 w) x eqn3 = eqn2[1, 1, y, z] sol = NDSolve[{eqn3, z[0] == 1}, z[y], {y, 1, 5} (*added interval*)] Plot[Evaluate[z[y] /. sol], {y, 1, 5}, PlotRange -> All] z3 = z[y] /. sol /. y -> 3

2

To understand what's going on in this problem, note that $$x'' = - (x + y)\\ y'' = -(x+y)$$ Then just define two new variables describing the sum and difference: $$z \equiv x+y\\ r\equiv x-y$$ and calculate their equations of motion by adding and subtracting the first equations: $$z'' = -2 z\\ r'' = 0.$$ This is a decoupled system of equations, and ...

2

You can get a path function directly from the solution of your ODEs. I don't understand your ODE's, so I'm going to work with a much simpler system, which gives the path of particle moving under constant gravity in a vacuum. g = -9.8; numSoln = NDSolve[{ y''[t] == g, q''[t] == 0., y[0] == 0., q[0] == 0, y'[0] == 50., q'[0] == ...

2

The condition x[t] == 0 && p[t] > 0 is not true very often, if at all, for the initial conditions tried in the OP's differential equation. It would not explain why your session would encounter a such a problem. (I haven't gotten such an error in a very long time. I always associated it with a bug. It was often unreproducible. If you can ...

2

There are at least two approaches by which you could obtain a closed form emulation of your answer. Both involve extracting a list of points that are part of the solution. 1. Inexpensive but takes you outside Mathematica. Export the list of points to a CSV file. Obtain (free trial) a program called Eureqa (http://www.nutonian.com/products/eureqa/) that ...

2

The reasons for the change in the behavior of ParallelTable are subtle. The main source of the problem is that in funcB, the argument k_ is not protected with ?NumericQ like this: funcB[t_?NumericQ, k_?NumericQ] := (* a solution *) funcB[t, k] = Exp[NIntegrate[funcA[et, k], {et, tini, t}]] But more on that later. The problem does not appear in the ...

2

There is a problem with boundary conditions. Changing them and fixing a few typos you can get: eq = {-f[x]^2 + f[x]^4 + x^4 Derivative[1][f][x]^2 + (x^3) /(-1 + x) f[x] ((1 - 2 x) f'[x] - (-1 + x) x f''[x]) == 0, f[1/10] == 1, f'[1/10] == -1/10}; eq // Column // TraditionalForm s = NDSolve[eq, f, {x, 1/10, 9/10}]; Plot[Evaluate[f[x] /. ...

2

The linear system is easily solved generally by first calulating the MatrixExp. Then we can extract the real and imaginary parts. Here we go The complex matrix A = {{0, 1}, {-2, -I}}; The matrix exp At = MatrixExp[t A] (* {{1/3 (2 Cos[t] + Cos[2 t] + I (2 Sin[t] - Sin[2 t])), 1/3 (I (-Cos[t] + Cos[2 t]) + Sin[t] + Sin[2 t])}, {1/ 3 (2 I (Cos[t] ...

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