0
|
7857 Views
|
15 Replies
|
10 Total Likes
View groups...
Share

# Strange numerical problem with fairly simple symbolic equation.

Posted 9 years ago
 Hi, I have a strange problem with a fairly simple function. I define the following: In:= u = Tanh[x/Sqrt] Out= Tanh[x/Sqrt] In:= f = Laplacian[u, {x}] + (1 - u^2)* u Out= -Sech[x/Sqrt]^2 Tanh[x/Sqrt] + Tanh[x/Sqrt] (1 - Tanh[x/Sqrt]^2)  Looks not too complicated, does it ? Now to the weired thing: I believe that u=Tanh[x/Sqrt] is a solution to Laplacian[u, {x}] + (1 - u^2)* u == 0 using the boundary condition f[-inf]==-1 && f[inf]==1. Mathematica doesn't seem to be able to deliver me any solution, though. Well, I might be wrong with my guessed solution, so I just plugged it into the equation to see how far off I am. Looking at the plot of f(x) from x=-4 to x=4 reveals something strange, though: So that plot looks way too noisy and within tiny numbers that I suspect a numerical problem here (and tanh(x/sqrt(2)) actually being a solution). Is that possible ? Why is that ? Could that also be the problem why Mathematica is unable to solve for u with the said boundary condition ? Also I tried In:= Simplify[f] Out= 0  so Mathematica DOES understand that it is zero. Why can't I then solve for u ? How would I do that properly ?
15 Replies
Sort By:
Posted 9 years ago
 Thanks the replies. So is there no way Mathematica can solve this equation for the boundary condition and give me the tanh(x/sqrt(2)) ? Do I have to guess all my solutions for specific boundary problems ? ;)
Posted 9 years ago
 Even though I have luckily guessed the solution for the 1-dimensional case I was not so lucky with the 2- and 3-dimensional case (where u^2 becomes u.u and the boundary condition at x^2+y^2+z^2==inf being {x,y,z}/Sqrt[x^2+y^2+z^2]). Is there a way to solve this problem with Mathematica ?
Posted 9 years ago
 and the boundary condition at x^2+y^2+z^2==inf being {x,y,z}/Sqrt[x^2+y^2+z^2]) Why don't you adopt a radial symmetric condition? By the way possibly the above condition is for a scalar function $u(x,y,z)$ contradictory e.g. for {x, y, z} = {0, -Infinity, Infinity}. Not sure how this works for a vector valued function $\vec{u} = u_1(x,y,z) \vec{e_1} + u_2(x,y,z) \vec{e_2} + u_3(x,y,z) \vec{e_3}$.
Posted 9 years ago
 Yes, using spherical coordinates would certainly make sense as the solution must be spherically symmetric. I just wasn't sure how to do it with Mathematica (I'm still a beginner). And to reformulate the boundary condition: Basically the condition should be that vectors at r=inf should have a length=1 and point away from the origin. At the origin (r=0) the vector length=0. How could I formulate it for mathematica ? Though I'm still struggling with the 1D case (see comment to your next post).
Posted 9 years ago
 with the 2- and 3-dimensional case (where u^2 becomes u.u ...) In 2- and 3-D the equation $\begin{equation}\frac{d^2u(x)}{dx^2}+(1-u(x)^2) u(x)=0\end{equation}$ no obvious generalization for a vector valued function $\vec{u}(\vec{x})$ exists because the Laplace operator $\Delta=\nabla\cdot\nabla$ as a gradient of the divergence of a scalar function $u(\vec{x})$ will not happen to be applicable. If one applies the divergence to a vector valued function, a matrix valued function appears ...
Posted 9 years ago
 hmm, i don't really understand what you are saying. But this equation is the Ginzburg-Landau equation which works in any dimension (so u yields a 3-vector for every given x, also a 3-vector). So for 3 dimensions it works on a 3d vector field. the laplacian of a 3d vector field is again a 3d vector field (and the second term is also a 3d vector field to be added). and i know from numerical experiments that there is a solution to it. so what's the problem here ?
Posted 9 years ago
 I was remembering only the scalar Laplacian but there is also the Vector Laplacian, you're right.
Posted 9 years ago
 There is a way In:= First[ FullSimplify[ ExpToTrig[u[y] /. DSolve[{D[u[x], {x, 2}] + (1 - u[x]^2) u[x] == 0, u == 0, u' == 1/Sqrt}, u, x]] ] ] Out= Tanh[y/Sqrt] using conditions not so far away In:= DSolve[{D[u[x], {x, 2}] + (1 - u[x]^2) u[x] == 0, u == 0, u' == 1/Sqrt}, u, x] Out= {{u -> Function[{x}, (-1 + E^(Sqrt x))/(1 + E^(Sqrt x))]}} 
Posted 9 years ago
 hmm, it doesn't work for me for some reason In:= First[FullSimplify[ExpToTrig[u[y] /. DSolve[{D[u[x], {x, 2}] + (1 - u[x]^2) u[x] == 0, u == 0, u' == 1/Sqrt}, u, x]]]] During evaluation of In:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >> During evaluation of In:= DSolve::bvfail: For some branches of the general solution, unable to solve the conditions. >> During evaluation of In:= DSolve::bvfail: For some branches of the general solution, unable to solve the conditions. >> Out= y In:= DSolve[{D[u[x], {x, 2}] + (1 - u[x]^2) u[x] == 0, u == 0, u' == 1/Sqrt}, u, x] During evaluation of In:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >> During evaluation of In:= DSolve::bvfail: For some branches of the general solution, unable to solve the conditions. >> During evaluation of In:= DSolve::bvfail: For some branches of the general solution, unable to solve the conditions. >> Out= {} Any idea why that is ?Also I don't understand how you got the new boundary condition from the original one.
Posted 9 years ago
 Any idea why that is ? The Mathematica version is a candidate; here is Mathematica 10.0.2.0 Windows 7 64 Bit Home Premion in use. Also I don't understand how you got the new boundary condition from the original one. That's incredibly simple. You stated In:= Simplify[D[#, {x, 2}] + (1 - #^2) #] &[Tanh[x/Sqrt]] Out= 0 So one uses the solution to compute other conditions In:= Limit[Tanh[x/Sqrt], x -> 0] Out= 0 In:= Limit[D[Tanh[x/Sqrt], x] /. x -> y, y -> 0] Out= 1/Sqrt allowing to reproduce it So is there no way Mathematica can solve this equation for the boundary condition and give me the tanh(x/sqrt(2)) ? In:= DSolve[{D[u[x], {x, 2}] + (1 - u[x]^2) u[x] == 0, u == 0, u' == 1/Sqrt}, u, x] Out= {{u -> Function[{x}, (-1 + E^(Sqrt x))/(1 + E^(Sqrt x))]}} 
Posted 9 years ago
 Ah okay, but that's somewhat cheating as I have to know the solution in advance already. ;) If I wouldn't have had that lucky guess of tanh(x/sqrt(2)) in the first place there would be no way to derive the solution, i guess ?(and i'm still on mathematica 9)
Posted 9 years ago
 In Mathematica 10 no cheating is needed, looking at the general solution one sees the C and C bringing the most significant simplifications: In:= Simplify[ Quiet[(u[y] /. DSolve[D[u[x], {x, 2}] + (1 - u[x]^2) u[x] == 0, u, x])] /. {C -> 1/2, C -> 0}, Assumptions -> y \[Element] Reals] Out= {-Tanh[Abs[y]/Sqrt], Tanh[Abs[y]/Sqrt]} because Tanh is an odd function In:= Tanh[x] == -Tanh[-x] Out= True this is your result. Seemingly the general algorithm has a problem to check that C -> 1/2 und C -> 0 will do the boundary conditions, saying Solve::incnst: Inconsistent or redundant transcendental equation. After reduction, the bad equation is 1-2 C == 0. >> but this is in fact the good equation reducing the JacobiSN.
Posted 9 years ago
 u[x_] := Tanh[x/Sqrt] In:= D[u[x], {x, 2}] + (1 - u[x]^2)*u[x] Out= -Sech[x/Sqrt]^2 Tanh[x/Sqrt] + Tanh[x/Sqrt] (1 - Tanh[x/Sqrt]^2) In:= Simplify[%] Out= 0 Noisy graph just shows computational roundoff errors
Posted 9 years ago
 Plot of necessity must evaluate numerically. That means there can be numerical error. The fact that you get values around $MachineEpsilon indicates this is in fact the case.Sometimes one can fool Plot by adding a largish constant, say 10^4, in the computation and later subtracting it. Posted 9 years ago  For the boundary condition one gets an error: DSolve[{D[u[x], {x, 2}] + (1 - u[x]^2) u[x] == 0, u[-Infinity] == -1, u[Infinity] == 1}, u, x] Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >> DSolve::bvlim: For some branches of the general solution, unable to compute the limit at the given points. Some of the solutions may be lost. >> Solve::incnst: Inconsistent or redundant transcendental equation. After reduction, the bad equation is 1-2 C == 0. >> the equation has a solution: In:= DSolve[D[u[x], {x, 2}] + (1 - u[x]^2) u[x] == 0, u, x] During evaluation of In:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >> Out= {{u -> Function[{x}, I Sqrt[-(1/(1 - Sqrt[1 - 2 C]))] JacobiSN[Sqrt[ x^2 + x^2 Sqrt[1 - 2 C] + 2 x C + 2 x Sqrt[1 - 2 C] C + C^2 + Sqrt[1 - 2 C] C^2]/ Sqrt, (1 - Sqrt[1 - 2 C])/(1 + Sqrt[1 - 2 C])] - I Sqrt[-(1/(1 - Sqrt[1 - 2 C]))] Sqrt[1 - 2 C] JacobiSN[Sqrt[ x^2 + x^2 Sqrt[1 - 2 C] + 2 x C + 2 x Sqrt[1 - 2 C] C + C^2 + Sqrt[1 - 2 C] C^2]/ Sqrt, (1 - Sqrt[1 - 2 C])/( 1 + Sqrt[1 - 2 C])]]}, {u -> Function[{x}, -I Sqrt[-(1/(1 - Sqrt[1 - 2 C]))] JacobiSN[Sqrt[ x^2 + x^2 Sqrt[1 - 2 C] + 2 x C + 2 x Sqrt[1 - 2 C] C + C^2 + Sqrt[1 - 2 C] C^2]/ Sqrt, (1 - Sqrt[1 - 2 C])/(1 + Sqrt[1 - 2 C])] + I Sqrt[-(1/(1 - Sqrt[1 - 2 C]))] Sqrt[1 - 2 C] JacobiSN[Sqrt[ x^2 + x^2 Sqrt[1 - 2 C] + 2 x C + 2 x Sqrt[1 - 2 C] C + C^2 + Sqrt[1 - 2 C] C^2]/ Sqrt, (1 - Sqrt[1 - 2 C])/(1 + Sqrt[1 - 2 C])]]}} The printing stuff below and around the $MachinePrecision means that it is not meaningful to print because it might or might not be zero, for Chop it's clearly zero.