vv

13977 Reputation

20 Badges

10 years, 38 days

MaplePrimes Activity


These are answers submitted by vv

For programming the solution is to use neutral operators.

`&x` :=LinearAlgebra:-KroneckerProduct;
A := <a,b;c,d>;
B := <1,2;3,4>;
A &x B &x A;

 

 

It works if you correct  2x  to  2*x.

Let f be a superposition of two functions f1, f2 . i.e. f(x) = g(f1(x),f2(x)) .

If f1 has period T1 and f2 has period T2 then f will have generally as period the lcm of T1 and T2, provided that T1, T2 are commensurable (i.e. T1/T2 is rational).
In your example we must know Omega. E.g. for Omega=1 the function is not periodic.

CommonPeriod:=(T1::Not(0),T2::Not(0)) -> `if`(type(T2/T1,rational), abs(numer(T2/T1)*T1), infinity);

For example, the function    cos(4*x) + sin((3/2)*x)     will have the period
CommonPeriod( 2*Pi / 4,  2*Pi / (3/2));
      4*Pi

A convert and a correct assumption are needed.

simplify(convert(exp(I*t)^q, exp)) assuming t > -Pi, t <= Pi, q > 0, q < 1;

 

 

Why don't you use the monomial order lexdeg([x,y,z], [u,v,w]) ; it is used exactly to eliminate x,y,z.

Your monomial order can be obtained:

t2:=plex(u,v,w);  t1:=wdeg([1,1,1,0,0,0],[x,y,z,u,v,w]);

t:=prod(t1, t2);  # your order

 

 

sat:=a -> satisfies(u -> (op([0,0,0],u)=D and op([0,1],u)=a)):
difford:= (e,a) -> max(nops~(map2([op],[0,0,..],indets(e,sat(a))))):

# Example
expr:=(diff(a(x, y), x, y))*x*y+(diff(a(x, y), x, x, y))*x+diff(b(x, y), x, x)-sin(z):
expr:=convert(expr,D):

has(expr,a); # depends on a?
                              true
has(expr,c); # depends on c?
                             false
difford(expr,a);
                               3
difford(expr,b);
                               2

 

For example, the principal branch with ~ 3 digits accuracy, for x>0:

W = 1.45869*ln(1.2*x/(ln(2.4*x/(ln(1+2.4*x))))) - 0.45869*ln(2*x/ln(1+2*x))

 

You probably know that  f(n) = O(g(n))  means  limsup( f(n)/g(n), n=infinity) < infinity

provided that f,g>0  and  n -->oo.

Now, Maple does not have limsup; we shall use limit instead (in most cases it's OK).
So, your "equation" is equivalent to

limit( (n^2/2 + 2*n - 1)/n^2, n=infinity ) < infinity;
        1/2 < oo
It is true. What do you want to solve here? Do you mean prove?

 

 

LinearAlgebra works fine. You must know that it uses Matrix and Vector (capital M and V) instead of the old matrix and vector.
I suspect that you have used matrix. If this is not the case, please post your example.

The equation is equivalent to

x ln(x) = ln(4) + 2n Pi I <==>  ln(x) exp(ln(x)) = ln(4) + 2n Pi I <==>

ln(x) = W(m, ln(4) + 2n Pi I)   and  Im( W(m, ln(4) + 2n Pi I) )  in (-Pi , Pi].

Here m,n are integers.

But  Im( W(m, ln(4) + 2n Pi I) )  in (-Pi , Pi]   iff  m=0  (for n in Z).

Note that m is an arbitrary integer if all the branches of the logarithm (or equivalently of x^x) are considered.

BIN:=module()
export ModuleApply, Fac, Fac1;
local pmax:=trunc(2^((kernelopts(wordsize)-1)/2));

Fac:=proc(n,m,p)
  local r:=1,k;
  for k from n to m do r := irem(r*k,p) od
end:

Fac1:=proc(n::integer,m::integer,p::integer)::integer;
  option autocompile;
  local r::integer:=1, k::integer;
  for k from n to m do r := irem(r*k,p) od
end:

ModuleApply := proc(N::nonnegint, K::nonnegint, p::prime)  # combined with Carl's
local r:=1, n:=N, k:=min(K, N-K), Bin, fac:=`if`(p<pmax,Fac1,Fac);

Bin:=proc(N,K)  # 0 <=K < p, 0 <= N
local k:=min(K,N-K);
if k<0 then return 0 fi;
fac(N-k+1,N,p)/fac(1,k,p) mod p
end;

if k<0 then return 0 fi;
while k > 0 and r > 0 do 
   r:= irem(r*Bin(irem(n,p,'n'), irem(k,p,'k')), p) 
od;
r
end:

end module:

p:=nextprime(8*10^7): n:=p*2-1:  k:=floor(p/2):
CodeTools:-Usage(BIN(n,k,p));

memory used=2.97MiB, alloc change=0 bytes, cpu time=1.89s, real time=1.88s, gc time=0ns
                            80000022

p:=nextprime(9*10^8): n:=p*2-1:  k:=floor(p/2):
CodeTools:-Usage(BIN(n,k,p));

memory used=2.11KiB, alloc change=0 bytes, cpu time=20.78s, real time=20.78s, gc time=0ns
                           900000010

NOTE. The compiler works for p < 3.037*10^9. For p greater than that, BIN uses the non-compiled Fac but then k should be smaller (or at least the reductions via Lucas' theorem) to have reasonable execution time. The magnitude of N is not important.
 

The following simple procedure is much faster for p>N.
Note that it requires K<p but can be adapted for this case too.

 

restart;

Fac:=proc(n,m,p)
local r:=1,k;
for k from n to m do r := irem(r*k,p) od
end:

Bin:=proc(N::posint,K::satisfies(n -> (n::nonnegint and n<p)),p::prime)
local k:=min(K,N-K);
`if`(k<0, 0, Fac(N-k+1,N,p)/Fac(1,k,p) mod p)
end:

 

`mod/Binomial`:= proc(N::nonnegint, K::nonnegint, p::prime)
description "Computes binomial(N,K) mod p, p::prime, by Lucas's theorem";
option
   author= "Carl Love <carl.j.love@gmail.com> 30-Oct-2018",
   reference= "https://en.wikipedia.org/wiki/Lucas%27s_theorem"
;
local r:= 1, n:= N, k:= min(K, N-K);
   while k > 0 and r > 0 do
      r:= r*irem(binomial(irem(n,p,'n'), irem(k,p,'k')), p)
   od;
   r mod p
end proc:

 

aa:=800000;bb:=500000;
pp:=nextprime(aa);

800000

 

500000

 

800011

(1)

CodeTools:-Usage(Bin(aa, bb,pp));

memory used=13.75MiB, alloc change=-2.00MiB, cpu time=484.00ms, real time=489.00ms, gc time=218.40ms

 

494383

(2)

CodeTools:-Usage(Binomial(aa, bb) mod pp);

memory used=35.43GiB, alloc change=91.49MiB, cpu time=81.78s, real time=74.28s, gc time=45.05s

 

494383

(3)

 

macro(ff=2*a*b-3*a-2*b-c):
f:=(a,b,c)-> `if`(ff<=30 and ff>=15,ff,0):
A:=Array(0..10,1..5,0..1,f, storage=sparse):
indices(A,pairs); # or simply inspect the Array using the matrix browser

(10, 3, 1) = 23, (7, 4, 1) = 26, (5, 4, 0) = 17, (4, 5, 1) = 17, (9, 3, 0) = 21, (8, 3, 1) = 17, (4, 5, 0) = 18, (6, 4, 0) = 22, (5, 4, 1) = 16, (8, 3, 0) = 18, (10, 3, 0) = 24, (5, 5, 0) = 25, (7, 4, 0) = 27, (5, 5, 1) = 24, (9, 3, 1) = 20, (7, 3, 0) = 15, (6, 4, 1) = 21

Vector needs a procedure (with 1 argument) as initializer.
fenq  is such a procedure but  fsenq(2.1, j)   (actually you mean fseqn) is not; it's an expression.
So, use

psf := Vector(5, j->fseqn(2.1, j));

or maybe the more "sophisticated"

psf := Vector(5, curry(fseqn, 2.1));

 

 

The roots of integer numbers are not automatically simplified. Not even 4^(1/2). It is by design.
Unfortunately it is hard to find in the help pages "automatic simplification",  even if the Programming Guide contains information about this important aspect.

First 62 63 64 65 66 67 68 Last Page 64 of 120