# Tag Info

## Hot answers tagged differential-equations

7

They are the same answer, as verified below. You can use the Simplify command to simplify things if needed: mma = y[x] /. First@DSolve[y''[x] + 2 y'[x] + 5 y[x] == x Cos[x], y[x], x]; handH = E^(-x)*(C[2] Cos[2 x] + C[1] Sin[2 x]); handP = (1/5 x - 7/50) Cos[x] + (1/10 x - 1/50) Sin[x]; hand = handH + handP; Simplify[mma - hand] and the answer is ...

6

This example works in version 8, but in version 9 it does indeed fail to evaluate. I did a little bit of spelunking to find out why. It turns out that in version 9 this function (as well as related ones) takes a third argument. I believe this third argument is just a symbol that will be used as the head in any messages that might be reported. Maybe this ...

5

As I said in a comment, you have some errors on your constants: ClearAll[t, x, y, z]; parms = {Cd -> .3, Cm -> 1, ωx -> 0, ωy -> 0, ωz -> -1500/60, m -> .142, ρ -> 1.225, A -> Pi .03^2, R -> .03}; term = Sqrt[x'[t]^2 + y'[t]^2 + z'[t]^2]; eq1 = m x''[t] == -(1/2 ρ*A*Cd*x'[t]*term) + (4 π*ρ*R^3*(ωy*z'[t] - ωz*y'[t])); eq2 ...

5

After a change of Variable s[k_]:= s[k]= RSolve[{a[p + m] == ((1 + p) (m + 2 p a[p] + p (-1 + m + p) a[-1 + m + p]))/(m + p) /. m -> k, Sequence @@ Array[a@# == 0 &, k - 1, 0]}, a, p] Which give DifferenceRoot solutions. So: Grid[Table[a[n] /. s[m][[1]], {n, 1, 5}, {m, 1, 5}]] /. C[1] -> 0 Gives the same table as in ...

5

Thanks for all your generous help. The wolfram technical support has just confirmed the issue originates from the first derivative of inverse Fourier transform. Actually D[u[x, t], x] should output InverseFourierTransform[I k U[k, t], k, x] rather than InverseFourierTransform[-I k U[k, t], k, x].

4

At least you can eliminate $p$: continue[{exprs__}, f_] := Append[#, Switch[Head@f , Rule | RuleDelayed, # /. f & , _, f]@Last@#]& @ {exprs} toRHS[term_][lhs_ == rhs_] := lhs - term == rhs + term multiplyBothSidesBy[x_]@e_Equal := # x & /@ e privateDRule = f_'[x_] :> d[f@x]/d[x]; integrateLocally = u_ d[v_] :> d[u v] - v d[u]; ...

4

You could try specifying the event differently (this will trigger when the absolute difference between p1 and p2 is smaller than some value): Ad1=10/1000^2; Ad2=1.5*1000^(-2); Ad3=1.5*1000^(-2); Cd1=0.67; Cd2=0.67; Cd3=0.67; V1=10/1000; V2=10/1000; Rho=875; beta=1000*10^6; ps=100*10^5; Q1=Ad1*Cd1*Sqrt[(2/Rho)*(ps-p1[t])]; ...

4

The problem with WhenEvent has to do with the OP's DE. For an event to be detected, there has to be a point at which the condition is crossed, that is, changes from False for t < t0 to True for t > t0. NDSolve then applies a root-finding algorithm to approximate the value of t0 at which the event occurs. In your DE, the solution p1[t] theoretically ...

4

You can try ParametricNDSolve with parameter a xy = ParametricNDSolve[{y''[t] + 500. y'[t] + 250. y[t] + a*(Cos[500. t] + 2*Cos[1000. t]) == 0, y[0] == 0, y'[0] == 0, 250. y[t] + 500.*y'[t] - 35*Tanh[50. x'[t]] - 333. x'[t] == 0, x[0] == 0}, {x, y}, {t, 0, 0.1}, {a}] And then Plot the solutions Plot[Evaluate[Table[x'[a][t] /. xy, {a, 1, 8, ...

4

Example: ClearAll[t, x, y, z]; parms = {d -> 1, L1 -> 10, a -> 5, b -> 99, c -> 8, m -> 100}; term = Sqrt[x'[t]^2 + y'[t]^2 + z'[t]^2]; eq1 = m x''[t] == d x'[t] term + L1 (a z'[t] - b y'[t]); eq2 = m y''[t] == d y'[t] term + L1 (b z'[t] - c y'[t]); eq3 = m z''[t] == d z'[t] term + L1 (c z'[t] - a y'[t]); ic1 = {x'[0] == 0, x[0] == 1}; ic2 ...

4

Mathematica's answer is called an implicit solution. A simpler form the ODE shows the reason. $$\left( e^{f\left( x\right) }+e^{bf\left( x\right) }\right) f^{\prime }\left( x\right) =1$$ The solution $f\left( x\right)$ of the differential equation is given as a solution using inverse function. The reason is that there is no analytical ...

3

I might be grossly mistaken, but what is preventing you to compute a function of an interpolating function? NDSolve[{x''[t] + .2x'[t] + x[t] == 0, x[0] == 1, x'[0] == .4}, x[t], {t, 0, 10}] InterpolatingFunction[{{0,10}},<>][t] Define your function in this way f[t_] = x[t] /. %[[1]]; Then you can compute functions of it, like it was ...

3

Here is another way to solve this issue. I know, it is written everywhere, but this is a common mistake to think that the orifice equation is Cd * Ad * Sqrt[ 2/Rho * ( ps - p1[t] ) ] and could give complex results ! There is no physics going imaginary in the real world. The equation is just wrong. When the pressure reverse, the flow reverse, at least. ...

3

2 problems: You were comparing, in the WhenEvent, solution, which had complex value at that t, to real numbers. I used Abs. If this does not work for you, you can use Re, but can't compare complex number to real number using >. Second, your system is stiff, need to use StiffnessSwitching to help NDSolve. d1 = 10/1000^2; Ad1 = 10/1000^2; Ad2 = ...

3

If I make an assumption about the value of A, I can get a solution although it's not very pretty. First I solved your ODE with no boundary condition. sol = With[{A = 2}, DSolve[r'[x] == Sqrt[-r[x]^2 - 2*A*r[x]^5 + 3*A^(2/3)*r[x]^4], r[x], x]] Next I extract an expression that can plotted from the result. r[x_] = (sol /. x_C -> 0)[[1, 1, 2]]; ...

3

Borrowing from an example of WhenEvent from the documentation in which a Button is used to stop the integration, I came up with this. ClearAll[ndsolveMemConstrained]; SetAttributes[ndsolveMemConstrained, HoldFirst]; ndsolveMemConstrained::mlim = "Memory used  exceeded limit ."; ndsolveMemConstrained[(nd_: NDSolve | NDSolveValue)[eqns_, rest___], bytes_] ...

2

This is not an analytic solution of the recurrence. I generate a table based on the recurrence relation (if I interpret it correctly). I have change l to m as difficult to discriminate from one. If the values are wrong I have obviously made an error but perhaps can motivate other approaches. f[m_, n_, mat_] := 1/n(1 - m + n) (m + (-1 + n) (-m + n) mat[[m, ...

2

You can use Piecewise function in the definition of DE. So for system at hand the NDSolve command would be xyz = First@ NDSolve[{x''[t] == -2.25 Cos[1.5 t] - x[t] - x'[t], x[0] == 0, x'[0] == 0, y''[t] == -1.125 Cos[1.5 t] - 4 y[t] - y'[t], y[0] == 0, y'[0] == 0, z'[t] == Piecewise[{{x[t] - (1 + y[t]), x[t] > 1 + y[t]}, {0, ...

2

To get the polynomials, assuming (interpolation order == 3): points = {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}; Needs["DifferentialEquationsInterpolatingFunctionAnatomy"] ifun = Interpolation[points] coords = First[InterpolatingFunctionCoordinates[ifun]]; vals = InterpolatingFunctionValuesOnGrid[ifun]; grid = Transpose[{coords, vals}]; partGrid = ...

2

Sjoerd beat me with the comment, but since I worked it out, here is an example of pulling the data out of an interpolating functiom. intf = y /. First@NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}] Show[{ Plot[ intf[x], {x, 0, 30}, PlotStyle -> Red, PlotRange -> All] , ListPlot[ Transpose@{(List @@@ (intf ...

2

As mentioned in my comment, it is possible for the example you have shown to achieve the same thing without a recursion and without even restarting NDSolve. The trick is to introduce a discrete variable which is changed at each event. Here is something that I think does the same thing as your code: cVals = {1, 2, 3}; tstart = 0; xsol = Quiet[NDSolveValue[{ ...

2

This can be done in Mathematica via simple function call. You can put NDSolve into a function can relate its parameter and output. A simple example f[k_?NumericQ]:=Block[{sol}, sol=NDSolve[{y'[x]==-k*y[x]+3,y[0]==1},y,{x,0,30}]; ((y[30]/30)/.sol)[[1]] ] Then plot it in a regular way: Plot[f[k], {k, 0.1, 0.7}] The result is here ...

2

I think if you look at λ, λ', λ'' space, you can see that the solution when yp = 2 goes off to infinity. Somewhere in 1.95 < yp < 2, there is a point where the integral curve transitions from being closed to going off to infinity. Integral curves are plotted for yp = 1., 1.95, 2. (blue, green, red, resp.). The other lines indicate the flow of the DE ...

2

Using FunctionExpand as suggested by Vladimir can improve the simplification, but for some inputs FunctionExpand is very slow in this case MeijerG is the one causing problems. By replacing all occurances of MeijerG with a temporary symbol it is possible to get improved results quicker: safeApply[f_, expr_, bad_List] := Module[{ badOnes = ...

2

I would just notice that $$\frac{d}{dx}(k_0 (\frac{T[x]}{T_0})^n \frac{dT[x]}{dx})=k_0/T_0^n \frac{1}{n+1}\frac{d}{d x^2} T[x]^{n+1}$$ and therefore I'd solve it as below : (* Solve the differential equation and rename the integration constants *) aux = (Tnp1 /. First@DSolve[k0/T0^n 1/(n+1) Derivative[2][Tnp1][x] == 0, Tnp1, x]) /. {C[1] -> a, C[2] ...

1

Needs@"DifferentialEquationsInterpolatingFunctionAnatomy"; if = y /. First@NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}] dataY = InterpolatingFunctionValuesOnGrid@if; dataX = Flatten@InterpolatingFunctionGrid@if; { ListPlot@Transpose@{dataX, dataY}, ListPlot@Transpose@{dataX, dataY^3} } InterpolatingFunction[{{0., 30.}}, ...

1

You can't get an exact solution with Mathematica, but you may approximate it, for example with polynomials: s = NDSolve[{y'''[x] + y[x]^2 y''[x] - y'[x] == 0, y[0] == 0, y'[0] == 0, y''[1]== 1}, y, {x, 0, 1}]; data = Table[{x, y[x] /. s[[1]]}, {x, 0, 1, .01}]; Manipulate[ Column[{#, Show[ListPlot@data, Plot[#, {x, 0, 1}, PlotStyle -> {Thick, Red}], ...

1

Ok, so this is my attempt at a short discussion and solution (after getting a little bit wiser). Due to these equations being stiff (Wikipedia) as pointed out by @Nasser, certain numerical methods have difficulty at tracking the solution, and thus, approximations of the orifice equations yield complex solutions at some point when p1[t]>ps and/or ...

1

You will have to solve this equation using NDSolve and the several plot functions in Mathematica can take care of the visualization. Here is a sample code: Let me put some number for the parameters in the equation: A = 10; B = 5; R = 2; \[Omega] = 2; Using NDSolve to find the numeric solution, which is a interpolation object in Mathematica: sol = ...

1

My Solution: Firsty,I give a numer to variable A,A=2

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