Tag Info

New answers tagged

1

You need to specify numeric values for the parameters U, R, c (normally one avoids starting names with capital letters in Mathematica). Since you did not, I made them up. As for the principal problem, one approach is to use the DiscreteVariables option to switch between your differential equation and the equation uc'[t] == 0. U = R = c = 1; uf[t_] := ...


0

Your syntax c[x > 0, 0] is not valid, try this: Diff = D[c[x, t], t] - D[c[x, t], {x, 2}] == 0; ic = {c[x, 0] == If[x != 0, 0, 1], c[0, t] == 1, Derivative[1, 0][c][1, t] == 0}; s1 = NDSolve[{Diff, ic}, {c[x, t]}, {x, 0, 1}, {t, 0, 1}]; You get a solution, however note that B.C. is ill conditioned in that the soluion must go sharply from ...


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


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


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]


0

The main ingredient that makes a differential equation into an eigenvalue problem is the specification of the boundary conditions. This crucial information is missing in the question, so I can only speculate on some ways to simplify the problem. You can turn this differential equation into a second order equation by Fourier transformation using my answer to ...


0

eqn = ψ'''[x] + (1 - 4 x^2) ψ'[x] - 6 x ψ[x] == E ψ[x]; sol[x_] = ψ[x] /. DSolve[eqn, ψ[x], x][[1]]; Manipulate[ psi[x_] = sol[x] /. {C[1] -> c1, C[2] -> c2, C[3] -> c3}; Plot[{ Tooltip[psi[x], ψ[x]], Tooltip[psi'[x], ψ'[x]]}, {x, -1, 1}, Frame -> True, Axes -> False, PlotLegends -> {ψ[x], ψ'[x]}], {{c1, 1, ψ[0]}, -5, ...


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


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


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


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


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


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


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


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


1

Beware of "formal power series" of this type. I have an example of a very competent mathematics professional that led him into ?? land. Concerning your question let's look at the condition $a_0=0\cdot a_{-1} $ which is off the end but doesn't matter because it sets $a_0 = 0$ But by recursion this sets all $a_x = 0 $ So the relation can only be ...


1

Nothing much to add here...this is just a slight modification to István's answer where the call to Needs has been removed in favour of Mr. Wizard's undocumented trick. The calling syntax is slightly different, and I also call DeleteDuplitacesBy to avoid the Interpolation warning about multiple points at a single coordinate. ...


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


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


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}


1

Replacing your last three lines by: eqn1[w_, Te_, Pprobe_, t_] := Cv*Te'[t] == (Cv - y[Te[t], w])*5 y[Te[t], w]*Pprobe eqn2 = eqn1[3*10^9, Te, 10^-15, t] sol = NDSolve[{eqn2, Te[0] == 0}, Te[t], {t, 0, 10}] Plot[Evaluate[Te[t] /. sol], {t, 0, 10}, PlotRange -> All] gives: My machine doesn't return a result for the DSolve[] after a few seconds, so I ...


0

The problem is that you use $Te$ as a variable and as a function in the same time this cause that it appears without argument in the differential equation.


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


1

For illustrative purposes and modify as desired: rate limits,starting populationm carrying capacity etc: f[a_, k_, r_, n0_] := First@NDSolve[{y'[t] == r y[t] (1 - y[t]/k) (y[t]/a - 1), y[0] == n0}, y[t], {t, 0, 10}] Manipulate[ Column[{Plot[Evaluate[y[t] /. f[a, 1, rate, pop0]], {t, 0, 10}, PlotRange -> {0, 1}, Frame -> True, ...


0

mat = {{0, 1, 0}, {0, -1, 1}, {2, 0, -4}}; xm = {x[t], y[t], z[t]}; sol = First[ DSolve[{D[xm, t] == mat.xm, (xm /. t -> 0) == {5, 0, 5/2}}, xm, t]]; Plot[Evaluate[{x[t], y[t], z[t]} /. sol], {t, 0, 5}, PlotLegends -> xm, Frame -> True] yields:


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]


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


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


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


1

This seems to work for me: thisstep = 0; laststep = 0; 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 + y[t] + x1[t]^2 y[t]^2 + 0.5` y[t]^3, x1[0] == 1, x2[0] == 1, y[0] == 1}; {tmin, tmax} = {-1,1}; First@NDSolve[eqn, {x1[t], x2[t], y[t]}, {t, tmin, tmax}, MaxStepFraction -> 1/150, ...


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


1

It seems like nobody has an answer for this, and unfortunately the best answer I can give is that it is a mystery of the internal workings of DSolve. Some of these functions and their methods are not necessarily well-documented (at least, not the internals) to the public. Maybe there is info out there explaining this error, but I can't find it. If I had 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 ...


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


1

Try this: ySol = NDSolveValue[{y''[t] == -9.81, y[0] == 5, y'[0] == 0, WhenEvent[y[t] == 0, {tMax = t, "StopIntegration"}]}, y, {t, 0, 10}]; Plot[ySol[x], {x, 0, tMax}] And in tMax you'll get 1.00964, that's slightly larger than t when y[t] = 0.


0

I think I don't quite understand your question. I will make some assumptions about your question: You want to solve a set of differential equations for different functions xy[i, j][t], where i and j runs in some range (like {i, 1, 4} and {j, 1, 3} leading to 12 different functions). Every differential equation for a given function xy[i, j][t] is in the form ...


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


0

I believe that you have to split the derivative into two parts (real + imaginary) and then make the corresponding contour plots like this z[x_, y_] := Abs[((1/3 x + I y) - 2 x)/(I y + 1/x)]; dx[x_, y_] := D[z[x, y], x] real = Re[ComplexExpand[dx[x, y]]]; img = Im[ComplexExpand[dx[x, y]]]; ContourPlot[real, {x, -2, 2}, {y, -2, 2}, PlotPoints -> 50] ...


0

LSODE stands for the Livermore Solver for Ordinary Differential Equations. It has a long history, and since the 1980's it has been part of a solver collection ODEPACK. LSODA is a variant of LSODE that tries to automatically switch between stiff and non-stiff solution methods. A pdf manual is also available.


1

Clear[koff]; koff = 5.*10^-5; Clear[kon]; kon = 1.*10^4; Clear[koff2]; koff2 = 1.*10^-5; Clear[kon2]; kon2 = 1.*10^4; Clear[kcg]; kcg = 1.2*10^-5; Clear[ndsolKRH]; ndsolKRH = NDSolve[{ D[ag[t], t] == -kon2*ag[t]*b[t] + koff2*cg[t] - kcg ag[t], D[a[t], t] == -kon*a[t]*b[t] + koff*c[t], D[cg[t], t] == kon2*ag[t]*b[t] - koff2*cg[t], ...


2

Assuming that I interpreted the input correctly, koff = 5. 10^-5; kon = 1. 10^4; koff2 = 1. 10^-5; kon2 = 1. 10^4; kcg = 1.2 10^-5; ndsolKRH = NDSolve[{ ag'[t] == -kon2*ag[t]*b[t] + koff2*cg[t] - kcg ag[t], a'[t] == -kon*a[t]*b[t] + koff*c[t], cg'[t] == kon2*ag[t]*b[t] - koff2*cg[t], c'[t] == kon*a[t]*b[t] - koff*c[t], b'[t] == ...


46

OK, there is good news and there is bad news. In the current version 10 there is no way to do this directly. That's the bad news. The good news is that finite element framework used within NDSolve is exposed and documented; for maximum "hackability" convenience. Let's start with a region that @MarkMcClure would consider interesting. We load our favorite ...


29

I've encapsulated the code of the mysterious user21 into a helmholzSolve command. The code is at the end of this post. It adds very little to user21's code but it does allow us to examine multiple examples quite easily, though it has certainly not been tested extensively and could be improved quite a lot I'm sure. It should be called as follows: ...


0

I don't see any negative X[t] when I NDSolve this. When I Plot[X[t]/.Modelo,{t,0,400}], it LOOKS negative, but that's because Mathematica set the y-axis range from 0.15 to 1.4. If you try a PlotRange->{0,All} in there, it looks better. Maybe this is it?


3

One problem is that the equations evaluate to ones with inconsistent dimensions, because Plus threads the components of the constant vector/list term with the unevaluated Dot product. Since NDSolve is not HoldAll or HoldFirst, what the equation evaluates to is relevant. (V9.0.1 actually issues a warning about inconsistent dimensions). {x'[t] == 0. {{0}, ...


3

This has been addressed before and up to Mathematica 9 (I only have 10 at work at the moment and it's a hassle to switch computers) you couldn't handle symbolic, non-explicit matrices in the generic way you want to. I suggest that if you are happy with the answer to that post you delete this as duplicate or if you are using mathematica 10 (which is ...



Top 50 recent answers are included