Tag Info

New answers tagged

1

How about this: Clear[x, t, X, Y, X0, δ, ϵ]; With[ {functions = {X, Y}, equilibrium = {X0, 0} }, Normal@Series[ D[X[t, x], t] + D[Y[t, x], x] + X[t, x] D[Y[t, x], x] + X[t, x] Y[t, x] == 0 /. Thread[functions -> Map[Function[{t, x}, #] &, equilibrium + ϵ Through[ ...


1

Beginning with D[X[t, x], t] + D[Y[t, x], t] + X D[Y[t, x], x] + X Y == 0 First replace the derivative by some other function to simplify manipulations. %[[1]] /. Derivative[z1__][z2__][z3__] -> W[{z1}, z2, {z3}] Make the first order substitution. %/. {X -> X0 + d X1, Y -> Y0 + d Y1} Expand the second argument of W. (Depending on the ...


1

Outline As you didn't provide boundary and initial conditions and the function pa'[t] this solution must be generic. Your equation for p[u,t] is linear (I guess pa'(t) means D[p[u,t],u]/.u->a) and can therefore be solved by standard mathematical methods once you provide the boundary and initial conditions. Physically it describes diffusion in a cylinder. A ...


1

A = {{0.1, 0}, {0, 0.1}}; B = {{2, 3}, {-3, 1}}; c = {{0.2, 0.6}, {0.2, 0}}; d = {2, 3}; e = {1, 0}; i = {{1, 0}, {0, 1}}; g[11] = {0, 0}; g[t_] := A.S[t+1].Inverse[i-B.S[t+1]].(B.g[t+1]-d)+A.g[t+1]+e; p[11] = {0, 0}; p[t_] := S[t].X[t] - g[t]; S[11] = {{0, 0}, {0, 0}}; S[t_] := c + A.S[t + 1].Inverse[i - B*S[t + 1]].A ; X[1] = {1, 0}; X[t_] := Inverse[i - ...


1

The value of Abs[ee - e[2]] at each step is not a number but a List containing a number. Your condition Abs[ee - e[2]] < 10^-5 is therefore never True, and Break[] is never evaluated. The problem is solved by simply adding First to make that line: If[First[Abs[ee - e[2]]] < 10^-5, Break[]];


0

This works: f[u_, x_] := D[u, x] + a[x] u By way of explanation, everything is an expression, and there is nothing particularly special about functions. You and I know that this definition doesn't have lot of meaning for objects "u" that aren't functions, but Mathematica doesn't need to know that u is a function.


1

funcs = NDSolveValue[{\[Gamma]'[t] == \[Sigma] - 3/8 a[t]^2 + f/(2 a[t]) Cos[\[Gamma][t]], a'[t] == -\[Mu] a[t] + f/2 Sin[\[Gamma][t]], a[0] == 1, \[Gamma][0] == 0}, {\[Gamma], a}, {t, 0, 30}]; Plot[Evaluate@Through@funcs@t, {t, 0, 30}]


2

As has been observed by Dr. Wolfgang Hintze if a,b and c are constant this coupled system has easily derived analytic solutions. In general, this site strongly encourages you to try to present your attempts and then focused clear guidance can be given. I post this as in this case this does not really require more than 'out of the box' functions. Perhaps it ...


0

I am still not sure of what you want but attempting to be helpful: f[u[x] p_, x] := D[u[x] p, x] + a[x] u[x] p f[z[x] u[x], x] a[x] u[x] z[x] + z[x] Derivative[1][u][x] + u[x] Derivative[1][z][x] Which formats as: $a(x) u(x) z(x)+z(x) u'(x)+u(x) z'(x)$


0

Coincidently, I recently made the following routine for the exact task: Clear[TrigShrink]; TrigShrink[exp_, trgt_, lag_: \[Phi]] := Module[{sign, xExp, xRes, xTrig, cCos, cSin, tan, xlag, clag}, xExp = exp // TrigExpand // Collect[#, {Sin[trgt], Cos[trgt]}] &; xRes = xExp /. {Sin[trgt] -> 0, Cos[trgt] -> 0}; xTrig = xExp - xRes; cCos = ...


0

Not sure this is what you need : A = 1/6; B = -Sqrt[3]/24; ω = 8 Sqrt[3]; r = Sqrt[A^2 + B^2] ClearAll[t]; sol = Solve[ A Cos[ω t] + B Sin[ω t] == r Cos[ω t - ϕ], ϕ]; t = 0; ϕ /. sol[[1]] (* ConditionalExpression[-ArcCos[4/Sqrt[19]] - 2 π C[1], C[1] ∈ Integers] *)


0

On the assumption that you have defined the functions u[x], a[x] and b[x] elsewhere, you can define a function as follows: f[x_] := u'[x] + a[x] u[x] + b[x] However, I recommend you read through the documentation on defining functions.


0

By replacing using the rule: θ[t] -> θe You are replacing all instances of the expression θ[t]. However, the derivative θ''[t] is represented in Mathematica by: Derivative[2][θ][t] (You can see this by using FullForm.) This does not contain θ[t], so no replacement is performed. What you want to do is replace θ with a Function like this: θ -> ...


0

No answer here but only further forward suggestions with my thoughts on the topic. We can start with any contour C but more conveniently consider a loop with known closed form parametrization. Supposing we start with an "ellipse" contour C written on a unit sphere ( defined by achille hui in SE Math in reply to my question or any Monkey saddle variant) with ...


0

I can confirm this problem appears when altering the boundary conditions, but not when altering the initial conditions. Here's an example of the former (the latter case is handled successfully in the documentation): (* setup simple damped wave equation *) diffeq = Derivative[0, 2][u][x, t] + Derivative[0, 1][u][x, t] - Derivative[2, 0][u][x, t] == 0; l ...


1

For example: (*Your matrix*) max = 2 Pi; pot = Table[{{x, y, z}, Sin@x y z } // N, {x, 0, max, max/40}, {y, 0, max, max/20}, {z, 0, max, max/20}]; v = Interpolation@Flatten[pot, 2]; dx[x_, y_, z_] := D[v[r, y, z], r] /. r -> x dy[x_, y_, z_] := D[v[x, r, z], r] /. r -> y dz[x_, y_, z_] := D[v[x, y, r], r] ...


1

You may try to fit a boundary condition, although it won't give you hints about the inner workings: sol = u /. NDSolve[{ D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == Exp[-x^2], Derivative[0, 1][u][t, -1] == 2/E}, u, {t, 0, 2}, {x, -1, 1}][[1]] n = 30; coefs = Table[c[i], {i, n}]; solMy = u /. ...


3

I changed the subscripts to numerated variables - much easier to read IMO. Module[{sold, τ1 = 10, τ2 = 10, plot}, sold = First[ NDSolve[{y1'[t] == lambda - d y1[t] - beta y1[t] y3[t]/(1 + alpha y3[t]), y1[t /; t <= 0] == 1, y2'[t] == beta y1[t - τ1] y3[ t - τ1]/(1 + alpha y3[t - τ1]) - a y2[t] - p y2[t] ...


2

There are a very large number of syntax errors. The most serious relate to use of protected symbols: D, I. This is a correction that should work. Please adjust plot range to your needs: sirds[α_, β_, δ_, μ_] := {S[t], SS[t], i[t], R[t], d[t]} /. First@NDSolve[{S'[t] == -α*S[t]*i[t] - δ*SS[t], i'[t] == α*S[t]*i[t] - β*i[t] - μ*i[t], R'[t] ...


1

The underlying problem is with the step size, which is controlled by various options, including PrecisionGoal (as shown in belisarius's answer. It is also controlled by AccuracyGoal, MaxStepSize, MaxStepFraction and some others. The default setting for MaxStepFraction is 1/10, which is not fine enough to stumble upon a little blip near the initial condition ...


1

According to the documentation for GeneratedParameters: The typical default setting is GeneratedParameters -> C. The setting GeneratedParameters -> f specifies that successive generated parameters should be named f[1], f[2], … In typical cases, the f[i] are used to parameterize families of solutions to equations. The f[i] usually correspond ...


2

a = {{0, 0, 5, 3, 3}, {5, 5, 5, 3, 1}, {0, 3, 0, 3, 10}, {1, 3, 2, 3, 10}, {1, 2, 3, 4, 5}}; vars = {x1@t, x2@t, x3@t, x4@t, x5@t}; normeq = x1[t]^2 + x2[t]^2 + x4[t]^2 == 1; eq = Thread[a.vars == {x1'[t], 0, x3'[t], 0, x5'[t]}]; sol = DSolve[eq, vars, t]; cs = Solve[normeq /. sol, {C[1], C[2], C[3]}]; k = vars /. sol /. cs[[1]] /. C[_] :> 0 // N; ...


2

Use AccuracyGoaland PrecisionGoal fun = ParametricNDSolveValue[{x'[s] == v[s], v'[s] == a[s], a'[s] == a[s] - 2 x[s] E^(-x[s]^2), x[0] == x0, v[0] == v0, a[0] == 0}, {x, v, a}, {s, tmin, 0}, {x0, v0, tmin}, AccuracyGoal -> 10, PrecisionGoal -> 10]; Table[Plot[fun[10, 2, ...


3

As Michel E2 said in his comment, DSolve is not and not be symbolic if you give it expressions containing inexact quantities. So try Clear @ v L = 10; alpha = 2*Pi/L; f[x_] := (alpha^2)*Sin[alpha*x]; sol = DSolve[{-v''[x] == f[x], v[L] == 0, v[0] == 0}, v[x], x]; v[x_] = N[v[x] /. sol[[1]]] Sin[0.628319 x]


1

Here's my interpretation: SeedRandom[0]; matrix = RandomInteger[10, {5, 5}]; zero = {2, 4}; (* equations to set to zero *) eqns = matrix.Array[x[#][t] &, 5] == Array[x[#]'[t] &, {5}] /. x[Alternatives @@ zero]'[t] -> 0; eqns /. x[i_Integer] :> Subscript[x, i] // Thread // MatrixForm {sol0} = DSolve[eqns, Array[x, 5], t]; sol0 // ...


2

With the corrections suggested by Jinxed (with whatever set to 1) plus the additional correction of specifying the range of t (required for a delay differential equation), the code becomes DSolve[{x'[t] == -0.12 x[t] - 0.8*1.77 x[t]/(1 + x[t]^4) E^(-0.1*2.8) (1.6*1.77 1/(1 + x[t - 2.8]^4) + 0.01) x[t - 2.8] - (0.51/61)^-0.001 p[t]/(p[t] + 1) ...


3

s /. Rational[a_, b_] :> With[{z = If[Reduce`FactorialInverse[b] === {}, b, Reduce`FactorialInverse[b]]}, a/HoldForm[Factorial[z]]] Or use Defer in place of HoldForm.


0

s = Series[Sin[x], {x, 0, 10}] // Normal; Replace[s, Times[Rational[s_, z_], p_] :> Times[s/HoldForm[Factorial[#]] &@InverseFunction[Factorial][z], p], Infinity] $x-\frac{x^3}{3!}+\frac{x^5}{5!}-\frac{x^7}{7!}+\frac{x^9}{9!}$


5

s = Series[Sin[x], {x, 0, 15}] // Normal ; s /. Times[_[a_, b_], c_] :>a (c/Inactive[Factorial][InverseFunction[Gamma][b] - 1]) Note: The above method will not work for any function This works for any function: s /. Times[a_, Power[_, b_]] :> (a x^b) (b!)/Inactive[Factorial][b]


0

Although this doesn't quite get the solution in your desired form, it does extract the coefficients in unexpanded factorials. Assuming[n >= 0, SeriesCoefficient[Sin[x], {x, 0, n}]]


2

A quick hack, until something better comes along: s = Series[Sin[x], {x, 0, 14}] getFact[n_] := Module[{z = 2, r}, r = n/z; While[ r != 1, r = r/++z]; z]; s = ReplacePart[s, 3 -> Map[With[{t = Denominator[#]}, If[t == 1, #, With[{z = getFact[t]}, Numerator[#]/HoldForm[Factorial[z]]]]] &, s[[3, All]]]] For expansion around non-zero: s = ...


0

The integral in your differential equation isn't the same as that in the post you linked, it can be easily eliminated if you D your equation: vdh = {x, t} \[Function] 1/(1 + h[x, t]) - h[x, t] + Log[h[x, t]/(1 + h[x, t])] λ = t \[Function] -(1/L) Integrate[vdh[x, t], {x, 0, L}] neqn = D[D[h[x, t], t] == D[h[x, t], {x, 2}] - vdh[x, t] - λ[t], x] Then ...


1

As bbgodfrey mentions you can do the following to solve the equation generally: DSolve[y'[x] == - y[x]^2, y[x], x] Or if you have a boundary condition (in this case I have chosen y=1 at x = 0), you can use DSolve to get the specific solution: DSolve[{y'[x] == - y[x]^2, y[0] == 1}, y[x], x] Hope that helps! Best, Ben


3

Here's one way, using Burgers' equation, to illustrate the general principle. One can use Check to react to any given message. Here we reduce the step size by 1/2. Another factor may be more appropriate in another case. PDE[a_] := {D[u[x, t], t] == a D[u[x, t], x, x] - u[x, t] D[u[x, t], x]}; BC = {u[0, t] == u[1, t], u[x, 0] == Sin[2 Pi x]}; ...


3

The right side of your plot actually needs both solutions. You can get the left side by inspection of your original equation observing that if y[x] is a solution then -y[-x] is also a solution. Show[{ Plot[ Table[ y[x] /. sol[[1]] /. C[1] -> c , {c, -100, 100, 5}] , {x, 0, 4}, PlotRange -> {{-4, 4}, {-4, 4}}, PlotStyle -> Red], ...


1

reg = Reduce[-x^4 + x^2 (x + y)^2 > 0, x]; RegionPlot[reg, {x, -10, 10}, {y, -10, 10}] or ParametricPlot[{x, y}, {x, -10, 10}, {y, -10, 10}, Mesh -> None, RegionFunction -> Function[{x, y}, reg], Axes -> False , PlotPoints -> 100] (* same picture -- almost *)


1

sol = Reduce[-x^4 + x^2 (x + y)^2 > 0, x] (y < 0 && (x < 0 || 0 < x < -(y/2))) || (y > 0 && (-(y/2) < x < 0 || x > 0)) RegionPlot[ImplicitRegion[sol, {x, y}]]


4

Here is another way, which is more straightforward than my other answer. At first, I got stumped by couple of things, including, it turns out, a Bug in ArcLength?, and I didn't have time to explore the issues. Instead of using a "BoundaryMarkerFunction" we can list the markers directly in LineElement[elements, markers]. We can make a fairly general ...


2

Apparently, the Kernel terminates, because it does not like x[1] and x[2] in this context. When I modify the code to sol = NDSolveValue[{0 == H[{x1, x2}, D[U[x1, x2], {{x1, x2}, 1}]], U[0, x2] == 0, U[x1, 0] == 0}, U, {x1, 0, 10}, {x2, 0, 10}] it gives the same warning message, NDSolveValue::ntdvdae: Cannot solve to find an explicit formula for the ...


7

You might create a NearestFunction to help pick the particular boundary you want. You can use it to mark the boundary elements of an ElementMesh (FEM). plot = ParametricPlot[ bezierfunc[ξ, η], {ξ, 0, 1}, {η, 0, 1}]; edges = Map[ First@Cases[ Normal@ParametricPlot[#, {t, 10^-5, 1 - 10^-5}, PlotPoints -> 100], Line[p_] :> p, ...


2

Your "exact" solution and THE exact solution aren't the same. You probably made some mistakes on your calculations, or a rounding error is lurking in there realSol = DSolve[{y''[x] + 43/100 y'[x] + y[x] == 1/10 Cos[2 x], y'[0] == 1, y[0] == 1}, y[x], x] // Simplify // First Now, your solution is within 10^-7 of the exact solution, which ...


0

You can analytically solve that problem by using hypergeometric functions. There is no need to specify a curved region for NDSolve. L = 8; Clear[k, en]; Clear[uall]; solution = DSolve[{-D[uall[x, en, k], x, x] + ((x - k)^2 - en) uall[x, en, k] == 0., uall[0, en, k] == 0, Derivative[1, 0, 0][uall][0, en, k] == 1.}, uall, {x, en, k}]; Eofk1[k_] := en /. ...


1

I corrected several syntax errors by editing your equation (parentheses to brackets, z' to zprime) in your Question, and also manufactured some simple expressions for the four undefined quantities: L = 1; tsteps = 1; f[z_] := 1; g[z_, zprime_] := 1 With these changes, NDSolve runs but, not surprisingly, generates errors: NIntegrate::inumr: The integrand ...


1

This is the right-hand part of your solution (taken from your post above): expr = 2 α β (-((E^((Sqrt[-((-1 + p - α + Sqrt[p^2 + 2 p (-1 + α) + (1 + \ α)^2])/(α β))] ξ)/Sqrt[2]) C[1])/(-1 + p - α + Sqrt[p^2 + 2 p (-1 + α) + (1 + α)^2])) - \ (E^(-((Sqrt[-((-1 + p - α + ...


0

As I mentioned in a Comment, the error is associated with WorkingPrecision. Deleting or setting it to MachinePrecision eliminates the error. However, WhenEvent also is producing errors. I believe that it should be rewritten as WhenEvent[NMaximize[{h[x, y, t]}, {x, y}][[1]] >= p, "StopIntegration"] However, even this does not work, perhaps because ...


1

I'm running V10.0.2 on OS X 10.6.8. Your code works fine of my system. s = NDSolve[{y'''[x] - x y[x] == 0, y[0] == 1, y'[0] == 0, y''[0] == 1}, y, {x, -4, 4}]; Plot[s[[1, 1, 2]][x], {x, -4, 4}]


2

Note: This is for V9. DSolve works in V10 Consider the general solution: sols = DSolve[{y''[t] + w^2*Sin[y[t]] == 0}, y, t] Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >> (* {{y -> Function[{t}, -2 JacobiAmplitude[1/2 Sqrt[(2 w^2 + C[1]) (t + ...



Top 50 recent answers are included