nm

8552 Reputation

19 Badges

12 years, 347 days

MaplePrimes Activity


These are replies submitted by nm

@sarra 

It is better to preallocate memory for the array before using it.

When you do

    bb[i]:=

without pre-allocating bb, the loop becomes inefficient as a new larger bb array has to be created each time.

 

 

If you want just any code, I would think searching google will be much easier and more efficient than posting a question to one forum.  Google will search millions and millions of pages in a fraction of a second, especially since your requirment is so specific and detailed asking for "some code"

your formulas must be wrong then.

You never said where you got the formulas from, or give any link. if you copied them from somewhere, check again.

some hints and smart tricks can be found here

interface(verboseproc=3);

print(exp);

 

 

@Carl Love 

great. Nice function. did not know about "is". it is hidden in the assume help.

"Even without assumptions, is has knowledge about the properties of some mathematical functions"

So, will change all my comparsions to do  IF is(.....) THEN .... from now on.
I just do not like using evalf() so much, it started to feel like I am using Fortran and not a computer algebera system!

thanks

@Alejandro Jakubi 

"I wonder what the Ada feature looks like."

In ada:

  SWAP:
       declare
          TEMP : INTEGER;
       begin
          TEMP := V; V := U; U := TEMP;
       end SWAP; 


http://archive.adaic.com/standards/83lrm/html/lrm-05-06.html
It is a very useful feature. Similar things can be done in C++ by simply writing a nested {}

  main()
 {
   int a=2;
   {
     int tmp=3;  // this has scope only inside enclosing {}
     .....
    }
   ....
 }



@Carl Love 

thanks. I was very close. I tried value(expr) and evalf(expr), but somehow forgot there is also eval(expr).

Help in that page could be a little more clear for newbies. A small example sometimes is worth 1000 words :)

@Carl Love 

thanks, that is good news. Looking at it now. Some Maple expert should consider adding an entry to http://rosettacode.org/wiki/Named_parameters since Maple is missing from there while many other languages are present. This gives one the impression that Maple does not support this feature.

@Carl Love 

Thank you very much Carl this and notifing me about it;

Your new operators worked very well. There was one case where I could not use it. I was using your earlier operator ~= to display the equations as well as expressions before numerical values are substitued in, and when I switched to ~> and removed the () it did not like it for the equation case.

Here it is (assume your operators are defined and restart was done before each example:

v:=10;
eq &= (2*x +v = 5);

changed to


eq <~ 2*x +v = 5;
          Error, `=` unexpected

But this seems to happen for the = operator only from what I have seen so far. So it is not a big deal. I can add () for this one special case, like this

eq <~ (2*x +v = 5);

So I have changed my code to use your new operator <~. I think we should give this operator a name since it is very useful. I suggest the Love assignment operator if it is ok with you.

ps. I do not use Maple too much actually, mainly becuase I do not like the new GUI interfaces, even though I do like the language itself. I liked the old classical interface. I do use it on occasions to compare results with Mathematica (Maple seems really good in solving differential equations) and used it before few times here and there. But I consider myself a newbie in Maple.

You should not need a computer algebra program to do this trivial thing. It is only second order. can be done on the fly easily as we do it by hand.

@Carl Love 

thanks. Those short cuts help.

But as you can see, there is no way,using one command, to insert a new text mode group.

For example, if one is in an execution group, and want to make new text group below it, one must first create new execution group (ctrl-J), then go change it to text mode (Ctrl-T) in order to document something, before starting new execution group below it.

so, what is needed, is new command to insert text mode group (above and below), similar to the Ctrl-J and Ctrl-K, but work for text and not just executable. The bottom line: there is no way to make a new text mode group when one is inside an execution group and using one command only. at least 2 are needed. This is a UI design error.

someone can correct me if I am wrong.

 

@Carl Love Carl, your function is wonderful. I use it now all the time. Nice way to document the computation as it runs. This really should be part of Maple itself.

I was wondering, is it too much work to make it work, when the RHS is an expression, without having to group the expression inside () ?

For example this works:

restart;
`&=`:= proc(f::uneval, expr::uneval)
local x:= eval(expr);
  print(op(1, subs(_f= nprintf("%a", f), _x= x, proc(_f:= expr=_x)
end proc)));
assign(f, x)
end proc:

r1:=10; r2:=20;
x &= (r1 +r2 );

                               10
                               20
                         x:= r1 + r2 = 30

but this does not

x &= r1 + r2;

it gives

                            x:= r1 = 10
                            () + 20

it is not a big deal to put () around everything, but it would be nice it it can be avoided?

thanks again for a wonderful assignment operator.

@Markiyan Hirnyk 

That was really a rude reply by you.

@Carl Love 

thanks, That is very nice. now one can do this:

g&=int(cos(x),x);
                
Something like this should have been build into Maple itself ! You have invented a new useful assignment operator.

@Markiyan Hirnyk 

Sorry, but I do not use document mode or 2D math at all. I use worksheet and classical Maple for input. I also wanted a solution without any clickable calculus :). So that I can run large code and have the output to look at later. I mean, I am looking for way to do this using code only. No mouse, and no GUI interface.

thank you

First 63 64 65 66 67 68 69 Page 65 of 71