# Tag Info

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

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 (-β + ...

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

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

5

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. So I used Block to replace it with FullSimplify, which will reduce the DE to True ...

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

4

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

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

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

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

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

2

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

2

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

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

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

2

Although replacng Module with Block can deal with this problem, it is fussy and inconvenient. As @J. W. Perry said, the built-in Mathematica function InterpolatingPolynomial OP's solution polyInterpolation[tb_, tf_, θb_, θf_, θbDot1_, θfDot1_, θbDot2_, θfDot2_] := Block[ {InterpolationResult, u, θ, θDot1, θDot2, c0, c1, c2, c3, c4, c5, ...

2

Manipulate[ Plot[y[x] /. sol[n], {x, 0, 2}, Evaluated -> True], {n, 0, 4}, Initialization -> {sol[h_] := Quiet@NDSolve[{y'[x] == y[x]^h, y[0] == 1}, y[x], {x, 0, 2}]}]

2

There are two syntax flaws that I see; one of which should have been addressed by your previous question. First, in this line eqn[i, F] = p[i]'[t] == (i + 1) t p[i][t]; I suspect you intend i and F to be variables. But, as it is, you are making a definition for eqn[i, F], verbatim. To make them amenable to substitution, you need to use patterns, e.g. ...

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

1

With your set of parameters your second equation looks as follows: param = {alphax -> 0.1, alphay -> 0.1, beta -> 0.1, nu -> 0.3, fs -> 10^-6}; eqn2 = (lambda[s])^(-2 nu) Log[lambda[s]] == fs*(alphax Cos[theta[s]] + alphay Sin[theta[s]]) /. param /. {lambda[s] -> λ, theta[s] -> θ} (* Log[λ]/λ^0.6 == (0.1 Cos[θ] + 0.1 ...

1

NDSolve wants a IVP, why not give it one?: bc3 = theta'[0] == slope; thetaSol = ParametricNDSolve[{Eqn1, Eqn2, BC1, bc3} /. param, {theta, lambda}, {s, 0, 1}, slope]; Then what we need to do is just looking for a proper slope that satisfies BC2, which is usually a task for FindRoot, let's have a look at the slope - theta'[1] relation as insurance: ...

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

1

Your code for your model is wrong. As others are saying, your forcing function is $\cos(\omega t)$. Therefore, you simply use NDSolve to obtain solution. eq =theta''[t] + b/(m L0^2) theta'[t] + g/L0 Sin[theta[t]] -T0 Cos[w t]/(m L0^2); ic = {theta'[0] == Pi, theta[0] == 1}; b = 0.22; m = 1; L0 = 1; g = 9.8; w = 1; T0 = 1; sol = First@NDSolve[{eq == 0, ic}, ...

1

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

1

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

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