awass

296 Reputation

10 Badges

19 years, 322 days

MaplePrimes Activity


These are replies submitted by awass

@Carl Love 

Yes, parentheses are a programmers best friend!

@vv Thanks,  I did not think of that.

@Axel Vogt 

 

Sorry, I don't understand your comment.

@Carl Love 

I understand now. It is like trying to plot
f := proc (x) options operator, arrow; if Pi < x then x^2 else -x end if end proc;

plot(f)

 

Works fine but

plot(f(x), x = -5 .. 5);
Error, (in f) cannot determine if this expression is true or false: Pi < x

plot('f(x)', x = -5 .. 5) also works for the same reason I guess.

I appreciate the clear explanations and the stylistic improvements also. Many thanks.

@Carl Love 

I understand that you have reformatted the input to meet Maple requirements for the plot3d command.
That is the difference between td and TD.

Also, the option remember addition to spped things up by a factor of 3 is clear. 

However, the eval command is the magic which somehow prevents premature evaluation in this case.

I do not undertand what is going on.

The alternative solution you proposed using an if statement works equally well but I also find that a bit mysterious as well as your comment about "bound variables". Could you please explain that?

@_Maxim_ I agree completely.

BTW,in my case doing the computaion 3 times does consume significant time.

@acer  I understand what Maple is complaining about now.

However, I must say I regard it as lazy coding. It would require only a few extra lines of code to accept either  input of the form [f(x,y), g(x,y),h(x,y)] or of the form [triple of values that depend on (x,y)]. It very much reminds me of the web pages that cannot deal with dashes in phone numbers or spaces in credit card numbers. Duh!

@tomleslie  I have never spent much time worrying about the idiosyncrasies and/or weaknesses of Maple. I have work to do. If something does not work in an intuitive way I flail around a bit to get what I want and then go on with my life. It is the 21st century; people do read manuals.

I remember well that in Maple I if you typed a command that had a t in it like plot or int or diff(f(t),t) Maple might balk on occasion for no discernable reason. The fix was to go back, erase the offending t and retype it. Pretty silly but that worked and that is what I told my students to do. Programs can be quirky like people. Not worth thinking about! That bug was fixed by Release 2.

 

@taro 

 

I did have smart quotes disabled. Mysterious!

@Carl Love

Good detective work.

I used the TextEdit application on my Mac to create the file as plain text. I wonder why the quotes were not ASCII.

 

You asked if I was using Maple 2017; the answer is yes. Whis is the new way of adding comments?

@Carl Love H

Here is my (silly) text file

Comments:=blah, blah, blah;
(*ignore this message*)
Cmnts:= “if time goes by then a=2.1” ;


Here is the result of my read command

read "Desktop/test3.txt";
                  Comments := blah, blah, blah
Error, on line 4, syntax error, missing operator or `;`:
Cmnts:=    if time goes by then a=2.1    ;
                 ^
Warning, unprintable characters in input
Error, while reading ``Desktop/test3.txt``

In Maple I enter
Cmmnts := "blah, blah,if  read save are included then end  blah" and the words if read save are all in bold. I can, however, save Cmmnts to an .mpl file or a .txt file and then read it back without problem.

When I save some data to a file for later use it is likely that I will forget some details of the calculation. I would like to add some text to the file. I have tried commands like
>comments:="blah, blah, a=7.1, blah";
and that works. When I read the file back I get the comments. However, it does not work if there are any reserved words included between the quotes, for exapmle if, read, do etc. Any suggestions for dealing with that? Idealy i would like to recall text enclosed with (* *)

That is very clear. I would love to see this in the help page; iy would have saved me a lot of time.
 

Now I can easily save a bunch of commands to a text file or .mpl file and then read them into a Maple session. If I do start a new worksheet and read a file  iinto that worksheet and later save the new worksheet will the values of L and A also be saved? (I suspect not; the read statements will still be there to re-enter those values.)

@tomleslie Hi,

 

I used a toy equation in my attempts to understand events.

> eq := diff(y(x), x, x)+y(x) = 0
> nan := dsolve({eq, y(0) = 1, (D(y))(0) = -1}, numeric, events = [[y(x) = 0, [print("Yes"), halt]]])

                             "Yes"
                nan := proc(x_rkf45)  ...  end;

 

>nan(20)

Warning, cannot evaluate the solution further right of .78539817, event #1 triggered a halt
    [                                                 -17  
    [x = 0.785398176646644, y(x) = 1.04083408558608 10   ,
    [                                                      

       d                          ]
      --- y(x) = -1.41421369774756]
       dx                         ]

Notice that the print command in not executed.
If instead I say
> nan1 := dsolve({eq, y(0) = 1, (D(y))(0) = -1}, numeric, events = [[y(x) = 0, [z = x*y(x), halt]]])
> nan1(20)
> z
I get z for an answer. No assignment hs been made.
 

@Carl Love 

I struggled with the syntax a bit but I do now understand it and it works in the sense that the program runs and I get a plot. I now have to figure out why the result is so different from the result I get using the at routine of Preben Alsholm (below). That must be do to my sloppiness somewhere.

2 3 4 5 6 7 8 Page 4 of 9