Rouben Rostamian

MaplePrimes Activity


These are replies submitted by Rouben Rostamian

@mehran rajabi The usual way for searching for roots is to plot the function in order to get a rough idea about where the roots are.  Then call fsolve with appropriate ranges to pinpoint them.  In your case we do:

plot(eq, x = 50 .. 200, discont = true, view = -100 .. 100)
fsolve(eq, x = 60 .. 70);
                          68.93033112
fsolve(eq, x = 70 .. 120);
                          106.9740567
fsolve(eq, x = 120 .. 170);
                          151.0624355
fsolve(eq, x = 170 .. 210);
                          198.3826229

 

 

@Adjal yassine I am quite familiar with the finite element method and its uses for solving differential equation, especially those that relate to structures. I am puzzled, however, by your statement that you are interested in the stiffness matrix, but not in the solution.  What is the use of a stiffness matrix other than for computing a solution?

Perhaps you have good reasons for writing your programs but those reasons do not come through in your posts.  If you wish to attract people's attentions, you should be more explicit in explaining your goals.

 

@acer That's excellent.  I have your setsize in my ~/.mapleinit now.  It works even with animations. Thanks!

The presentation in your worksheet makes things more difficult than is necessary.  Consider the following.

1. You have defined the variables y, B, R, R2, r as functions.  To make life easier, I suggest making all of them into expressions.  For instance, replace

y := (x,k,xi,B) -> whatever

with

y := whatever

2. In the definitions of R and R2 replace B(k) with B.

3.  Is the y that enters the definition of r the same y that is defined on the first line in the worksheet?  I don't think so.  And if that is indeed a different y, then you should name it something different.

4. In order to plot any of these functions, you need to specify the value of k.

 

 

@CEFOG Look at y = a*x + b.  Can you solve for y/a so as to get y/a = (something that has no a in it)?  Do it by hand, not Maple. If you show me how you do that by hand, I will show you how to do it in Maple.

 

@Joa The symbolic solution that you have obtained is too unwieldy to be useful.  At least I cannot make it do what you want.  But the problem that you wish to solve is a well-explored subject and much has been written about it.

Specifically, we have a system of differential equations which involve a certain number of parameters.  We wish to determine the parameters so that the solutions fit a prescribed set of data.  Doing that is not very difficult but requires some familiarity with common techniques in numerical computing.  If you have a serious need (such as graduate research) for solving the problem that you have stated, I suggest that you have a look at Notes on Adjoint Methods.  Section 6 addresses exactly what you need.

 

@Earl Your calculations are correct, however I would organize the worksheet somewhat differently.  You may continue doing it your way, or do it as shown below, whichever makes better sense to you.

restart;

with(plottools): with(plots):

de1 := diff(r(w),w) = 1/(m*k)*F(w);
de2 := diff(F(w),w) = - omega^2*r(w);
bc := r(0)=r__0, F(m)=0;

diff(r(w), w) = F(w)/(m*k)

diff(F(w), w) = -omega^2*r(w)

r(0) = r__0, F(m) = 0

dsol := dsolve({de1,de2,bc});

{F(w) = -r__0*m^(1/2)*k^(1/2)*omega*sin(omega*w/(m^(1/2)*k^(1/2)))+r__0*m^(1/2)*k^(1/2)*omega*sin(omega*m^(1/2)/k^(1/2))*cos(omega*w/(m^(1/2)*k^(1/2)))/cos(omega*m^(1/2)/k^(1/2)), r(w) = -(-cos(omega*w/(m^(1/2)*k^(1/2)))*r__0*m^(1/2)*k^(1/2)*omega-sin(omega*w/(m^(1/2)*k^(1/2)))*r__0*m^(1/2)*k^(1/2)*omega*sin(omega*m^(1/2)/k^(1/2))/cos(omega*m^(1/2)/k^(1/2)))/(omega*m^(1/2)*k^(1/2))}

Don't assign values to the parameters.  That pollutes the worksheet.
Instead, define parameter values as a sequence of equations.

 

Here n is the number of coils, R is the radius of the coils.

params := m=10, k=2, r__0=1, omega=3*Pi/16, R=0.25, n=12;

m = 10, k = 2, r__0 = 1, omega = (3/16)*Pi, R = .25, n = 12

In the code below, the % in front of the %spacecuve makes it an inert operation
which sets up the spacecuve but does not actually execute it because the parameters
have not been applied yet.  In the next line we do eval(%, {params}) to insert the parameters
in the previously constructed line. Finally we do
value(%) to execute that line.

eval(r(w), dsol):
subs(w=m/(2*Pi*n)*theta, %):
%spacecurve([%, R*cos(theta), R*sin(theta)], theta=0..2*Pi*n):
eval(%, {params}):
value(%):
display(%, scaling=constrained, axes=none,
  thickness=5, color="MidnightBlue");

You may want to do with with tubeplot instead of spacecurve:

eval(r(w), dsol):
subs(w=m/(2*Pi*n)*theta, %):
%tubeplot([%, R*cos(theta), R*sin(theta)], theta=0..2*Pi*n,
  radius=0.04, numpoints=300, tubepoints=12, style=surface):
eval(%, {params}):
value(%):
display(%, scaling=constrained, axes=none, color="Orange");

 

 

 

Download Slinky2-alt.mw

 

@Earl  Page 212 of that book reduces the solution of the problem to solving a system of differential equations for the unknown functions r(m*) and F(m*)  [ equations (3) and (4) ]  subject to the boundary conditions in (2).

The rest of that page muddles things up by attempting to establish an analogy with harmonic oscillations.  The analogy is quite confusing since there is no time-dependence in this problem—we are looking at the steady-state rotation of a stretched spring (unvarying length) about an axis.  There is not much to animate here.

Here I will show how to solve the equations noted above in Maple.  The note at the top of page 213 does the same thing, therefore the confusion of page 212 was not necessary at all.
 

Carrying the symbol m* around is inconvenient, therefore

I will replace it with w. Here is the system to be solved:

restart;

de1 := diff(r(w),w) = 1/(m*k)*F(w);
de2 := diff(F(w),w) = - omega^2*r(w);
bc := r(0)=r__0, F(m)=0;

diff(r(w), w) = F(w)/(m*k)

diff(F(w), w) = -omega^2*r(w)

r(0) = r__0, F(m) = 0

dsol := dsolve({de1,de2,bc});

{F(w) = -r__0*m^(1/2)*k^(1/2)*omega*sin(omega*w/(m^(1/2)*k^(1/2)))+r__0*m^(1/2)*k^(1/2)*omega*sin(omega*m^(1/2)/k^(1/2))*cos(omega*w/(m^(1/2)*k^(1/2)))/cos(omega*m^(1/2)/k^(1/2)), r(w) = (sin(omega*w/(m^(1/2)*k^(1/2)))*r__0*m^(1/2)*k^(1/2)*omega*sin(omega*m^(1/2)/k^(1/2))/cos(omega*m^(1/2)/k^(1/2))+cos(omega*w/(m^(1/2)*k^(1/2)))*r__0*m^(1/2)*k^(1/2)*omega)/(omega*m^(1/2)*k^(1/2))}

Simplify the result by introducing set xi = omega*sqrt(m/k)
or equivalently, by letting omega = xi*sqrt(k/m):

eval(dsol, omega = xi*sqrt(k)/sqrt(m)):
combine(%);

{F(w) = sin((m*xi-w*xi)/m)*r__0*xi*k/cos(xi), r(w) = r__0*cos((m*xi-w*xi)/m)/cos(xi)}

These agree with the expressions for r and Fat the bottom of page 212.

 

 

 

Download mw.mw

 

@imparter I know that alpha is a parameter that you want to vary.  The problem is, the code that you have shown has a few dozen of ohter symbols whose meanings are known only to you and the author of the book that you are reading.  I can only guess what those symbols mean.  In fact, I can only guess what the code is attempting to solve because you have not even provided me with the mathematical statement of the problem.

That said, I have made a best effort to guess what you have in mind and have produced this worksheet:  fixed-alpha.m which plots the solution curve at t=0.2 as you have asked, but for alpha=1 only.

To plot the curve for other values of alpha you have two choices:

Choice #1. Copy and paste the entire code (but not the "restart" line) in the worksheet (thus doubling the number of lines in the worksheet).  Set the value of alpha in the second half, execute the entire worksheet.  Then you will have two graphs, the original one (with alpha=1) and the second one with whatever value of alpha you want. 

Copy/paste some more to produce additional graphs with other choices of alpha.  Then you may produce a composite graph by applyting plots:-display.

Choice #2. Instead of copying/pasting, you may wrap the entire code in a proc which takes alpha as a parameter.  Then you may execute that proc any number of times with the desired values of alpha.  This second approach is the right way of doing it but it needs some elementary knowledge of Maple programming.  I cannot tell how much of Maple programming you know.  If you don't, then go with Choice #1.

@imparter The plot the curves based on the code that you have shown requires reading the book to understand what the various variables mean. But I don't have the book. Sorry.

@imparter In my previous message I showed how to plot the solution at time t=0.2 for alpha = 0.1, 3.0 and 5.0. Those are the curves drawn in red, green, and blue.  Isn't that what you are asking?

@AhmedRahby The first step in changing the order of integration, is to draw an accurate picture of the domain of integration as I did in my answer to your previous question.  Did you see that?

It can't be done without pictures.

 

@Carl Love Thanks for the complement. I, too, teach multiple integrals that way.  Some students see the idea right-away and have an easy time.  For some others it never clicks because they have difficulty in connecting analysis with the underlying geometry.

 

@AhmedRahby  Do you realize that a multiple integral expresses integration over a certain domain?  The integration limits specify the domain.  Can you sketch the integration domain for your integral?  There is no point in playing around with integration if you don't see that connection.

You have terminated some of the crucial parts of the code with colons and therefore deprived yourself of the chance to visually inspect what Maple is doing.  Don't do that!  Terminate commands with semicolon and verify that Maple echos what you expect.

If you change colons to semicolons, you will see that pde1 contains the undefined variable ρA and ibc1 contains the undefined variable ℓ. Correct those!

After those corrections your problem is well-posed and should have a solution.  Unfortunately Maple's pdsolve is unable to find it.  The fact that we have v(t) rahter than v(x,t) is not the cause of the failure (see the worksheet below.)  The problem arises due to the terms w(0,t) and w(ℓ, t) that occur in pde2 which to Maple looks like a boundary condition rather than a PDE, and therefore it complains about insufficient number of equations.  I don't see a workaround.  If you really need a solution, you may write your own finite difference solver for it.

The much simpler system in the worksheet below suffers from the same issue.

restart;

pde1 := diff(u(x,t),t) = diff(u(x,t),x,x);
ibc1 := u(0,t)=0, u(Pi,t)=0, u(x,0)=sin(x);

diff(u(x, t), t) = diff(diff(u(x, t), x), x)

u(0, t) = 0, u(Pi, t) = 0, u(x, 0) = sin(x)

pde2 := diff(v(x,t),t) = diff(v(x,t),x,x) + sin(x)*D[1](u)(0,t);
ibc2 := v(0,t)=0, v(Pi,t)=0, v(x,0)=0;

diff(v(x, t), t) = diff(diff(v(x, t), x), x)+sin(x)*(D[1](u))(0, t)

v(0, t) = 0, v(Pi, t) = 0, v(x, 0) = 0

The exact solution is

sol_exact := u(x,t) = sin(x)*exp(-t),  v(x,t) = t*exp(-t)*sin(x);

u(x, t) = sin(x)*exp(-t), v(x, t) = t*exp(-t)*sin(x)

Let's verify that:

pdetest([sol_exact], [pde1, pde2, ibc1, ibc2]);

[0, 0, 0, 0, 0, 0, 0, 0]

OK, that verifies it.  Now let's try the numerical solver:

pdsol := pdsolve({pde1,pde2}, {ibc1,ibc2}, numeric);

Error, (in pdsolve/numeric/process_PDEs) number of dependent variables and number of PDE must be the same


 

Download mw.mw

First 41 42 43 44 45 46 47 Last Page 43 of 99