awass

261 Reputation

10 Badges

16 years, 282 days

MaplePrimes Activity


These are replies submitted by awass

@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.

@Preben Alsholm

When you say the first line is most important I take it you do not refer to  local x:=evalf(xx);  but to

  if not type([x,yy],list(realcons)) then return 'procname(_passed)' end if;

(I can get away with out the evalf)


Is the original problem( that your version solves) the fact that odeplot tries to evaluate its arguments before generating the solution?

@tomleslie You are right that f(y) is the numerical solution to an ode that is solved by dsolve.  The command odeplot can access f(y), diff(f(y),y)  and plot them. It can also plot functions of those solutions like f(y)^2 +  y^3 diff(f(y),y) and plot them. There is no need to access them other than by name.
Most importantly, odeplot has no problem with the command

> odeplot(nans, [[y, arctan(diff(f(y),y)/(f(y) - Pi/2)) ]], y = 0 .. 6);

 

which is almost identical to the command I want. It seems clear to me that the problem lies with the if clause in the at procedure.

@Carl Love That clears things up; thank you.

@Kitonum Thanks for your response.

I understand now that evalc is the command I need and that does in fact do the job.

 

However, the solution expand(Re((2-I*X)^4)) assuming X::real; is very mysterious.
(Note Re(expand(((2-I*X)^4)) assuming X::real; also works. )

It tells Maple to take the real part of the expression and then expand it? Whats to expand? After the real part has been taken the job is done. My alternative, to expand and then take the real part makes more sense. I wonder what Maple is doing.

@Rouben Rostamian  Thanks for your response. The transform command is exactly what is needed.

@Markiyan Hirnyk Thanks for your response. It is true that you  can(usually) break up the original curve into pieces that can be paramterized and then use that paramter together with parameterplot. And as you show, it can be quite a bit of work to pull t off. Furthermore, a curve might have places that cannot be so paramterized. The transform command takes care of thses problems directly.

@Markiyan Hirnyk

Sorry if that was not clear.

Let me try an example in 2 dimensions-there is less typing.
 

Suppose we have curve C given implicitly by the equation. s^6 + s t^5 + t^8 =1 or some such. Suppose also we have functions x(s,t), y(s,t) given by some equations like x= t cos(s+t^2) , y= s^3-sin(t). Can I plot the curve x(s,t), y(s,t) for (s,t) in C?

My previous example was in 3 variables and I had k(r,a,b) = 0 which defines a surface S.  The function k was complicated: r sqrt(1-r^2)( cos a cos b) etc I  wanted to plot a surface in x,y,z space where x = x(r,a,b) was a bit complicated. Sorry if that was not clear.

 

the equation k is x1 x2 - y1 y2 = 1/4  in 4 space variables.

The surface lies on a sphere of radius 1 so x1^2+x2^2+y1^2+y2^2=1.

 

One cannot plot in 4 space so I wrote x1= r cos a, y1=r sin a,

x2= sqrt(1-r^2) cos b, y2= sqrt(1-r^2) sin b and plugged that in to get a function K(r,a b ) =1/4.

(Note that this reduces the number of variables to 3.)

My intention was then to take the r,a,b values from the implicit3d plot and plot3d those using 

x1= r cos a, y1=r sin a,

x2= sqrt(1-r^2) cos b, y2= sqrt(1-r^2) sin b. Hence my question.

 

I say that I wanted to plot that but there is a simple workaround, namely

I project to R^3 stereographically via
x=x1/(1-y2), y=y1/)1-y2), z=2x2/(1-y2)

Then  I can express k interms of x,y,z  via s = x^2+y^2+z^2, x1= = 2x/(1+s), y1= = 2y/(1+s), y1= = 2z/(1+s), y2=( -1+x^2+y^2+z^2)/(1+s) to get an equation in K(x,y,z) = 1/4 and implicit3d plot that directly.

But since the issue came up I thought I'd ask.

2 3 4 5 6 7 8 Page 4 of 9