# Tag Info

1

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

1

This is not an answer. I am just providing a (hopefully) fixed version of the input: DSolve[{ 3 E^(-λ2 φ0) r a[r] - 1/2 λ1 φ[r] + 3/8 E^(-λ2 φ0) λ1 φ[r] - 1/2 λ2 φ[r] + 3/2 E^(-λ2 φ0) r^2 a'[r] - 2 b'[r] + 3/2 E^(-λ2 φ0) b'[r] - r λ2 φ'[r] + r^2 Derivative[3][b][r] == 0, -((6 b[r])/r^2) - (3 λ1 φ[r])/(8 r) + (E^(λ2 φ0) ...

0

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

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

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

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

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

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

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

0

To complete my first comment (Hey, I've been scolded by the system because it was too long) I suggest to use a shooting (or balistic) method: instead of using mixed boundary conditions (at x=0 and x=l), specify the values of T and T' at the same extreme of the x interval, leaving the one that did not appear in the original problem as a parameter a to be ...

0

The problem is that your BC's are not linear. So Mathematica can't solve for C[1] and C[2]. May be if you use numerical values for some of the parameters, then they can be solved. You can solve leaving the IC's out and get a solution with C[1] and C[2] later as follows ClearAll[x, n, k0, T, q, len] f[x_, n_] := k0 (T[x]/T0)^n T'[x] T[x_] = T[x] /. ...

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

3

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

0

If $z^n$ means $\frac{\partial ^n\text{}}{\partial t^n}$, then you can do like this: eq = 3 (z + 4)/(z^2 + 2 z + 5)//Simplify; lhs = Total@MapIndexed[#1 D[y[t], {t, #2[[1]] - 1}] &, CoefficientList[Denominator[eq], z]] // Simplify; rhs = Total@MapIndexed[#1 D[u[t], {t, #2[[1]] - 1}] &, CoefficientList[Numerator[eq], z]] // Simplify; ...

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

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

0

Here is a method I found for a different problen which could probably be adapted to your problem. {fit, steps} = Reap[TimeConstrained[ FindFit[ztp, {convolutionModel, k > 1 && r0 > 0 && r1 > 0}, convolutionParameters, t, Method -> Automatic, StepMonitor :> Sow[{r0, r1, k}]], 10]]; You should be able to change ...

0

zeta1 = x[t] + I y[t]; eqn1 = (I/zeta1 + 1/Im[zeta1])/(8 Pi Conjugate[zeta1]); s = NDSolve[{x'[t] == Re[eqn1], y'[t] == -Im[eqn1],x[0] == y[0] == 1}, {x, y}, {t, 0, 10}]; Grid[{Plot[# /. s, {t, 0, 10}, Evaluated -> True, PlotLabel -> ##], ParametricPlot[# /. s, {t, 0, 10}, Evaluated -> True, PlotLabel -> ##]} & /@ ...

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

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

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

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

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

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

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

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

Are you not satisfied with difference root objects? I think that @belisarius has given the most general solution. If you want to give your sequence values and see how it behaves there's no reason to use RSolve. You can define the n-th term recursively and build the sequence from the bottom up (in what follows, I changed l to q): ClearAll[a, g, data, data2, ...

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

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

0

The differential equation has constraints on real solutions and the initial condition of r[0]==0 is problematic. Insights can be obtained by the following: Checking when derivative has real values: w[a_] := N@Reduce[-y^2 + 3 a^(2/3) y^4 - 2 a y^5 >= 0, y] Plotting the function: Manipulate[Plot[Sqrt[-y^2 + 3 a^(2/3) y^4 - 2 a y^5], {y, -2, 2}], {a, ...

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

1

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

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

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

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

1

Is the solution supposed to be something like this? Hopefully I did not break too many things. You should know if the solution looks right or not. Clear[y, x, t]; eqs = y''[t] + 500 y'[t] + 100 y[t] == -33 Cos[500 t] - 66 Cos[1000 t]; ic = {y[0] == 0, y'[0] == 0}; sol1 = First@NDSolve[{eqs, ic},{y[t], y'[t]}, {t, 0, 30},Method -> "StiffnessSwitching"]; ...

Top 50 recent answers are included