Tag Info

New answers tagged

1

One can access Reduce through Solve via the Solve option Method -> Reduce. To get this through DSolve, we can use SetOptions. opts = Options[Solve]; SetOptions[Solve, Method -> Reduce]; DSolve[u'[t] == u[t]/(4 + u[t]^2), u[t], t] // FullSimplify SetOptions[Solve, opts]; (* long messy answer that looks quite like rcollyer's and Simon Wood's, ...


0

Well, that was easy: Block[{Simplify = FullSimplify}, DSolve[{x''[t] + x[t]^3 == 0, x'[0] == 0, x[0] == x0}, x[t], t] ] // FullSimplify (* {{x[t] -> x0 JacobiCD[(t x0)/Sqrt[2], -1]}} *) DSolve uses Simplify to check the solution, and Simplify is not up to the task. Perhaps the Method option could be used, but there are no clues to how to use it. ...


1

Higher-order, nonlinear differential equation are usually difficult. We can solve the general equation and try to solve the initial condition for the constants of integration. sol = DSolve[{x''[t] + x[t]^3 == 0}, x, t]; Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution ...


6

Ok, at first you don't solve your equation properly, the grid spacing is not enough for the entire time range. So first increase resolution, e.g.: tmax = 10; mdfun = NDSolveValue[ {D[h[x, t], t] + D[h[x, t]^-1*D[h[x, t], x], x] + D[h[x, t]^3*D[h[x, t], {x, 3}], x] == 0, h[0, t] == h[2 Sqrt[2] \[Pi], t], h[x, 0] == 1 + 1/10*Sin[x/Sqrt[2]]}, h, {x, 0, ...


3

Instead of giving screenshots you should copy your code and paste to this section properly. Ok, now I give a general approach to solve this problem. In[1]:= DSolve[x''[t] + x[t] == 0, x[t], t] Out[1]= {{x[t] -> C[1] Cos[t] + C[2] Sin[t]}} Well, Mathematica does the job well and easy. Your problem shouldn't be that hard. Let's see: In[2]:= eqn = ...


0

This question relates to nonlinear wave steepening and I see now that I did not list everything that was necessary to address the problem. I am also quite certain that I phrased this question poorly on account of my novice-level experience with NDSolve in Mathematica. The question spawned from my attempt to reproduce results from this paper. On the ...


6

It works in V10 with G defined as in the update to the question but not in V9. It works in both versions of Mathematica if G is undefined. So there are two ways to get the solution in V9: 1) Compute the solution with a symbolic G and then define G; 2) Rationalize G, solve, and numericize the result with N: G = (1.86559*10^38 lambda)/(1 + (0.338476 ...


3

If you correct the Syntax from deltaP to deltap[] there is no problem: sol1 = DSolve[(miuP*F*D[deltaP[x], x]) + (Dp* D[deltaP[x], {x, 2}]) + (G*Exp[-alpha*x]) == (deltaP[x]/Tp), deltaP[x], x] (* {{deltaP[x] -> (2*Dp*G* ...) a long Expression, with two constants C[1], C[2] *) Regards, Wolfgang


4

You need the magic of "Pseudospectral": sol = With[{nxy = 250}, NDSolve[gnm, {u, v}, {x, -L, L}, {t, 0, tmax}, Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> nxy, "MinPoints" -> nxy, "DifferenceOrder" -> "Pseudospectral"}}]]; Animate[Plot[Through[{Re, Im}@#] & /@ {u[x, t], ...


6

Referring to your own answer there is a much simpler form that you may use, recalling: Collect[expr, var, h] applies h to the expression that forms the coefficient of each term obtained. sol = x[t] /. s[[1]]; Collect[sol, _C, Simplify] (E^(I t ωd) f0)/(m ω0^2 + I m β ωd - m ωd^2) + E^(-(1/2) t (β + Sqrt[β^2 - 4 ω0^2])) C[1] + E^(1/2 t (-β + ...


1

Instead of nn[z, t /; t <= tmin1] == 0 you should state the boundary condition as nn[z, tmin1] == 0


3

One way to tackle the problem is to recognize that the solution is one giant sum with three terms. You can then convert this sum to a list, simplify the terms individually, and sum all elements of the list back together. sol = x[t] /. s[[1]]; Total[ FullSimplify[ Apply[ List , sol ] ] ] But this "hack" is somewhat unelegant, because it might fail if ...


2

Concerning the follow-up question in a comment: ...just for curiosity, if someone knows how to impose a positive codomain to not yet known function, I would very much like to know. One way is to define the system so that x'[t] is positive whenever x[t] < 0. Then when x[t] reaches 0, it will be stuck at 0, unless x'[t] becomes positive for x[t] > ...


0

I posted the solution I found in another thread (Constraining function found by NDSolve to stay positive) and I am reposting it here for convenience. However, in your particular case the model is not complete and you need to ensure that x'[t] is identically zero when x[t]<0. Here is your model with the necessary completion. The description is below. ...


1

I had a very similar problem for a system of very large number of ODEs and none of the methods proposed above worked. The main reason is that the coefficient If[x[t] >= 0, -10, 0] is a stiff function. Several bad things happen because of that. For stiff system the step size decreases substantially and it may take forever to integrate. The simplest ...


1

I can't tell exactly what the problem is, since as user, do not have access to internal code. But it has to do with the handling of UnitBox in StateResponse. how can one obtain deterministic results The work around is very simple. Make the definition of the UnitBox outside the call with NumericQ argument. Then it works. Like this: f[t_?NumericQ] := ...


4

Manipulate[{sx = NDSolve[{x''[t] + (2 k1)/m (x[t] - a) == 0, x[0] == x0, x'[0] == vx0}, x[t], {t, 0, 10}]; sy = NDSolve[{y''[t] + (2 k2)/m (y[t] - a) == 0, y[0] == y0, y'[0] == vy0}, y[t], {t, 0, 10}]; Graphics[{Disk[{Evaluate[x[t] /. sx][[1]], Evaluate[y[t] /. sy][[1]]}, 0.4]}, PlotRange -> 6] /. t ...


1

I get no errors from your code after correction of \\ to //: ODE = H u2''''[x] == Subscript[p, 0] SpringBC = -H u2''[L] == k u2'[L] {u2} = {u[x]} /. DSolve[{ODE, 0 == u2[0], 0 == u2'[0], 0 == u2[L], SpringBC}, u2, x][[1]] // Simplify H (u2^(4))[x]==Subscript[p, 0] -H (u2^\[Prime]\[Prime])[L]==k (u2^\[Prime])[L] {u[x]} Please clarify your ...


11

Okay, this is a bit of an embarassment. Here is a very small modification of the original code. I simply made explicit option settings, made a denominator to Sin explicitly real, that kind of thing. My tests show the same timing as the original, give or take an iota. ie = 200; ez = ConstantArray[0., {ie + 1}]; hy = ConstantArray[0., {ie}]; fdtd1d = ...


4

It's pretty straightforward to make this work, so I'll just post my interpretation of what you're trying to do. In addition to neglecting to define the velocities and accelerations in terms of the positions, you also had some typos in there (capital XX etc.). There was also a redundant initial condition for XX[td] that I removed. It's important to define the ...


3

You could start with sol = DSolve[{c'[t] == t^2 c[t]^3}, c[t], t] plot = (c[t] /. sol /. C[1] -> #) & /@ Range@3; Plot[plot, {t, -3, -1.}, GridLines -> Automatic] Update To include C[1] = 20 plot = (c[t] /. sol /. C[1] -> #) & /@ {0, 10, 20} // Transpose; Plot[plot, {t, -6, 0}, GridLines -> Automatic, PlotLegends -> {" ...


2

Wolfgang's answer #4, 03.10.14 Reformulation of problem and solution The following brief answer #4 presents finally the complete exact solution of the problem. It is based on all the intermediate results obtained so far, and therefore presents only the final results without derivations. First of all, I have simplified the problem without loss of ...


2

Just to address your question, of what can be done. This: expr1 = MapAt[ Collect[Expand[#], {F[t], F[t]^2, J[t], J[t]^2}] &, (F'[t] == d*(Q[t] - R[t]) /. R[t] -> x*q*A[t]*B[t] + f*M[t]) /. M[t] -> b0 + b1*H[t] /. Q[t] -> (A[t] - 1)*B[t] /. H[t] -> m0 + m1*L[t] - m2*G[t] /. G[t] -> v*F[t] /. {A[t] -> a0 ...


2

I think you are missing a parenthesis. This works: Plot[Evaluate[{X[t], Y[t], Z[t]} /. sol /. {C[1] -> 1}], {t, 0, 50}] If you want a 3D plot you should write: ParametricPlot3D[Evaluate[{X[t], Y[t], Z[t]} /. sol /. {C[1] -> 1}], {t, 0, 50}] Hope this helps


2

Not a complete answer but might give some ideas. As noted, it is impossible to enforce the inequality since it can conflict with the equations. One possibility might be to cap k[t] and force the derivative to vanish when it hits the cap. Below is code that could be used. constraint1 = k'[t] == (inv[t] - 0.04 k[t])* Piecewise[{{1, 5 10^6 - k[t] > ...


1

Yes, make X, Y, and Z functions of t. And use Equal instead of Set or SetDelayed. Example with Z[t] = Exp[t]: Block[{Z = Exp}, DSolve[{X[t] == a + b Y[t], Y'[t] == c + d Z[t]}, {X[t], Y[t]}, t] ] (* {{X[t] -> a + b (d E^t + c t + C[1]), Y[t] -> d E^t + c t + C[1]}} *)


2

For the initial integral, why do you have any reason to believe that there is any sort of closed form? As for the simpler integral, if you do: Assuming[ x > 0 && c > 0 && t > 0, Integrate[BesselJ[0, s], {s, x + c t, x - c t}]] It returns: 1/2 (\[Pi] (-c t + x) BesselJ[1, c t - x] StruveH[0, c t - x] - \[Pi] (c t + x) ...


5

For NDSolve, an InterpolatingFunction might be sufficient. Here are smooth versions of UnitStep and UnitBox, with a smoothing "radius" of epsilon. us[epsilon_] := Interpolation[{{{-epsilon}, 0, 0}, {{epsilon}, 1, 0}}, "ExtrapolationHandler" -> {If[# < -epsilon, 0, 1] &, "WarningMessage" -> False}]; ub[epsilon_] := Interpolation[ ...


2

Wolfgang's answer #3 It seems apropriate to create a new answer because the idea of my second answer is not taken up here. Abstract We present here the complete analytic solution of the problem. First we consider the problem with the sharp step replaced by a smooth one. Then a study of the phase space trajectories of the system will give the key insight ...


3

Edit 2: I think I've figured out how NDSolve constructs the solution, which has been incorporated in the revision below. Introduction The term -beta Sign[y'[x]] is discontinuous when beta != 0, so the IVP is not guaranteed to have a solution. NDSolve does not indicate that, but it is obvious. In such cases NDSolve automatically processes the ...


0

Wolfgang's answer #2 The problem can be solved exactly up to the numerical solution of a goniometric equation (i.e. one involving Sin and Cos) for the zeroes of y'. 1. General theory Indeed, the differential equation is either (letting $beta \to b$) $y'' + y = +b \to y'<0 $ or $y'' + y = -b \to y'>0 $ The solution is of the type $y(x) = U + ...


1

You can do it like this, but your system is Stiff: p[t] = {p1[t], p2[t]}; p'[t] = {p1'[t], p2'[t]}; A[t_] = {{p1[t], 1}, {1, p2[t]}}; NDSolve[Flatten@{Thread[p'[t] == A[t].p[t]], Thread[p[t] == {1, 0}] /. t -> 0}, {p1, p2}, {t, 0, 1}] NDSolve::ndsz: At t == 0.9040861047003397`, step size is effectively zero; singularity or stiff ...


4

Try to solve the problem numerically beta = 0.2; As you have observed, the problem is not solved in symbolic form: Solution = DSolve[{y''[x] == -y[x] - beta*Sign[y'[x]], y[0] == 1, y'[0] == -1}, y[x], x] (* -> DSolve[{(y^\[Prime]\[Prime])[x] == -0.2 Sign[Derivative[1][y][x]] - y[x], y[0] == 1, Derivative[1][y][0] == -1}, y[x], x] *) Now ...


6

Vb3[x_] := If[x < -L, 10^10, If[-0.1*L < x < 0.1*L, U, 0]]; u = NDSolve[{(-hbar^2/(2*me)) f''[x] == (2.40986*^-20 - Vb3[x]) f[x], f[L] == 0, f'[-L] == 0.1}, f, {x, -L, L}, Method -> {"DiscontinuityProcessing" -> False}] Plot[f[k] /. u, {k, -L, L}]


1

I am not an expert on this (solving non-linear odes'). But to put all what I saw here in stead of in comment is easier. Basically, you have a non-linear ode with singularity when y(0)=0 as well due to the initial conditions. You can see this part like this: de = y[x] (2 + y[x]) y''[x] + 2 x y[x] (2 + y[x]) y'[x]/(-1 + x^2) - (1 + 2 y[x]) y'[x]^2 + 4 (1 + ...


0

For 1, the problem is that you want to evaluate the ReplaceAll (/.) but not evaluate Part ([[1, 2]]) until a matrix value of the solution is computed. The evaluation has to be separated. One way is to use With: With[{pfn = P /. First[sol]}, Plot[pfn[t][[1, 2]], {t, 0, tfin}] ] I cannot say whether it is what you expect, obviously. :) For 2, I ...


2

In version 9 you can use Part to access the parts of an InterpolatingFunction: points = {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}; ifun = Interpolation[points] (* InterpolatingFunction[{{0,5}},<>] *) {ifun[[3]], ifun[[4]]} (* {{{0,1,2,3,4,5}},{{0},{1},{3},{4},{3},{0}}} *) You can also access Properties of ifun using (not ifun["Properties"] ...


0

There is this package from MathSource, which contains a number of similar packages. Various packages dealing with Lie groups have also been proposed over the years. Your mileage may vary.


1

On V10.0.1, I get the suggestion to try Method -> {"EquationSimplification" -> "Residual"}, which produces a reasonable result. (On V9.0.1, I get lots of errors, but the OP's original code still produces the same solution as below, apparently.) s = NDSolve[{k^2 (w'[y] - 2 Exp[y] (1 + Log[Exp[y]/R1]) (n - 1) (w[y] + m)/(R1 - (n ...


0

Your problem is that you are using a mix of integers and real-valued parameters, which isn't what NDSolve is really designed to do. When I make e, d and R1 real-valued by adding decimal points, the equations to be solved become: {-1 + 3.7037*10^-8 E^-y (300. - 0.620746 E^y)^3 Derivative[1][w][y] + 3.73457*10^-11 (300. - 0.620746 E^y)^4 Sqrt[ ...



Top 50 recent answers are included