nm

8552 Reputation

19 Badges

12 years, 349 days

MaplePrimes Activity


These are questions asked by nm

For the function coulditbe it says

The environment variable _EnvTry can be used to specify the intensity of the testing by the is and coulditbe routines. Currently _EnvTry can be set to normal (the default) or hard. If _EnvTry is set to hard, is and coulditbe calls can take exponential time.

But how does one know the current value of _EnvTry which is supposed to be set to normal.? If I do   _EnvTry it does not show any value.  And when I do 

anames('environment');
anames('environment','active');

I do not see _EnvTry even listed.  I wanted to make sure I am setting it correctly.

Is it enough to do this?

 

foo:=proc()
 _EnvTry:='hard';
  #now use coulditbe, it should use hard value?
  #coulditbe(....)
end proc;

foo();

Would the above actually tell coulditbe to try hard? I wanted to use this inside a proc without affecting any global setting it might have. It is not possible to tell by just calling it if it actually using the hard option or not.

I do not think I am setting this right, I just tried

foo:=proc()
 _EnvTry:='hard';
 _EnvTry:='XXXX';
  #now use coulditbe, it should use hard value?
  coulditbe(1=2)
end proc;

And it did not complain or anything. Any value I put seems to work. I must be not setting this correctly as coulditbe does not complain.

I wish help would give example usages. But Maple help is not good at all as it has no usage examples to help users.

btw, I think the use of environment variables is bad in programming.

Each function should instead accept options as argument and one should set an option explictly.  So coulditbe should have an explicit optional argument to pass it. This makes the code more clear when looking at the call also.

Programming environment variables are just like global variables.

Bad way to program as in large program one can lose track of these settings.

I am not able to make a MWE for this error, as it only shows in the debugger. So it seems Maple internal memory changes or some other library is loaded to cause this. Inside the debugger, I get to a function which does this

DBG> simplify(JacobiDN(x,k)^2*n)

Error, invalid input: simplify/Jacobi/JacobiDN expects its 1st argument, k, to be of type posint, but received 0

Version 2023 on windows 10

In a worksheet, the above works just fine

restart;
simplify(JacobiDN(x,k)^2*n)

Back to the debugger, if I write (2*n) instead of 2*n, then the error goes away

DBG> simplify(JacobiDN(x,k)^(2*n))
JacobiDN(x,k)^(2*n)

The values of x,k,n are all symbols and have no values in the code running:

I have no idea why this happend when I run the code only. It think x is zero in the above for some reason.

Sorry can't make MWE, I wish I can. Something strange happens when I run the code that does not show otherwise. 

Any suggestions how to invetigate this more? Stepping into the simplify code it fails in

DBG> next
`simplify/check_constant`:
   3   return type(r,'And(constant,Or(Not(function),satisfies(f -> evalb(op(f)
         <> NULL))))')

DBG> r
JacobiDN(x,k)^2*n^2

DBG> type(r,'And(constant,Or(Not(function),satisfies(f -> evalb(op(f)          <> NULL))))')
false

DBG> step
`simplify/Jacobi`
`simplify/do`:
  84               userinfo(1,simplify,'applying',new_simp,
                     `function to expression`);

 85               new_r := new_simp(r,symb_mode);  

Here it generate the error.


It has nothing to do with simplify. Here is a call to integrate which gives same error

DBG> lhs(ode)
diff(diff(xi(x),x),x)-k^2*JacobiSN(x,k)*JacobiCN(x,k)/JacobiDN(x,k)*diff(xi(x),x)+(-k^2*JacobiCN(x,k)^2+k^2*JacobiSN(x,k)^2-k^4*JacobiSN(x,k)^2*JacobiCN(x,k)^2/JacobiDN(x,k)^2-JacobiSN(x,k)^2*k^2*n^2+n^2)*xi(x)

DBG> int(lhs(ode),x)
Error, invalid input: simplify/Jacobi/JacobiDN expects its 1st argument, k, to be of type posint, but received 0

DBG> x
x

DBG> k
k

DBG> xi(x)
xi(x)

 

Maple 2023 still can't verify its own series solution. This happens with Frobenius method when the indicial root are repated. I think I mentioned or reported this long time ago but unable to find a link now.

My question is: Since this looks like it will not be fixed by Maplesoft anytime soon, any one could suggest an alternative method to verify this solution?

restart;

ode:=2*x^2*diff(y(x), x, x) + 2*x*diff(y(x), x) - x*y(x) =0;
sol:=dsolve(ode,y(x),'series');
odetest(sol,ode,'series')

Maple's solution is correct, I solved it by hand and get same solution.

Maple 2023 on windows 10.

Someone added "Duplicate question" tag on this question.

How is this duplicate question? Where is the duplicate question? 

Is this a bug?

Accoding to this help page 

A derived class must not redeclare (via a local or export declaration) any members inherited from the base class

this example does not do this. But derived class gets an error when using ::static on a method declared in base class and this only shows up when using kernelopts('assertlevel'=2):

So it is either kernelopts('assertlevel'=2): is wrong or help is wrong.  Here is example

972100

restart;

972100

interface(version);

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

interface(warnlevel=4);
kernelopts('assertlevel'=2):

3

module bank_account()
  option object;
  local account_id::integer:=0;
  
  export ModuleCopy::static:=proc(_self, proto::bank_account, account_id::integer,$)
         if nargs=2 then
            _self:-account_id := proto:-account_id;
         else
            _self:-account_id := account_id;
         fi;
  end proc;
end module;

module bank_account () local account_id::integer; option object; end module

module saving_account()
  option object(bank_account);

  ModuleCopy::static := proc(_self, proto::saving_account, account_id::integer,$)
         if nargs=2 then
            _self:-account_id := proto:-account_id;
         else
            _self:-account_id := account_id;
         fi;
  end proc;
end module;

Error, (in saving_account) type `static` does not exist

 


Download static_error.mw

Removing the line kernelopts('assertlevel'=2): the error goes away. Also keeping kernelopts('assertlevel'=2): but removing the ::static from the derived class the error goes way.

What is going on?

Maple 2023 on windows 10.

When making a module with option object, help says 

To create a new class of objects, use the named module declaration syntax with option object.

and it gives an example.  But what is the difference from using the standard module syntax?

This seems to work the same but may be there are cases where it makes a difference?  Here is an example. second case below is what help says to use. But first case is the original module syntax. Both work the same in this simple example.

Can one use either syntax, or is there any subtle difference in semantics that will show under more complicated setup?

interface(version);

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

restart;

1421372

person_class:=module()
  option object;
  export foo::static:=proc(_self,$)
    print("in foo");
    NULL;
  end proc;
end module;

o:=Object(person_class);
o:-foo();

_m2325067887584

_m2325067872032

"in foo"

restart;

1421372

module person_class()
  option object;
  export foo::static:=proc(_self,$)
    print("in foo");
    NULL;
  end proc;
end module;
o:=Object(person_class);
o:-foo();

module person_class () option object; end module

module person_class () option object; end module

"in foo"

 


Download syntax_of_OOP_module.mw

First 14 15 16 17 18 19 20 Last Page 16 of 164