Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

I may not be understanding your question correctly, but perhaps the following can help.

restart;

Consider the function  u(x) defined on the interval "-Pi < x < Pi." Its Fourier series is given by

Sum(Int(exp(I*n*x)*u(x), x=-Pi..Pi)*exp(-I*n*x), n=-infinity..infinity) / (2*Pi);

(1/2)*(Sum((Int(exp(I*n*x)*u(x), x = -Pi .. Pi))*exp(-I*n*x), n = -infinity .. infinity))/Pi

(1)

Example: Let's calculate the Fourier series of the function

f := piecewise(x<0, 0, x);

f := piecewise(x < 0, 0, x)

(2)

subs(u(x)=f, (1)):
value(%);

(1/2)*(sum(-(I*exp(I*Pi*n)*Pi*n-exp(I*Pi*n)+1)*exp(-I*n*x)/n^2, n = -infinity .. infinity))/Pi

(3)

As you have noted, there is an n in the denominator, but Maple is smart enough to handle it correctly as we see here where we sum over "n=-1, 0, 1," so we need not worry about it:

eval((3), infinity=1):
evalc(%);

(-2*cos(x)+Pi*sin(x)+(1/4)*Pi^2)/Pi

(4)

Of course, that's too few terms.  By taking a larger number of terms we get a pretty good approximation:

eval((3), infinity=20):
evalc(%);

(-2*cos(x)+(1/4)*Pi^2+Pi*sin(x)-(2/81)*cos(9*x)-(2/49)*cos(7*x)-(2/25)*cos(5*x)-(2/9)*cos(3*x)-(2/289)*cos(17*x)+(1/9)*Pi*sin(9*x)+(1/5)*Pi*sin(5*x)+(1/7)*Pi*sin(7*x)+(1/3)*Pi*sin(3*x)+(1/17)*Pi*sin(17*x)+(1/13)*Pi*sin(13*x)+(1/15)*Pi*sin(15*x)+(1/11)*Pi*sin(11*x)+(1/19)*Pi*sin(19*x)-(2/225)*cos(15*x)-(2/169)*cos(13*x)-(2/121)*cos(11*x)-(2/361)*cos(19*x)-(1/4)*Pi*sin(4*x)-(1/6)*Pi*sin(6*x)-(1/10)*Pi*sin(10*x)-(1/2)*Pi*sin(2*x)-(1/12)*Pi*sin(12*x)-(1/8)*Pi*sin(8*x)-(1/14)*Pi*sin(14*x)-(1/16)*Pi*sin(16*x)-(1/20)*Pi*sin(20*x)-(1/18)*Pi*sin(18*x))/Pi

(5)

Here are the graphs of the original function (in red) and its Fourier series representation (in blue).

plot([(5),f], x=-Pi..Pi, thickness=2, color=[blue, red], legend=[Fourier_Series, u(x)=f]);

 
 

 

Download FourierSeries.mw

Solving this PDE is a textbook example an application of the Fourier series.  Tomleslie has already sketched the first half of the process.  In the attached worksheet I have carried it out all the way to the end.  There is one correction, however.  Tomleslie's calculations end up with X(x) expressed as an exponential function and Y(y) as a trigonometric function.  That won't work.  It should be the other way around in order to satisfy the boundary conditions bc[3] and bc[4].  The solution turns out to be

u(x, y) = Sum(4*((-1)^n-1)*sin(Pi*n*x)*cosh(n*Pi*y)/(n^3*Pi^3*cosh(n*Pi)), n = 1 .. infinity)

 

which agrees with what Maple 2017's pdsolve() produces, as shown by Kitonum.

Here's what the solution looks like:

Worksheet:   mw.mw

Update: The previous worksheet had a couple of careless typos, although the final solution was correct.  In this new version I have fixed the typos.

Worksheet ver 2: mw-ver2.mw

 

@Bendesarts After fixing the brackets issue we can make some progress but the results are not very encouraging.  Let's assume all variables other than g are positive:

indets(TableauRouth) minus {g}:
(x -> x>0)~(%):
rels := %[]
;

                  rels := 0 < ca, 0 < ka, 0 < keqc, 0 < ma, 0 < meqc, 0 < p

and then try the easier task of solving the equality TableauRouth[4,1]=0 for g:

solve(TableauRouth[4,1]=0, g) assuming rels;

If you try that, you will see that Maple does succeed in solving the equation but the result is so huge as to being useless. This tells us that there is no simple necessary and sufficient condition in terms of g for the stability of your system.

 

You should refer to matrix entries through square brackets, not parentheses.

Change TableauRouth(2,1)  to TableauRouth[2,1] to fix the Maple coding problem.  After that you will have to deal with the mathematics of your question, and that may not be very easy.

 

 

restart;

 

sigma := (r,z) -> (1-r)*(1-z)^2*(1/sqrt(z^2+(1-r)^2) + r*z^2/(1+z^2)^(3/2));

proc (r, z) options operator, arrow; (1-r)*(1-z)^2*(1/sqrt(z^2+(1-r)^2)+r*z^2/(1+z^2)^(3/2)) end proc

 
 

sigma(1,z);

            0

 
 

sigma(r,0) assuming r>0, r<1;

            1

 
 

D[1](sigma)(0,z):  simplify(%);

            0

 
 

D[2](sigma)(r,1);

            0

 
 

plot3d(sigma(r,z), r=0..1, z=0..1, style=patchcontour);

 
 

 

 

 

p := randpoly(x,coeffs=rand(-1..1),degree=6);

x^6-x^4-x^3+x^2-x-1

 
 

r := fsolve(p, complex);

-HFloat(0.9274257587897949)-HFloat(0.8169970506029892)*I, -HFloat(0.9274257587897949)+HFloat(0.8169970506029892)*I, HFloat(-0.5667626672449242), HFloat(0.526644569079707)-HFloat(0.7528316788438223)*I, HFloat(0.526644569079707)+HFloat(0.7528316788438223)*I, HFloat(1.3683250466651)

 
 

plots:-complexplot([r], style=point,  color=orange,
           symbol=solidcircle, symbolsize=20);

 
 

 


 

Here is how:

 

restart;

 

M := < a,b;c,d>;

_rtable[18446883792265957614]

 
 

(x->1/sqrt(x))~(M);

_rtable[18446883792265958814]

 
 

 

 

See Maple's help on fieldplot3d.  This is an example from there:

with(plots):
fieldplot3d([2*x,2*y,1],x=-1..1,y=-1..1,z=-1..1,grid=[5,5,5]);

 

Your argument here is backwards: You should check the correctness of Matlab with the help of Maple, not the other way around.

Matlab does its calculations in the machine hardware which carries about 16 digits of precision.  Maple can do its floating point calculations in software with any degree of precision.  The default is 10 digits which is less than Matlab's, but you may request higher.  For instance:

K := 25888158.4218766;
K-sqrt(K^2-1);              # default 10 digits precision
    0.
evalf(K-sqrt(K^2-1), 30);   # 30 digits precision
    1.93138496702600*10^(-8)

Compare this correct answer to Matlab's not-so-good answer.

You may change Maple's default precision of 10 by setting the value of Digits , as in:
Digits := 30;
Then all floating point calculations will be done with 30 digists of accuracy in software.  This will slow things down, therefore I don't recommend doing that unless you really have a need for it.

 

As an alternative to what kitonum has suggested, you may try:

ss1:=-2:  ss2:=1/2:  ss3:=-5:
printf("The 3 equation in A, B, C for s=%a, s=%a, and s=%a:\n", ss1, ss2, ss3);
     The 3 equation in A, B, C for s=-2, s=1/2, and s=-5:

Here is an alternative to what rlopez has suggested.

restart;
with(Physics):
Typesetting:-Settings(typesetdot=true):

Here I will pick a Lagrangian function just for illustration.  Replace it with yours.

L := 1/2*a[1]*diff(q[1](t),t)^2 + 1/2*a[2]*diff(q[2](t),t)^2
   + b*diff(q[1](t),t)*diff(q[2](t),t)
   + c[1]*q[1](t) + c[2]*q[2](t);

The two Euler-Lagrange equations are:

de[1] := diff(diff(L, diff(q[1](t),t)), t) - diff(L, q[1](t)) = Q[1](t);
de[2] := diff(diff(L, diff(q[2](t),t)), t) - diff(L, q[2](t)) = Q[2](t);

 

 

 

Here is an alternative to the solution presented by vv and kitonum.  It involves a little bit of a "cheat" in embedding the drawings in 3D.  The method can handle non-convex domains with equal ease.  Here are a couple of samples extracted from the worksheet mw.mw.

You are attempting to solve your equations in two phases: first for p and q, and then for M.  It is easier to solve all of them together at once.

There are four unknowns, p1, p2, q1, q2, from the first set of equations.  There are 16 knowns, M[i,j], from the second set of equations.  Put them together and solve a system of 20 equations in 20 unknowns, and then you are done.

You didn't say what your differential equations are, therefore I will make up some arbitrary ones here.
de1 := diff(x(t),t,t) = -x(t) - diff(x(t),t) + y(t);
de2 := diff(y(t),t,t) = -y(t) - diff(y(t),t) + x(t);
ic := x(0)=0, D(x)(0)=1, y(0)=0, D(y)(0)=1;

As you see, I have isolated the second derivative terms on the left-hand sides of de1 and de2.

Now solve the system:
dsol := dsolve({de1, de2, ic}, numeric);

Let's say we want to examine the solution at time t=1.23.  We do
dsol(1.23);

The accelerations at time t=1.23 are obtained from
eval(rhs(de1), dsol(1.23));
eval(rhs(de2), dsol(1.23));

 

This is only a slight variation of a question that you asked a month ago.  Here is how to solve it:

Worksheet: mw.mw

First 40 41 42 43 44 45 46 Last Page 42 of 58