nm

11353 Reputation

20 Badges

13 years, 20 days

MaplePrimes Activity


These are questions asked by nm

I did not know about these before. Was looking at 

https://fr.maplesoft.com/support/help/Maple/view.aspx?path=repository/management

And wanted to display the actual values of $MAPLE,$TOOLBOX, $VERSION,$HOME gives about. 

But everything I tried does not work. 

anames('environment');
getenv("$MAPLE");
print("$MAPLE/toolbox/$VERSION/$TOOLBOX/lib")

Where are these things defined and how to display them from inside Maple to see where they point to?

 

Maple 2020.1 on windows 10

 

dAlembert ode has the form

https://fr.maplesoft.com/support/help/Maple/view.aspx?path=odeadvisor/dAlembert

Which also agrees with textbooks and Wikipedia

 

https://en.wikipedia.org/wiki/D%27Alembert%27s_equation

 

 

So the ODE should have   x  in there (the independent variable).  

Then why  in the following, when I give Maple ode of form   y=f(p)+g(p)  it says it is d'Alembert? notice that there is no x in there

restart;
ode:=y(x)=ln(cos(diff(y(x),x)))+diff(y(x),x)*tan(diff(y(x),x))

DEtools:-odeadvisor(ode)

I am not saying Maple is wrong, as I am not sure, but I am just trying to understand what is going on. All references I've seen so far say x should be there.  Otherwise, how did Maple determine it is dAlembert if not using the orginal form to check against?

The strange thing is calling dsolve on the ode, with no option gives different answer if calling dsolve telling it is is dAlembert:

dsolve(ode,[dAlembert]);

but

dsolve(ode)

Why it did not give the same result? 

 

I noticed the following. I have 2 worksheets. A.mw and B.mw.  From A.mw, it does something as follows

libname := currentdir(), libname
foo();

Where foo() is entry inside my say TMP.mla in currentdir(). This works fine with no problems and foo() executes and complete OK.

Now I make changes to the code foo.mpl, and need to update TMP.mla. currently I use LibraryTools. But i'd like to delete TMP.mla each time and create new one so I am sure there is no problem. So from B.mw I run this code

libname:= currentdir(),libname;
FileTools:-Remove("TMP.mla");
LibraryTools:-Create("TMP.mla");
read "foo.mpl";
LibraryTools:-Save('foo',"TMP.mla");

This all works well, except it fails at the Remove line, since "TMP.mla" could not be removed, since it was open before when running the A workseet, and it seems to be still open and Maple could not delete the file.

So each time this happens, I close all worksheets, close Maple, open Maple again, and now I can run the above code OK to update the mla.

Is there a better way to do all of this?

I worry if I do not delete the mla each time, I could end up with old code there I do not want, if I rename things in my code. That is why I like to start with fresh mla file each time.  But I always have to restart Maple now to update the mla.

 

from help, it says 

The expression assuming property calling sequence evaluates the expression under the assumption property on all names in expression.

Then why 

restart;
expr := Sum((-1)^n - 1, n = 1 .. infinity):
simplify(op(1,expr)) assuming n::even;

does not simplify expr to zero, while

restart;
expr := Sum((-1)^n - 1, n = 1 .. infinity):
assume(n::even):
simplify(op(1,expr))

does simplify expr to zero.


I would have expected both to give zero. 

 

Having read-only, public proprty of class is very useful. But I am not able to see if Maple supports this.

The idea is to have an object with public variable that can only be read from outside. But to change it, one must call a setter() method.  The advantage of this over having a getter() method to read the variable back is that it simplifies the code and makes it easier to read.  

There is good discussion here on this subject https://www.python-course.eu/python3_properties.php  

and https://en.wikipedia.org/wiki/Property_(programming)  :


"A property, in some object-oriented programming languages, is a special sort of class member, intermediate in functionality between a field (or data member) and a method. The syntax for reading and writing of properties is like for fields, but property reads and writes are (usually) translated to 'getter' and 'setter' method calls. The field-like syntax is easier to read and write than many method calls"

 

In Maple, if I make the variable inside the object an export then now one can not only read it, but also change it from outside. I want to allow only reading from outside. Here is an example

restart;
module my_class()
  option object;

  export name::string; #made it export to allow direct reading
 
  export set_name::static:=proc(o::my_class,name::string)
      o:-name := name;
  end proc;

end module;

And now one can do

o:=Object(my_class);
o:-set_name(o,"me");
o:-name;  #read it

But one can also change it from outside by doing o:-name:="new name";  and this ofcurse breaks the whole idea of encapsulation.

I think allowing reading only of object variables is OK and many OO language allow this. They are called properties.

If the variable above is made local, then one can not read it directly, and a getter() method is needed for each object properties, in addition to setter() method.

Is it possible in Maple to make local object variables read only from outside? If not and if Maplesoft wants to improve its OO, this will be something useful to add for next version.

First 117 118 119 120 121 122 123 Last Page 119 of 199