nm

11368 Reputation

20 Badges

13 years, 39 days

MaplePrimes Activity


These are questions asked by nm

What is a good way to determine, at run time, a free symbol to use inside a proce, so it does not appear the same as one being passed in from outside?

Here is the problem. Inside a proc, user calls it with an ODE. The independent variable is passed in as the argument called x

Inside this proc, it does change of variables to do something else.  If the proc uses say as the new variabe, this could be the same as the passed in argument in the way it appears when being printed out to file.  

I know the local symbol is not the same as the passed in symbol, even if that happend to be also. As one is local and the other is not. So the math will still work, but the display will look very confusing to the user.

But since I am printing these out, these will show the same. 

So I need a way to make symbol inside proc, which looks different from the one being passed in.

An example will show the problem. 

foo:=proc(ode::`=`,y,x)
local t; #hoping this will not be the same looking as actual x
return PDEtools:-dchange({x=t^2},ode,t)  
end proc;

Now it is called as

ode:=diff(y(x),x)=sin(x);
foo(ode,y,x)

Which gives

The above worked, because the independent variable being passed in happend to be x

But if the proc was next called using global as the independent variable

ode:=diff(y(t),t)=sin(t);
foo(ode,y,t)

The output will be the same. Which looks confusing.

I want the out in this case to be using different letter than t, say z

The point is, the proc needs to use different looking symbol. Since it does not know which symbol the user is using, currently I use Z  since this is not likely to be used as independent variable by a user. most odes use x or t or z as independent variables

Again, this is all for display purposes, as I am printing these out, and want to avoid using the same looking symbol.

What is a good way to come up with symbol that does not look like the one being passed in?   The option of the user passing in the extra variable to use for this is not possible at all, as this is done deep inside and asking the user to pass in the spare symbol to use is not possible.

 

 

For last 4 hrs, I've been chasing this problem.

Inside a module, there is a proc with a name say foo().

It is local to the module. When creating an .mla file that contains this module which was read from .mpl file, and running a test against it, Maple does not see this specific proc foo() as a proc, but only sees it as a symbol.

So the call to foo() never happens (error is generated).

I have a print statement inside foo() also which never prints. In the debugger, when I try to step into foo(), it fails also. Maple simply does not see it as a proc.

I also added my_module:-foo() in call, but this made no difference, even though it is not needed to prefix the module name, since foo is a local proc.

Now, instead of making an .mla, I now just read the .mpl file directly which make up the module. And now run the same test, and now maple see foo() as proc and the test runs with no error.

No change in the code at all. Nothing changed, exacept the test is called one time when package is inside the .mla vs. just using plain .mpl files.  The module has option package on it.

It seems something goes wrong with symbol table when inside mla file.

When I do 

libname := currentdir(), libname;
LibraryTools:-Browse()

And browse the content inside my mla file, I see no problems, it lists all 24 procs inside the package, and I can see foo listed there as type PROC.

But in the code, what printing whattype(foo)  it says it is symbol when using mla file, but it says it is a procedure when not using mla, but just by reading the .mpl file which went into the .mla

I will try to make an example to reproduce this if I can. But has any one seen something like this before? What could cause this?  I've restarted Maple ofcourse, and this made no difference.

The way I build the mla is

FileTools:-Remove(cat(currentdir(),"/my.mla"));
LibraryTools:-Create(cat(currentdir(),"/my.mla"));

read cat(currentdir(),"/my_module.mpl");
LibraryTools:-Save('my_module',"my.mla");

For now, I will stop using .mla and just read the .mpl file each time to use the code, as this seems safer and this always worked and never gave any problems.

The code is large. I also use database. So I am not sure I can make a small example but will try.  

I am using 2020.1 on windows 10.

I am not able to use Maple's map() to do the following. Given 2 lists of things (of equal length), map a function that take 2 arguments, from these 2 lists, in order.  Here is an example to illustrate. In Mathematica

a = {1, 2, 3}; b = {7, 8, 9};
MapThread[f, {a, b}]

           {f[1, 7], f[2, 8], f[3, 9]}

In Maple, I tried map and map2, map[n] etc.. not able to get the result I want. I want to use map, and not ~

A:=[1,2,3];
B:=[7,8,9];
map((x,y)->f(x,y),A,B)

          [f(1, [7, 8, 9]), f(2, [7, 8, 9]), f(3, [7, 8, 9])]

 

map[2]((x,y)->f(x,y),A,B)

           [f([1, 2, 3], 7), f([1, 2, 3], 8), f([1, 2, 3], 9)]

and other things.

How to get same result as MapThread, using map?

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? 

 

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