vv

13992 Reputation

20 Badges

10 years, 38 days

MaplePrimes Activity


These are replies submitted by vv

@MapleUser2017 

You still have typos: Mylib <> MyLib, Mylib <> MyMat. Why don't you use copy+paste?

Please open the attached file and execute it using the (!!!) icon.

restart;

MyMat:=module()
description "My Package";
option package;
export E1,E2;
E1 := "first export":
E2 := "second export"
end module;

_m620393440

(1)

LibLocation:="C:/temp/MyLib.mla":  # dir with write access

LibraryTools:-Create(LibLocation); # if the library is new; if exists ==> error (to be ignored)

LibraryTools:-Save(MyMat, LibLocation);

####################################

restart;  # check

LibLocation:="C:/temp/MyLib.mla";

"C:/temp/MyLib.mla"

(2)

libname:=LibLocation, libname:

with(MyMat);

[E1, E2]

(3)

E1, E2;

"first export", "second export"

(4)

LibraryTools:-ShowContents(LibLocation);

[["MyMat.m", [2019, 11, 8, 9, 34, 55], 41984, 115]]

(5)

 

 

Download libex.mw

@Rouben Rostamian  

And also:

with(MyMat);

@MapleUser2017 

I suppose that the OS is Windows.

Probably you forgot to "execute" the module definition. Press Enter in its execution group.

1. Do you have the directory C:/temp  ? If not, you must create it (or use an existing one).
2. Do you have MyLib.mla in this directory after executing Save?

You may execute

LibraryTools:-ShowContents(LibLocation);
to see the contents of the library

 


 

 

The builtin method seems to be marginally faster than a simple "square" recursive method.

restart;
pow:=proc(a,n)
     if n=0 then return 1 fi;
     if n::odd then a*thisproc(a,n-1)
     else thisproc(a,n/2)^2 fi
end:
a:=841117; n:=311012;
CodeTools:-Usage(pow(a,n), iterations=100):
CodeTools:-Usage(a^n, iterations=100):

 

@Carl Love 

- No, the integral is from 1 to -1. Our results are the same.

- The integral is independent of the path in {z: Im(z)<0}, the function being holomorphic here. The limit was needed just because of this.

@Christian Wolinski 

The problem is fprintf(output, "%f\t %Zf\t \n", x, b),  not evalf

@Carl Love 

The problem is that the assume facility is not reliable in nontrivial situations.

is(2^n+r, rational) assuming n::integer, r::rational;
                              true
is(2^n+r^2, rational) assuming n::integer, r::rational;
                              FAIL

 

@Christian Wolinski 

Yes, but this was the point: using the current implementation it's impossible to decide whether a real number is real!

@Christian Wolinski 

A clear and proper answer should be true.
FAIL means "I don't know" for an obvious question.

@Carl Love 

A nice find, vote up! When I saw the sequence I suspected that a closed formula should exist. But I am sure that a formal proof is not easy. You should try the Collatz conjecture too :-)

@Kitonum 

Then you probably have the 32 bit version.

@Kitonum 

What version did you use? In Maple 2018/2019 the code does not work due to a well known problem in fsolve.

A workaround for f(1):

F:= s -> int(sqrt(16 + 4*sin(2*t)^2 + 9*cos(3*t)^2), t = 0 .. s)-1:
Optimization:-NLPSolve('F'(s)^2, s=0..10);

[2.88626817600000*10^(-17), [s = 0.203398786591181]]

@tomleslie 

In v426 sol is 0 (the integral in [-Pi,Pi]  is 0), so, incorrect.

@Carl Love 

Nice!
BTW, you mean this?  Rabin-Shallit-Rand-alg-1986.pdf

@Rouben Rostamian  

You are right. When I wrote the comment It was late and I forgot the ilcm in computing the order of the permuataion (I did not use GroupTheory).  Here are the procedures.
 

f:=(n,k) -> piecewise(k<=floor((n+1)/2), n-2*k+2, 2*k-n-1):
P:= n -> [seq(f(n,k), k=1..n)]: # perm
IP:= n -> convert(convert(P(n),Perm)^(-1),list):  # inverse perm
C:= n -> convert(P(n),disjcyc):
N:= n -> ilcm(seq(nops(u), u=C(n))):  # Order
encrypt := s -> cat(convert(s,list)[IP(length(s))][]):
decrypt := s -> cat(convert(s,list)[P(length(s))][]):

But now the cipher seems to be less interesting :-)

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