nm

11413 Reputation

20 Badges

13 years, 72 days

MaplePrimes Activity


These are replies submitted by nm

@lcz 

Instead of 

subs((5435 + 3*sqrt(515793))^(1/3)=t,s1)

You could try

simplify(subs((5435 + 3*sqrt(515793))=t^3,s1))

@Carl Love 

The solve evaluates to NULL

But I checked before. On 2020.1 

solve(x^2+a=0,x) assuming a>0

But I do not understand exactly what you mean by "Arguments are evaluated before being passed"

If solve is evaluated before being passed to timelimit, then what is the point of using timelimit in first place?

The whole reason to use timelimit is to prevent solve evaluation  from taking a long time? I must be missing something about what you are saying here.

But now I always add [ ] around solve inside timelimit. This has fixed things.

@Carl Love 

Thanks for your nice code example. It was useful to learn from.

But I was worried that if Maple introduce D(x),D(y),D(z), etc... as build-in operators, then many problems will start to result from users abusing this. For example, when I called your function using

ode:= -(x^2+x*y(x))*(D(x))^2 + D(y(x)) = 0:
convert(ode, standardODE);

ode:= -(x^2+x*y(x))*ln(D(x)) + D(y(x)) = 0;
convert(ode, standardODE);

I can come up with 1000 more such examples.

Ofcourse you could argue that the input should mathematically make sense to start with, but that is my point. Users can now type anything and abuse this notation to the limit and then expect Maple to figure what they meant.

Maple would have to do 100 times more work to parse the input to check it represents a valid differential equation since the D(x) and D(y) have been separated apart and they can be anywhere and inside anything. For example, What if there is an extra D(y) with no matching D(x), what does that mean mathematically?

If the purpose for the user wanting this notation, is to enter a differential equation, then they should simply use diff(y(x),x) standard notation. If the purpose is for something else, the OP did not explain why they needed this notation for. 

I just do not see the benefit gained from this complexity. I do not know of any CAS that supports such operations. May be there is a good reason why that is. 

 

no, there is no such thing, and there will never be such thing in CAS. It makes little sense and will cause all sort of problems.

Simplify write the ODE as normal using diff(y(x),x)

 

@Scot Gould 

but you did not mention the most important thing: did it autoscroll for you? i.e. when the print lines reach the bottom of the screen the first time, does it autoscroll so the last line being printed always shows up at the bottom of the screeen without having to manually scoll down to see it?

The whole reason I try to grab the bar on the right with the mouse, is to try to chase those lines being printed so I can see the last lines so I know the progress of the program.

 

@baharm31 

 If I add numeric I get an error.

I get no error on 2020.1

restart;
ode1:=-diff(q(t), t) - 1.851851852*10^(-7)*q(t)*(2.042885233*10^10 - 3.517396152*10^18*(0.00001474262739*cos((1000*sqrt(1122)*t)/33) + 0.00001474262739*sin((1000*sqrt(1122)*t)/33))^2) + 9.259259260*10^(-7):
ics := q(0) = 2.45*10^(-12):
sol:=dsolve({ode1,ics},numeric)

it works. I'll leave it up to you to check if the numerical solution is OK or not, as you know more what the solution should be. 

@mehran rajabi 

You can add assumptions to help Maple. Updated.

how is first  bc := q(-y) = 0, q(y) = 0  supposed to be boundary conditions?  since q is the dependent variable of the other ode. and the second bc bc1 := u(-y) = 1, q(y) = j  here is the dependent variable from first ode. These BC do not make sense to me.

You can solve the ode without BC (need to fix the first one as well to change q to q(y)

restart;
ode := xi*diff(q(y), y, y) - N*diff(u(y), y) - 2*N*q(y) = 0;
ode1 := (1 + N)*diff(u(y), y, y) + N*diff(q(y), y) = p;
dsolve([ode,ode1],[q(y),u(y)]

I am really just curious, how would you suggest Maple should decide if f(x) is meant to be f*x  vs being just a normal function call f(x)?

@acer 

"I don't really understand why you want big_car:-set_name declared as static, "

Well, Maple help says to make all object methods static, to avoid making copy of them each time a new object instance is created. 

But in your solution, you changed the sub-module to become Object class. But this will now require changing all the signatures of its methods to use ::static, and not only that, but also adding the object name to each internal method API.

Which means changing 10's of internal API's inside the submodule and each call as well, which will break things.   

I also do not need to make instances of those modules, so making them Objects is not logically needed. I simply wanted to use the code they provide  from inside the object, but as private or local modules to the Object class.

But I ended up with just keeping them as separate modules for now. Like this

restart;	
module car_class()
      option object;
      local name::string :="UNKNOWN";

      export set_name::static:=proc(o::car_class,_name::string)
        o:-name := _name;
        big_car:-set_name(_name);
      end proc;

end module:

#separate module.
big_car :=module() 
   local big_car_name::string:="UNKNOWN";  

   export set_name :=proc(_name::string)
       big_car_name:=_name;
   end proc;        

end module;

This ofcourse works.

Only disadvantage is that big_car is module on its own, while before it was submodule or local module. 

So it is now not private to, or child to the object.

But it is not a very big problem for now. This way I do not need to modify many many API's just to make these modules child to the object. 

But thank you  for the suggestion.

It might be better to explain what the algorithm does (i.e in words. What is the input and what is the output, and short description. A small example is also good) and then try to write it from scratch the Maple way, instead of trying to write it as Maple++.  This is always the best way to do such things.

 

@Carl Love 

This is another reason why the common object:-method(args)  is better than method(args,..,object,...args) used by Maple.

In the first case, there is no ambiguity of the name scope of the method, as it clearly bounded to class of the object.  by just looking at the call.

In the second case, Maple has to parse the whole call, scan all the arguments one by one, looking for an object somewhere there, then look into the class/type of that object, and then see if the method belongs to that class or not. 

Maple did not do that, and just saw process as external command name, and not  a name inside the class of the object.

So now in Maple one has to write this somewhat convoluted code instead

                  object:-method(object,args) 

Since object:-method(object,args) works, then I wonder if Maple could add feature to its OO in next version to allow the use of just object:-method(args). Saving one having to type the object name in two places. each time. I don't like redundancy and duplication as it can cause errors.

 

@itsme 

I agree. I also noticed the same thing. It would be much better to have the object as the first argument.

Btw, in Ada programming language, when they first added OO to the language (I think this was in 1995), they did not use the Object.method(args)  initially either, and many people complained but they used method(object,args)

Then in Ada 2005 version I think, they finally added the dot notation so one can now do Object.method(args)  instead, which is more natural for me because in OO one thinks of the object first as the central thing, then its methods, not the methods then the object. May be Maple could not find a good way to do object.method. They run out of keyboard keys to use for the "dot" operator as ~,->,:-,.,::,%,@ etc.. are all used in Maple already for other things.  

 

@Carl Love 

I am learning OO in Maple. I have not looked at it much before.

But one thing I find a little awkaward, is that one can not use the object.method(arg) notation, common in all OO languages, but have to use method(arg,object). Which is a little strange for OO programming, and will take a while to get used to. For example

restart;
module car_class()
      option object;
      local name;  #private

      export set_name::static:=proc(name::string,o)
          o:-name := name;
      end proc;

      export get_name::static:=proc(o)
          return o:-name;
      end proc;      

end module;

my_car:=Object(car_class); #make an object of class car

and now to set the name and get the name:

set_name("toyota",my_car);

get_name(my_car)
      "toyota"

It would be much more natural to do something like   my_car[set_name]("toyota") or my_car:-set_name("toyota")

And then my_car:-get_name() since in these, the object itself is upfront, instead of being passed as an argument.

It would be best to use the dot notation ofcourse, but that would probably break many things. So one could write my_car.set_name()  which is what Java/Python, and many other OO languages use, but this is asking too much in Maple.

But it is nice to have OO in Maple.

 

 

@Preben Alsholm 

 

I am not able to understand what this means. The index variable i is NOT private to the seq invocation.  It is recommended that you always explicitly declare the index variable to be local inside procedures.

What procedure is this?  When doing this 

seq(expression, i = integer1..integer2

how is one supposed to declare `i` as local? There is no procedure here anywhere.  (if this was inside a proc, sure, I can say local i; ) 

And how to apply this to the example given?

seq(%, x[j] in L);

 

 

 

First 55 56 57 58 59 60 61 Last Page 57 of 91