Nick

25 Reputation

4 Badges

15 years, 26 days

MaplePrimes Activity


These are replies submitted by Nick

Ahh, thank you.  Okay.. but suppose now that we know the magnitude of w as well. Also assume that we know all the components of v and b. Is there anyway we can use this given information to find the individual components of w[1], w[2]. w[3]?  

Ahh, thank you.  Okay.. but suppose now that we know the magnitude of w as well. Also assume that we know all the components of v and b. Is there anyway we can use this given information to find the individual components of w[1], w[2]. w[3]?  

I modified the program to use plot3d, and things work perfectly now.  Thank you very much

I modified the program to use plot3d, and things work perfectly now.  Thank you very much

Is there a way to make Maple even more picky?  I just feel like when I programmed with C++, the compiler would catch so many of my little mistakes.  I know often find myself struggling to find them on my own with Maple.

Is there a way to make Maple even more picky?  I just feel like when I programmed with C++, the compiler would catch so many of my little mistakes.  I know often find myself struggling to find them on my own with Maple.

@pagan Awesome.  Thank you. That's exactly what my guess was.  I'm finally getting a grasp on this language.

But now I'm having basically the exact same error as last time, but now with an acceleration proc... It is literally coded the exact same way, but values are not assigned to the accel matrix... Is there some sort of nuance of the Maple programming language that I am missing, or is there a bug in Maple that I am not aware of?

The proc is dirt simple.  Here:

 

accel := Matrix(3, 241, datatype = float[8]);

gravity := 32.174;

UpdateAllAccelerations := proc (i, accel::Matrix, gravity)

accel(1, i) := 342;  #arbitrary... just for testing reasons

accel(2, i) := 423;

accel(3, i) := -243;

end proc;

#inside the same look that the velocity update was in:

for i from 1 to 241 do

UpdateAllAccelerations*(i, accel, gravity);

end do:

 

I really need to learn what is causing these identical problems... I just don't see why these procedures aren't working when i type them out.  I thought this assignment would take me a few hours, but it has developed into quite an ordeal.  Could i be making really little spelling errors/syntactical? I don't think spacing is relevant, is it?

@pagan Awesome.  Thank you. That's exactly what my guess was.  I'm finally getting a grasp on this language.

But now I'm having basically the exact same error as last time, but now with an acceleration proc... It is literally coded the exact same way, but values are not assigned to the accel matrix... Is there some sort of nuance of the Maple programming language that I am missing, or is there a bug in Maple that I am not aware of?

The proc is dirt simple.  Here:

 

accel := Matrix(3, 241, datatype = float[8]);

gravity := 32.174;

UpdateAllAccelerations := proc (i, accel::Matrix, gravity)

accel(1, i) := 342;  #arbitrary... just for testing reasons

accel(2, i) := 423;

accel(3, i) := -243;

end proc;

#inside the same look that the velocity update was in:

for i from 1 to 241 do

UpdateAllAccelerations*(i, accel, gravity);

end do:

 

I really need to learn what is causing these identical problems... I just don't see why these procedures aren't working when i type them out.  I thought this assignment would take me a few hours, but it has developed into quite an ordeal.  Could i be making really little spelling errors/syntactical? I don't think spacing is relevant, is it?

So I just copy and pasted parts of what you did in there, and it works now.  

Note that the declaration of accel was included in my code; I just didn't post it online.

I tried removing small segments of your code and replacing it with my own to isolate what I did wrong, but I couldn't find the error.  Maybe I misspelled something forgot a comma... who knows.  Note that the declaration of accel was included in my code; I just didn't post it online.

This is just bizarre.

So I wanted to ask what exactly the inclusion of the NULL does.  I'm guessing that this is only appropriate because I am modifying a matrix, which is itself passed into a function, as opposed to a copy of it. Right?  I suppose this is just good programming practice as well.

Thank you for the other bits of advice.  I'll be sure to take them.

So I just copy and pasted parts of what you did in there, and it works now.  

Note that the declaration of accel was included in my code; I just didn't post it online.

I tried removing small segments of your code and replacing it with my own to isolate what I did wrong, but I couldn't find the error.  Maybe I misspelled something forgot a comma... who knows.  Note that the declaration of accel was included in my code; I just didn't post it online.

This is just bizarre.

So I wanted to ask what exactly the inclusion of the NULL does.  I'm guessing that this is only appropriate because I am modifying a matrix, which is itself passed into a function, as opposed to a copy of it. Right?  I suppose this is just good programming practice as well.

Thank you for the other bits of advice.  I'll be sure to take them.

I just didn't include that declaration because I didn't realize it was missing until I already posted the code.

I declared accel directly below vel: accel := Matrix(3, 241, datatype = float[8]);

I'll edit the code above with this addition.

Note that the velocity indices still do not update when i include this declaration.

 

EDIT: looks like it's too late to edit the above post

I just didn't include that declaration because I didn't realize it was missing until I already posted the code.

I declared accel directly below vel: accel := Matrix(3, 241, datatype = float[8]);

I'll edit the code above with this addition.

Note that the velocity indices still do not update when i include this declaration.

 

EDIT: looks like it's too late to edit the above post

I don't think I'm allowed to post large sections of the code online.  Sorry about that.  The program is a disgusting mess anyway.  The student who wrote it did not have any formal guidance with programming with Maple, so it is written without proper style and structure; I am similarly lost.  Difficulty finding learning materials isn't helping the matter.

Let me give an example of a performance issue I experienced.  In order to test the speed of Maple, I extracted a very small piece of my finished program and ran it.  I'll post an excerpt here.

(By the way, note that I have little to no idea of how to program in Maple.  You are more than welcome to criticize.)

pos := Matrix(3, 241); vel := Matrix(3, 241); angVel := Matrix(3, 241);

step = 0.1;

pos(1, 1) := 2; pos(2, 1) := 0; pos(3, 1) := 5;  #arbitrary values

vel(1, 1) := 13; vel(2, 1) := 0; vel(3, 1) := 9;

UpdatePosition := proc (i)

pos(1, i) := pos(1, i-1)+vel(1, i)*step; #x position

pos(2, i) := pos(2, i-1)+vel(2, i)*step; #y position

pos(3, i) := pos(3, i-1)+vel(3, i)*step  #z position

end proc;

for i from 2 to 241 do

UpdatePosition(i)

end do;

This small section of code took a couple seconds to execute.  The final program should have thousands of more computations that this program.  If the execution time increased linearly, then the program would easily take a minute or more to run.  

P.S.  Are there code tags I can use?

I don't think I'm allowed to post large sections of the code online.  Sorry about that.  The program is a disgusting mess anyway.  The student who wrote it did not have any formal guidance with programming with Maple, so it is written without proper style and structure; I am similarly lost.  Difficulty finding learning materials isn't helping the matter.

Let me give an example of a performance issue I experienced.  In order to test the speed of Maple, I extracted a very small piece of my finished program and ran it.  I'll post an excerpt here.

(By the way, note that I have little to no idea of how to program in Maple.  You are more than welcome to criticize.)

pos := Matrix(3, 241); vel := Matrix(3, 241); angVel := Matrix(3, 241);

step = 0.1;

pos(1, 1) := 2; pos(2, 1) := 0; pos(3, 1) := 5;  #arbitrary values

vel(1, 1) := 13; vel(2, 1) := 0; vel(3, 1) := 9;

UpdatePosition := proc (i)

pos(1, i) := pos(1, i-1)+vel(1, i)*step; #x position

pos(2, i) := pos(2, i-1)+vel(2, i)*step; #y position

pos(3, i) := pos(3, i-1)+vel(3, i)*step  #z position

end proc;

for i from 2 to 241 do

UpdatePosition(i)

end do;

This small section of code took a couple seconds to execute.  The final program should have thousands of more computations that this program.  If the execution time increased linearly, then the program would easily take a minute or more to run.  

P.S.  Are there code tags I can use?

I agree that my knowledge of other programming languages is hindering my understanding of Maple, primarily because they embody different paradigms.  I suppose learning to program in Maple is the next big step.  Is there anywhere where I can find examples of fully fleshed out programs?

I own the Introductory and advanced programming guides linked above and have looked through them pretty extensively.  Unfortunately, while they cover an extensive array of topics, they are a bit short on details, often neglecting detailed explanations as well as larger examples that show how all the concepts fit together into the puzzle.  Is there another resource available that I can reference besides Google?

With regards to program structure:

Should I basically put the entire thing inside a module and declare most of my structures to be local.  Then I can pass these structures into the many procedures that I intend to call.  Or is it appropriate to use global variables?  I understand in many languages that this latter technique is often highly discouraged.

1 2 Page 1 of 2