Tag Info

New answers tagged

2

I've had difficulty before with UnitBox, although I've forgotten the exact context. UnitStep usually works better. sol = NDSolve[{-u''[x] == UnitStep[x - 0.3] - UnitStep[x - 0.7], u[0] == 0, u'[1] == 0}, u, {x, 0, 1}]; Plot[u[x] /. First[sol], {x, 0, 1}]


3

This is just an extended comment. I'm not quite certain what's going on as we can easily implement a shooting method manually here. (Shooting method, in short: parametrize in terms of u'[0] and very the parameter until u'[1] has the desired value.) fun = ParametricNDSolveValue[{-u''[x] == UnitBox[(x - 0.5) 0.5/0.2], u[0] == 0, u'[0] == ud}, u, {x, 0, 1}, ...


2

What is happening is that the RuleDelayed (:>) keeps the Table from being evaluated. When NDSolve detects an event, it evaluates the appropriate event action. In your code, the "EventAction" option is not (yet) an expression with head List, but an expression with head Table. So instead of picking the corresponding part, NDSolve assumes that the whole ...


9

Here is extensions to @Jens answer (I think) also relying on possible separation of variable. I is not meant as an independent answer, but complements it. First extend his answer to 2D ClearAll[pt, px, x, t, p]; operator = Function[p, D[p, t] - Δ D[p, x, x] - Δ D[p, y, y]]; ansatz = pt[t] px[x] py[y]; pde2 = Expand[Apply[Subtract, ...


13

A first step would be to implement a convenience function that can automatically apply the method of separation of variables to separable types of equations. To show that the steps could in principle be automated, let me repeat basically the same calculation that I did for cylindrical coordinates with only slight modifications to the heat equation: ...


3

Your specific example can be solved by DSolve. First let's get the general solution of the PDE: gsol = DSolve[{D[p[x, y, t], t] == x D[p[x, y, t], x] + (1 - y) D[p[x, y, t], y] + 2 p[x, y, t]}, p, {x, y, t}] {{p -> Function[{x, y, t}, C[1][x (-1 + y), t + Log[x]]/x^2]}} Then substitute it into the boundary condition: eqn = p[x, y, ...


6

I think it's a bug. Tracing Tracing the evaluation of DSolve as the following: eq = D[y[x], x] - y[x]^2 + y[x]*Sin[x] - Cos[x] == 0; traceRes = Trace[DSolve[eq, y[x], x, GeneratedParameters -> ThisIsForGeneralC], {TraceInternal -> True, TraceOff -> _Message}]; and formatting (using the ...


7

This is a bug in DSolve. The solution to your example should certainly include a constant of integration. DSolve attempts to solve this Riccati equation by solving the corresponding second order linear ODE. The problem occurs while using the solution of the second order linear ODE, which has an unevaluated integral in it. Sorry for the confusion and ...


5

Heureka! Symbolic solution with constant of integration found. With a little help for MMA from its friend ... Writing the differential equation as eq = y'[x] - Cos[x] == y[x] (y[x] - Sin[x]); we observe that putting (no MMA code) $$z(t)=y(t)-Sin(t)$$ we obtain a related equation eq1 = z'[t] == z[t] (z[t] + Sin[t]); which surprisingly is DSolved ...


5

The differential operator in the first form can be written as dd1[n_] := (Sum[a[k] D[#, {t, k}], {k, 0, n}]) & and is applied for example as dd1[1][x[t]] a[0] x[t] + a[1] Derivative[1][x][t] and dd1[2] @x[t] a[0] x[t] + a[1] Derivative[1][x][t] + a[2] (x^\[Prime]\[Prime])[t] In the second (product) form we would perhaps try d2[n_] := a[n] ...


2

To illustrate how to get solutions for use: sir[b_, g_, i0_, s0_] := {s[t], i[t], r[t]} /. First@NDSolve[{s'[t] == -b s[t] i[t], i'[t] == b i[t] s[t] - g i[t], r'[t] == g i[t], s[0] == s0, i[0] == i0, r[0] == 1 - s0 - i0}, {s[t], i[t], r[t]}, {t, 0, 20}] Manipulate[ Plot[Evaluate[sir[ir, rr, in, 1 - in]], {t, 0, 20}, PlotLegends -> ...


3

From the textbook solution, you can see/guess that K$15888 is being substituted for y'[x] in order to reconcile the arguments of f and f'. If this seems too wild a guess, you can confirm it with the following: Clear[f, x, y]; kamke = f[x - 3/2*D[y[x], x]^2] + D[y[x], x]^3 - y[x]; Trace[ DSolve[kamke == 0, y[x], x], _Solve, TraceInternal -> True ] ...


0

Are you wanting to do this numerically or is symbolically fine for you? If so how about implicit differentiation: Solve[D[w + 1/(x^2 + y^2) + 1/(x z[w]) == 2y, w], z'[w]] (* {{z'[w] -> x z[w]^2}} *)


4

This may simply be just an error in transcribing desired system for assessment. However, I post this to amplify Gregory Rut's answer for the coded system. Please note: documentation of Poincare section uses well defined non-linear system with specific initial conditons. This is somewhat different to this system and what is being tabulated. I am using the ...


3

It seems that you need to filter your results and select only numbers (some of points were not evaluated correctly) sps = Flatten[Select[ps, NumberQ[#[[1, 1]]] &], 1]; Now the plot should be ok (note that there are very few points, you'd have to increase their number in order to get a better picture). ListLinePlot[#[[FindCurvePath[#][[1]]]] ...


3

This gives the solution to the equation: temp = Solve[eqn[x, y, z], D[y[x, z], x]] This extracts the value of the rule: res = D[y[x, z], x] /. temp This evaluates the result at the requested coordinates: res /. {x -> 1, y -> 1, z -> 1} (* {9} *)


2

Too small to post as comment, as I am not sure about your equations. First, You have few syntax errors. 1) it is I not i, 2) Need space, as in I z and not iz 3) You are solving for y[x,z] and not D[y[x,z],x 4) You are using y[x, z] == 2 but y[x,z] 5) do not know what y=2 is initial conditions mean. You mean y[0,z]=2 or y[x,0]=2? Also, why write g as you ...


1

Try: NDSolveValue[{2 - x*Abs[3/(2 - I z)]*2 x/(1 - 3 D[y[x, z], x]) == 3 y[x, z], y[0, z] == 2}, D[y[x, z], x], {x, 0, 1}, {z, 0, 1}] Initial conditions need to be set at a specific point, the complex is I not i. Then plot the derivative: Plot3D[%, {x, 0, 1}, {z, 0, 1}]


5

I'd like to add to Mark's answer but do not have enough rep to do so in a comment. One can write: Needs["NDSolve`FEM`"] omega = ImplicitRegion[x^6 + y^4 <= 1, {x, y}]; m = ToElementMesh[omega]; uif = NDSolveValue[{Derivative[1, 0, 0][u][t, x, y] == Derivative[0, 0, 2][u][t, x, y] + Derivative[0, 2, 0][u][t, x, y], ...


8

Using V10's new FEM functionality, this problem can be solved as follows << NDSolve`FEM`; omega = ImplicitRegion[x^6 + y^4 <= 1, {x, y}]; mesh = ToElementMesh[omega, "MaxCellMeasure" -> {"Area" -> 0.005, "Length" -> 0.1}]; gamma = DirichletCondition[u[t, x, y] == 0, x^6 + y^4 == 1]; u = NDSolveValue[ {Derivative[1, 0, 0][u][t, x, y] ...


1

Instead of explaining too much, here is some correct MMA-code for your problem. By studying it (and the documentation of MMA) in detail you will discover the answer to your question: In[69]:= Clear[a, y, v, yy, vv, sol] In[70]:= sol = DSolve[{y'[t] == v[t] , v'[t] == -a^2 y[t], y[0] == 0, v[0] == 1}, {y[t], v[t]}, t]; In[71]:= {yy[t_, a_], vv[t_, a_]} ...


1

one way, if I understand you right (even though I think this will be closed :) Clear[v, t, y]; a = 9; eq1 = y'[t] == v[t]; eq2 = v'[t] == -a^2 y[t]; sol = First@DSolve[{eq1, eq2, y[0] == 1, v[0] == 2}, {v[t], y[t]}, t]; ParametricPlot[Evaluate@{v[t] /. sol, y[t] /. sol}, {t, 0, 1}] (as others mentioned, you have lots of syntax errors there)


4

I often do this sort of thing with Dt. It works on equations, too. It basically gives you the multivariate differential $$ {\partial f \over \partial x} \;dx + {\partial f \over \partial y} \;dy + \cdots = 0$$ To get $dy/dx$, set $dx = 1$ and any other differential other than $dy$ equal to zero. Then solve for $dy$ to get $dy = - ({\partial f /\partial ...


2

It maybe done by finding first the total derivative of a function f(x,y,z) f = Sin[y] + y - Sin[1/x] - x z; Dt[f] (*-z Dt[x] + (Cos[1/x] Dt[x])/x^2 + Dt[y] + Cos[y] Dt[y] - x Dt[z]*) then solve fro both Dt[y] and Dt[x] dy = Dt[y] /. Solve[Dt[f] == 0, Dt[y]][[1]]; dx = Dt[x] /. Solve[Dt[f] == 0, Dt[x]][[1]]; f2=dy/dx/. {x -> 3/10, y -> 4/10}; ...


2

Comment: I think you want D instead of Derivative. Also == instead of =. And you probably want the functions defined with patterns z_ etc. But there are errors that you'll have to address. (Or perhaps someone else.) ClearAll[φ, η, r, u]; φ[z_] = q*(1/z + (-1*q)/(-1*z)); η[z_] := k*(1/z + (-1*q)/(-1*z)); r[ρ_, z_] := Sqrt[ρ^2 + z^2]; pde = D[u[t, ρ, z], ...


2

y[x_, z_] := Sin[1/x] - 1/x - z D[y[x, z], x] /. x -> 0.3 Not exactly sure what you wanted to do after that. Update 1 y[x_, z_] := Sin[1/x] - 1/x - x z D[y[x, z], x] /. {x -> 0.3, z -> 1} Update 2 eqn = Sin[y[x, z]] + y[x, z] == Sin[1/x] + x z Solve[ D[eqn, x] /. {x -> 0.3, z -> 0.5, y[x, z] -> 0.4}, D[y[x, z], x] /. {x -> ...


7

The sign of the radial coordinate is of course supposed to be non-negative, and indeed your example shows that the sign flips to a negative value after some time. However, this is an artifact of the special case you considered in the example: the case of zero angular momentum, pPhi = 0. If you give the angular momentum any arbitrarily small non-zero value, ...


1

It seems that you're missing a solution of Ef1. Try y = NDSolve[{eqnBo == 0, Eb1[r, 0] == 0, eqnDe == 0, Ef1[r, 0] == 0, Derivative[1, 0][Ef1][rn, t] == 0, Ef1[ro, t] == eo}, Ef1, {r, rn, ro}, {t, 0, 14400}]; Plot[Ef1[r, 14400] /. y, {r, rn, ro}, PlotRange -> Automatic]


1

I suggest going with the second approach: choose a set of points and follow their trajectories. To solve differential equations numerically, use NDSolve (as a documentation search quickly reveals). To plot a set of points in 2D, use ListPlot. This information, together the the documentation of the mentioned functions and some of the basic tutorials is ...



Top 50 recent answers are included