Tag Info

Hot answers tagged

17

Yes, it can! Unfortunately, not automatically. There are different algorithms to do it (see special literature, e.g. Dziuk, Gerhard, and John E. Hutchinson. A finite element method for the computation of parametric minimal surfaces. Equadiff 8, 49 (1994) [pdf] and references therein). However I'm going to implement the simplest method as possible. Just ...


12

The good news is that yes, there is an easy way to put your problem into NDSolve by using the new finite element functionality in v10. The bad news is that it seems the specific problem you're trying to solve is ill-posed. NDSolve can now handle internal boundaries; see e.g. the first figure under "Details" for DirichletCondition. Generating a mesh with ...


9

The differential equation should reflect the fact that θ ranges between 0 and Pi. Because the spherical coordinate system becomes degenerate at these two pole, Q should be independent of ϕ there. Thus, from the differential equation, Q is time-independent at the poles. Hence, the boundary values of Q at 0 and Pi are the initial values there. Based on ...


7

I've wrapped up @ybeltukov's code into a function that works for an arbitrary MeshRegion surface. First we need to find the boundary vertices, which will remain fixed. If the MeshRegion represents a 2-dimensional manifold with boundary, then every internal vertex has as many edges as it has faces, but every boundary vertex has one extra edge. ...


7

The Finite Element Method seems more stable for this type of problem. e = 2.5; xmax = 5; ymax = 5; sol = First@ NDSolve[{-D[f[x, y], x, x] - D[f[x, y], y, y] + NeumannValue[Cos[\[Pi]/(2 xmax) x], y == -ymax] == e f[x, y], DirichletCondition[f[x, y] == 0, y > -ymax]}, f, {x, -xmax, xmax}, {y, -ymax, ymax}, Method -> {"FiniteElement", ...


5

Your calculation is unstable, because the Courant limit is violated. For a square mesh, it is e > 4 dx^-2. Choosing e=27.5 gives


5

The problem is that NDSolve is using the shooting method and for some of the initial conditions it tests lead to a singularity. Indeed there seems to be a small neighborhood around the desired solution where the integration does not blow up before r == 20. I don't know why previous versions of Mathematica were able to push through and find an adequate ...


5

BVP as opposed to IVP is not relevant to what is going wrong. NDSolve wants initial/boundary conditions to have order strictly less than that of the differential equation. You could work around this by taking another derivative of the DE and also giving another condition say by evaluating the original DE at some point. The given example could be done as ...


4

The periodic driving at one point doesn't seem to be compatible with the boundary conditions expected by NDSolve, so I modified the problem in two ways: first, broaden the point source into a Gaussian, and then incorporate this driving as a source term in the actual differential equation. So we're actually solving the inhomogeneous wave equation here. For ...


4

You can use series solution to find analytical solution, but this will be valid only near the point of expansion (it is Taylor series). This finds such solution and compares it to NDSolve solution. The more terms you use, the more accurate the approximation will be. seriesSol = findSeriesSolution[t, 20]; numericSol = u[t] /. First@NDSolve[{u''[t] + 4 u[t] + ...


4

Curious, but under Mathematica 10, using FiniteElement spatial discretization we get this result NDSolveValue[{x''[t] - x[t] == 0, x''[0] == 0, x[1] == 1}, x, {t, 0, 1}, Method -> "FiniteElement"] Plot[%[x], {x, 0, 1}]


3

eqns = {y'[t] == (t + 1)/(t (t + 4)), y[-1] == 0}; sol = DSolveValue[eqns, y, t] Function[{t}, (1/4)*((-I)*Pi - 3*Log[3] + Log[t] + 3*Log[4 + t])] sol satisfies the differential equation and boundary condition eqns /. y -> sol // Simplify {True, True} So does your formulation sol2 = Function[{t}, 1/4 (Log[-t] + 3 Log[4 + t] - 3 ...


3

[Udpate: simplified DirichletCondition, omitted unnecessary Method specification.] Following the Transient PDE examples in Finite Element Programming, I came up with this: Ω = ImplicitRegion[(x + y <= 10), {{x, 0, 10}, {y, 0, 10}}]; Dif = 0.0000072; eq1 = D[u[t, x, y], t] == Dif*Laplacian[u[t, x, y], {x, y}] - 1.2; sol = NDSolve[{eq1, ...


3

[Edit: Revised explanation, incorporating references to documentation.] The PDE is a quasilinear PDE similar to Burgers' equation, whose solution, also similar to the OP's, is discussed in the tutorial Linear and Quasi-Linear PDEs. A first-order quasilinear PDE $$a\,p_x+b\,p_t=c$$ is linear in the partial derivatives, although the coefficients ...


3

Given that U*V = f[r], one can invert the function f locally about a center, r == center in terms of a power series with Normal @ InverseSeries @ Series[f[r], {r, center, orderOfApproximation}] /. r -> U*V This yields a truncated power series (polynomial) that approximates InverseFunction[f][U*V]. For instance, Block[{α = 0.13, Q = 0.5^2, M = 1, R = ...


3

I'd like to post a LaplaceTransform-based solution: eqn = D[p[x, t], {t, 2}] == c^2*(D[p[x, t], {x, 2}]); bc = {p[x, 0] == Exp[x], D[p[x, t], t] == Sin[x] /. t -> 0}; teqn = LaplaceTransform[eqn, t, s] /. Rule @@@ bc (* Notice that p[x, t] in the following equation implies the Laplace transform of p[x, t] *) tsol = DSolve[teqn /. ...


3

Although Implicit Euler is described in the documentation, it may not be an implemented Method. In fact, the Wolfram discussion of the Lotka–Volterra Equation actually defines Backward or Implicit Euler, suggesting that it is not an implemented Method: BackwardEuler = {"FixedStep", Method -> {"ImplicitRungeKutta", "Coefficients" -> ...


2

Somewhat inspired by bbgodfrey's answer, after rereading the tutorial of "MethodOfLines", I found that a restriction for "MaxPoints" together with "DifferenceOrder" -> 2 solved the problem, no v10-feature is needed!: e = 2.5; xmax = 5; ymax = 5; sol[x_, y_] = f[x, y] /. With[{n = 18}, First@NDSolve[{-D[f[x, y], x, x] - D[f[x, y], y, y] == e f[x, ...


2

This is a so called first order differential equation, in general not solvable via separation of variables. You have to solve the homogenous equation an then determine a specific solution. For more info see Mathworld I forgot to mention that Mathematica (surely) solves this equation: DSolve[u'[x] + u[x]/x == x/s - 1/2, u[x], x]


2

Here is my solution, just change the WhenEvent part to WhenEvent[First@y[t] == 0, y[t] -> {1, Last@y[t]}] sol = NDSolve[{y'[t] == {{.1, -.2}, {-.1, .2}}.y[t], y[0] == {1, 1}, WhenEvent[First@y[t] == 0, y[t] -> {1, Last@y[t]}]}, y, {t, 0, 10}] Plot[Evaluate[y[t] /. sol], {t, 0, 10}] Mathematica gives


2

Define m in one of two ways: Clear[m]; m0 = NDSolveValue[{m[x] == Tanh[x + m[x]], s'[x] == 1, s[-1] == -1}, m, {x, -1, 0}] m[x_] /; x < 0 := m0[x]; m[x_] /; x == 0 := x; m[x_] /; x > 0 := -m0[-x]; or Clear[m, m0]; m[x_?NumericQ] := m0 /. FindRoot[m0 == Tanh[x + m0], {m0, x}]; Then solve the PDE: {sol} = NDSolve[{D[u[x, t], t] + u[x, t] D[u[x, ...


2

Mathematica might need some help with this one. One of the problems is surely that you are asking for y - try first to get a solution for u(x)=y''(x), this makes things a bit easier. You can always integrate twice at the end. In this case, it might be an idea to split up the 'source term' (i.e. the right hand side). As the differential equation is linear, ...


2

If Mathematica can't decide if argument to HeavisideTheta is positive or negative, this remains unevaluated. Type HeavisideTheta[x - L/2] on your computer and see the result. So, the result will contain this even if it can solve it. I think it just can't find a particular solution because of this. One way to help M, is to break it to 2 ODE to avoid the ...


2

In generally, I used the method as below: Plot[Sin[x], {x, -\[Pi], \[Pi]}] Select the output cell -> Save selected as -> sample.pdf \documentclass[b5paper,UTF8]{article} \usepackage{graphicx} \begin{document} \texttt{Plot[Sin[x], {x, -Pi, Pi}]} \vspace{1mm} \fbox{\includegraphics[width=.9\textwidth]{sample.pdf}} ...


2

In general, if you must use NDSolve rather than DSolve to solve your differential equation for a particular value of y[0], then you need to use NDSolve for every value of y[0] in your domain of interest. Hence, you need ParametricNDSolveValue. Here is a demonstration for a simple illustrative equation, the results of which allow an illustration of how you ...


2

The code in the Question can be recast as ω = 1; ϵ = 0.001; Manipulate[fn = With[{T = t}, NDSolveValue[{y''[r] + (4 r^3)/(r^4 - T^4) y'[r] + (ω^2 r^4)/(r^4 - T^4)^2 y[r] == 0, y'[T + ϵ] == -((ω (I T^2 + (T + ϵ) ω))/ (ϵ (T + ϵ) (2 T + ϵ) (T + ϵ - I ω))) y[T + ϵ], y[2] == 1}, y, {r, T + ϵ, 2}]]; Plot[Re[fn[r]], {r, t + ϵ, 2}, PlotRange -> All], ...


2

It's not actually that the bottom plot is incorrect, it's that the horizontal axis is not drawn where you expect it. Consider this simplification, where it is more clear that the position of the horizontal axes are placed differently. Since Show inherits many of the plotting features from the first argument, the order of the plots matters in the placement of ...


2

Thanks for the help. I came up with two solutions that worked. Show[p1sol17, p2sol17, Graphics[{Red, PointSize[Large], Point[{{0, 3}, {0, 1}}], Black, Text["(0,3)", {0, 3}, {-2, -2}], Text["(0,1)", {0, 1}, {-2, 2}]}], AxesOrigin -> {0, 0}, AxesLabel -> {x, y}, PlotRange -> {{-3, 3}, {-10, 10}} ] Which produced the correct image. ...


1

ParametricNDSolve is a perfectly good way to go about this, so I'll leave that for another answerer. Instead, for fun I'll show an equivalent trick to plot an ODE with respect to one of its parameters by augmenting the system into a 2D PDE. As an example, consider the oscillator equation, $$f''(x)=-\omega^2f(x)$$ where $\omega$ is to vary over a range of ...


1

This looks like a bug related to exporting via the context menu. Try exporting using: sol = DSolveValue[{y'[t] == 1/(2 y[t] + 3), y[0] == 1}, y, t]; p = Plot[sol[t], {t, -10, 10}, ImageSize -> Small] Export[NotebookDirectory[] <> "test.pdf", p, "PDF"]



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