Doug Meade

 

Doug

---------------------------------------------------------------------
Douglas B. Meade <><
Math, USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Phone: (803) 777-6183 URL: http://www.math.sc.edu

MaplePrimes Activity


These are replies submitted by Doug Meade

A := beta(t)^2; eval(A, [beta^2 = proc (t) 0 end proc]); Result is: beta(t)^2 Shouldn't it be zero as well? I understand your logic, but this is not the way Maple works. In this case there is a pretty simple workaround. Just solve fo r beta:
A := beta(t)^2;
eval(A, [beta = (proc (t) 0 end proc)^(1/2)] );
                                         2
                                  beta(t) 
                                      0
I do not understand why you are using a proc in the eval. Why not use:
A := beta(t)^2;
eval(A, [beta(t)^2 = proc (t) 0 end proc] );
                                         2
                                  beta(t) 
                                      0
You may need to use some of the other ideas that have been suggested. In particular, I would get rid of all functional references to t, do my work, then reinsert the functional dependence (if necessary). For example,
A := beta(t)^2;
A1 := eval( A, beta(t)=B );
A2 := algsubs( B^2=t^(1/2), A1 );
eval works here, but the algsubs command is more powerful in its ability to identify algebraic expressions in its second argument. See the online help for more details and examples. Good luck! Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
A := beta(t)^2; eval(A, [beta^2 = proc (t) 0 end proc]); Result is: beta(t)^2 Shouldn't it be zero as well? I understand your logic, but this is not the way Maple works. In this case there is a pretty simple workaround. Just solve fo r beta:
A := beta(t)^2;
eval(A, [beta = (proc (t) 0 end proc)^(1/2)] );
                                         2
                                  beta(t) 
                                      0
I do not understand why you are using a proc in the eval. Why not use:
A := beta(t)^2;
eval(A, [beta(t)^2 = proc (t) 0 end proc] );
                                         2
                                  beta(t) 
                                      0
You may need to use some of the other ideas that have been suggested. In particular, I would get rid of all functional references to t, do my work, then reinsert the functional dependence (if necessary). For example,
A := beta(t)^2;
A1 := eval( A, beta(t)=B );
A2 := algsubs( B^2=t^(1/2), A1 );
eval works here, but the algsubs command is more powerful in its ability to identify algebraic expressions in its second argument. See the online help for more details and examples. Good luck! Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
You said you added this code:
for i from nxpoints+1 to 2*nxpoints do
  u[i,j]=u[1-i,j]
end do;
First, you need ":=", not "=", to make an assignment. Second, I doubt you mean u[1-i,j]. You are probably hoping to implement u(x,t)=u(1-x,t), for x=1/2..1, but this will be coded as u[i,j] := u[2*nxpoints+1-i,j], for i=nxpoints+1..2*nxpoints. To be honest, I think I would prefer to implement this symmetry as u[nxpoints+i,j] := u[nxpoints-i,j]. Try this and see if it doesn't fix your plotting problems as well. Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
You said you added this code:
for i from nxpoints+1 to 2*nxpoints do
  u[i,j]=u[1-i,j]
end do;
First, you need ":=", not "=", to make an assignment. Second, I doubt you mean u[1-i,j]. You are probably hoping to implement u(x,t)=u(1-x,t), for x=1/2..1, but this will be coded as u[i,j] := u[2*nxpoints+1-i,j], for i=nxpoints+1..2*nxpoints. To be honest, I think I would prefer to implement this symmetry as u[nxpoints+i,j] := u[nxpoints-i,j]. Try this and see if it doesn't fix your plotting problems as well. Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
I don't have time right now to look at your full code, but I can comment on the nested seq. First, this is pretty unnatural. I would keep the nested do loops. You should be able to replace
for j from 0 to ntsteps-1 do
for i from 1 to nxpoints-1 do
u[i,j+1]:=r*u[i-1,j]+(1-2*r)*u[i,j]+r*u[i+1,j]
end do;
end do;    # not in your code
with
seq(
 seq( # missing from your code
  assign(u[i,j+1]=r*u[i-1,j]+(1-2*r)*u[i,j]+r*u[i+1,j]),
  j=0..nxsteps-1
 ),         # this closing parenthesis was missing as well
 i=1..nxpoints-1
);
I encourage the use of whitespace to make code more readable. Splitting commands between lines, and indenting, work also. (To see the spacing in MaplePrimes, enclose the code with "pre" tags - for preformat - which are very difficult to show in a post.) Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
I don't have time right now to look at your full code, but I can comment on the nested seq. First, this is pretty unnatural. I would keep the nested do loops. You should be able to replace
for j from 0 to ntsteps-1 do
for i from 1 to nxpoints-1 do
u[i,j+1]:=r*u[i-1,j]+(1-2*r)*u[i,j]+r*u[i+1,j]
end do;
end do;    # not in your code
with
seq(
 seq( # missing from your code
  assign(u[i,j+1]=r*u[i-1,j]+(1-2*r)*u[i,j]+r*u[i+1,j]),
  j=0..nxsteps-1
 ),         # this closing parenthesis was missing as well
 i=1..nxpoints-1
);
I encourage the use of whitespace to make code more readable. Splitting commands between lines, and indenting, work also. (To see the spacing in MaplePrimes, enclose the code with "pre" tags - for preformat - which are very difficult to show in a post.) Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
To me, a "matrix" is a rectangular grid of numbers (or other objects). You use a "matrix" when you refer to u[i,j] (or even just v[i] - a "vector" is also a "matrix"). Not using other "built-in" functions? I think I understand what you are being told, but the language needs to be watched carefully. I believe the comment about matrices is really a restriction from using linear algebra or matrix operations. The comment about built-in functions is probably a restriction from using high-level commands such as dsolve. On one hand I admit that I am being a little picky. But, I do believe it is important to watch the way instructions are given. While I understand some of this, I do stand by my earlier comments that it is a little counterproductive to not use the full power of the software. It sounds as though you are being forced to use Maple as if it were a standard 20th century programming language. Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
To me, a "matrix" is a rectangular grid of numbers (or other objects). You use a "matrix" when you refer to u[i,j] (or even just v[i] - a "vector" is also a "matrix"). Not using other "built-in" functions? I think I understand what you are being told, but the language needs to be watched carefully. I believe the comment about matrices is really a restriction from using linear algebra or matrix operations. The comment about built-in functions is probably a restriction from using high-level commands such as dsolve. On one hand I admit that I am being a little picky. But, I do believe it is important to watch the way instructions are given. While I understand some of this, I do stand by my earlier comments that it is a little counterproductive to not use the full power of the software. It sounds as though you are being forced to use Maple as if it were a standard 20th century programming language. Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
Thanks for the explanation. Now we can hit you full force with our ideas. Take some time to think about the suggestions in my previous post. Show us where you get, and what more you'd like to do. Are there any other restrictions on the uses of Maple? Can LinearAlgebra be used? Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
Thanks for the explanation. Now we can hit you full force with our ideas. Take some time to think about the suggestions in my previous post. Show us where you get, and what more you'd like to do. Are there any other restrictions on the uses of Maple? Can LinearAlgebra be used? Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
These comments make it seem that this is part of a homework assignment. If so, is it within your course/school rules to be getting help on this forum? Regardless, your instructor should be able to provide some local assistance. The rule about not using arrays is odd. You give someone a tool, then tell them they can't use all of it. Who has an electric screwdriver but always uses it as if it were a standard screwdriver? Anyway, back to your code. The only problem I see in your code is an extra "end do" after the seq in the initial condition. With that commented out, I get the solution at 0.001, 0.002, 0.003, 0.004, and 0.005 and the plot shows 6 curves. If you are not going to do anything with the other timesteps, there is no reason to save them in solution. You can also replace the conditional based on floor(X/N)=X/N with X mod N = 0. If you do this, then the loop to create the plots will change to "for j from 1 by iprint to ntsteps+1 do" to "for j from 1 to nops(solution) do". In fact, there is no reason to make the separate plots. The entire plot can be created in one line with nested seq's - just be careful to adjust the indices on solution. Another approach would be to not save all of the results (solution) and to simply create the plot every iprint timesteps. Not knowing your rules, I am not going to post the code I have. It's not very different from what you posted originally. I hope this is helpful, Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
These comments make it seem that this is part of a homework assignment. If so, is it within your course/school rules to be getting help on this forum? Regardless, your instructor should be able to provide some local assistance. The rule about not using arrays is odd. You give someone a tool, then tell them they can't use all of it. Who has an electric screwdriver but always uses it as if it were a standard screwdriver? Anyway, back to your code. The only problem I see in your code is an extra "end do" after the seq in the initial condition. With that commented out, I get the solution at 0.001, 0.002, 0.003, 0.004, and 0.005 and the plot shows 6 curves. If you are not going to do anything with the other timesteps, there is no reason to save them in solution. You can also replace the conditional based on floor(X/N)=X/N with X mod N = 0. If you do this, then the loop to create the plots will change to "for j from 1 by iprint to ntsteps+1 do" to "for j from 1 to nops(solution) do". In fact, there is no reason to make the separate plots. The entire plot can be created in one line with nested seq's - just be careful to adjust the indices on solution. Another approach would be to not save all of the results (solution) and to simply create the plot every iprint timesteps. Not knowing your rules, I am not going to post the code I have. It's not very different from what you posted originally. I hope this is helpful, Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
Florian, Thank you for the updated worksheet. But, this does not tell me what you are trying to do. What is the origin of this problem? What do the variables mean? What question are you trying to answer? One of my thoughts is that you are finding a differential equation (or system). In many instances it is possible to get information from the differential equation(s) without explicitly (or numerically) finding a solution. For example, if you are trying to optimize a function y=f(x) that is a solution to a differential equation, say F(x,f(x),f'(x))=0, simply set f'(x)=0 and solve F(x,f(x),0)=0. Maybe this is completely off-target. But, it would be helpful to know more background and "big picture" information about your problem. Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
Florian, Thank you for the updated worksheet. But, this does not tell me what you are trying to do. What is the origin of this problem? What do the variables mean? What question are you trying to answer? One of my thoughts is that you are finding a differential equation (or system). In many instances it is possible to get information from the differential equation(s) without explicitly (or numerically) finding a solution. For example, if you are trying to optimize a function y=f(x) that is a solution to a differential equation, say F(x,f(x),f'(x))=0, simply set f'(x)=0 and solve F(x,f(x),0)=0. Maybe this is completely off-target. But, it would be helpful to know more background and "big picture" information about your problem. Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
It's even simpler than this. Just click on the Help menu (at the top of the Maple window) and select What's New. Doug
---------------------------------------------------------------------
Douglas B. Meade
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
First 61 62 63 64 65 66 67 Last Page 63 of 76