casperyc

962 Reputation

10 Badges

16 years, 226 days
University of Kent
Dr

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by casperyc

Here is a brute force way, using loop:

 

mytest:=proc(C)
    local i,ans;
    
    ans:=s[C-1]*w[C]+s[C]*w[C-1];
    for i from C-2 by -1 to 2 do
        ans:=ans*s[i]+w[i]*mul(s[j],j=i+1..C);
    end do;

    if C>2 then ans:=ans*s[1] end if;

    return ans;

end proc;

 

I wonder if there will be a more efficient way, using the "", as I originally thoght in the post.

It might be more efficient than a loop?

Also, I am trying to come up with a normal mathematical expression with it using the summation and product symbol.

 

thanks,

 

Casper

If you select the graph, go to "Edit" menu, "Remove output"--> "From selection". That should work too.

I think 'add' works. At least works for my problem at the moment.

But if there is a 'better' or 'right' solution. Please do let me know.

for i to 300 do
if isprime(i) then print(i) end if;
end do;

Hi,

Dont think they are saved anywhere. You usually have to "save" them before you close Maple.

Otherwise, you loose the worksheet.

 

 

Just a final check, "with" would be performed globally no matter where it is used and "uses" should be used within procedures.

Say for the LinearAlgebra package, it is needed for many of the procedures that I write, do I load it at the beginning with "with(LinearAlgebra)" or use it within procedures as "uses"? Which one is good practise? or more efficient (fast)?

Many thanks for all your reply.

Casper

Hi Adri,

Thank you for you answer. That was very helpful.

 

Now, the next thing to consider is that I want to computer a 'weighted' mean.

See my worksheet. new2.mw

In the end of the file,

>par:=w1*parC1+w2*parC2+(1-w1-w2)*parC3;

is the desired output.

 

I have tried to write a procedure ( getpVec ) for it, but I am stuck. I think it might be a problem of declaring variables.

Since the p[i,j] are NOT declared in 'local' in getpVec.

Any help would be greatful.

 

Many thanks.

 

Casper

 

I want it to have two decimal places like this:

8005.15
1781.15
  198.15
    14.70
      0.82

(the decimal point need not to be aligned)

 

Thanks.

 

================================

poi:=x->exp(-0.2225)*0.2225^x/x!;

for i from 0 to 4 do > evalf(poi(i)*10000,2) > od;

================================

 

That's the code. It didnt display correctly.

 

Thanks

It's so difficult to decide which one to use now.

In my procedure, sometimes, the 'subsop' is faster anda bit more memory consume, sometimes, it's slower and less memory consume.

However, the time difference is small, so I might use 'map' in my project.

Thanks.

casper

the option "skiplines" seems to be taken away 'some' rows. However, what I wanted is to taken away a specific colum(s).

Thank you.

 

casper

Download 7845_thisone.mws
View file details

Hi,

I got a new problem in multiplying them in mod 127

I used the command

Multiply(127,TextMatrix,enMatrix);

both of which are Martix type.

they just wont multiply..

 

Thanks.

Casper

i hope maplesoft can come up with a better solution to solve the Highlighting problem in latex.

Or someone can write a Macro for latex listings environment for that.

Thanks.

casper

thanks

i will look into it.

 

casper

after nearly half an hour of trying

 

'   "   `` and ""

 

finally saved

 

for i from 1 to 3 do
 save i, `a_`||i||``
end do;

1 2 3 4 5 Page 1 of 5