vv

13822 Reputation

20 Badges

9 years, 315 days

MaplePrimes Activity


These are answers submitted by vv

L:=(u,v)->u(v(f_(x,t)))-v(u(f_(x,t))):
alias(``=f_(x,t));
#########################
v:=f->diff(f,x):
w:=f->x*diff(f,t):
L(v,w);
   

u:=f->x*t*diff(f,x,t):
L(u,w):  simplify(%);

   

I was curious to see how much the compiler can help in such problems.

It seems that in Carl's version (which is very fast) the compiler is not very useful.
I used practically my original version, made compilable.

Here it is:

Tri1:=proc(n::integer,V::Vector(datatype= float[8]),
     X::Vector(datatype= float[8]),Y::Vector(datatype= float[8]),
     Ax::float[8],Ay::float[8],Bx::float[8],By::float[8],Cx::float[8],Cy::float[8])
   local k::integer,a::float[8],b::float[8];
   for k to n do
     a:=V[k]; b:=V[n+k];
     if a+b>1 then a:=1-a;b:=1-b fi;
     X[k]:=Ax+(Bx-Ax)*a+(Cx-Ax)*b;
     Y[k]:=Ay+(By-Ay)*a+(Cy-Ay)*b
   od;  
end:

CTri1:=Compiler:-Compile(Tri1):


Tri:=proc(n,Ax,Ay,Bx,By,Cx,Cy)

local
  V:=LinearAlgebra:-RandomVector(2*n, generator= 0..1., datatype= float[8]),
  X:=Vector(n,datatype= float[8]), Y:=Vector(n,datatype= float[8]);
global Ctri1;
  CTri1(n,V,X,Y,Ax,Ay,Bx,By,Cx,Cy);
X,Y
end:
####
Ax:=-1: Ay:=0:  # Triangle T = ABC
Bx:=0:  By:=4:
Cx:=2:  Cy:=1:
n:=6000:           # number of random points
T:=CodeTools:-Usage(Tri(n,Ax,Ay,Bx,By,Cx,Cy),iterations=100):
memory used=195.55KiB, alloc change=18.38MiB, cpu time=940.00us, real time=920.00us, gc time=0ns

Compare with Carl's version (not compiled)

T:= CodeTools:-Usage(SampleTriangle([[-1,0],[0,4],[2,1]], 6000), iterations=100):
memory used=0.86MiB, alloc change=8.21MiB, cpu time=24.18ms, real time=6.52ms, gc time=1.25ms

Note that I have used iterations=100, otherwise the timing was not stable enough.





 

The definition is simple and clearly presented in the help page.

HeunT is the solution of the differential equation (depending on three parameters):

 

f(0)=1,  f'(0)=0

 

It is an entire function. For other properties:

FunctionAdvisor(HeunT);

Yes, it seems that the numerical algorithm in sum fails here.

But we can verify manually (after a simple estimation of the remainder):

evalf[600]( add( floor((exp(Pi)-Pi)*n)/3^n, n=1..5000) ):
evalf(evalf[600](%-29/2));
     -4.142437940*10^(-531)

Ax:=-1: Ay:=0:  # Triangle T = ABC
Bx:=0:  By:=4:
Cx:=2:  Cy:=1:
n:=4000:        # number of random points

a:=Vector(n): b:=Vector(n):
r:=rand(0.0 .. 1.0):
for i to n do
  x:=r(): y:=r():
  if x+y>1 then  x,y := 1-x,1-y  fi;
  a[i]:=x: b[i]:=y:
od:
u:=Vector(n,1):

plot(
Ax*u+(Bx-Ax)*a+(Cx-Ax)*b, Ay*u+(By-Ay)*a+(Cy-Ay)*b,
symbol= point,style=point,scaling=constrained);

# The distribution is uniform i.e.
# Prob(X in D) = Area(D)/Area(T).

n:=8000:   #ellipse - nonuniform distribution (naive attempt)
a:=Vector(n,i->r()):
b:=Vector(n,i->r()):
plot(3*a*~cos~(2*Pi*b),2*a*~sin~(2*Pi*b),
symbol= point,style=point,scaling=constrained);

a:=sqrt~(a):   #ellipse - uniform distribution
plot(3*a*~cos~(2*Pi*b),2*a*~sin~(2*Pi*b),
symbol= point,style=point,scaling=constrained);

If you can't stop the executecution of your worksheet, use mine:

x:=0.0:
for i to 10^8 do x:=x+1/i od:x;
###
for i to 10^8 do x:=x+1/i od:x;
###
for i to 10^8 do x:=x+1/i od:x;


which can be interrupted. :-)

 

The wmf format supports both vector and bitmap graphics, but unfortunately Maple produces only bitmap.

For Windows 64bit (at least), there is no support for vector 3D graphics! (postscript is supported but totally wrong!). I use Maxima for this purpose.

 

extrema(y,{},{x,n});

or

yy:=subs(x=t/n,y);
extrema(yy,{},t);

You must save n too, so use:
save n, x, "./myfunction.m"

(note that after restart and read the assume property for n is lost, as about(n) shows, see below).

 

I seem to recall that in new Maple versions, saving in internal .m format is not recommended.
Why don't you save in a text file? You can put your assumptions in a procedure and save them too.

If you insist  in using .m files, and use the assume facility, you will have to save the properties. This can be done by saving also `property/object`. In yor example:

save n, x, `property/object`,  "./myfunction.m"

 

 

1. Try to avoid 2D math for input
2. You can obtain a symbolic solution.

#k:=1;
eq := diff(g(Y), Y$4)+diff(g(Y), Y$2)+g(Y);
cis := g(1/4) = k, D(g)(1/4) = 0, g(0) = k, (D@@2)(g)(0) = 0;
dsolve([eq, cis]);

t:= `Hello Bob`;
cat(cat(t,` `)$5);

It is generally impossible to generate all the elements of the group GL(n,q) because its order is huge.
Maple knows this order (a classical formula).

with(GroupTheory):
GroupOrder(GL(4,2)); #your group
      20160
GroupOrder(GL(5,2));
      9999360
GroupOrder(GL(4,3));
      24261120
GroupOrder(GL(8,2));  # !!!
      5348063769211699200
GroupOrder(GL(n,q));  #even symbolically!
       







 

 

For symbolic result in (-Pi,Pi]

angle + 2*Pi*floor(1/2-angle/(2*Pi));

Reduce(X,X,T) is useless, it will produce only zeros.

If you want to see if a polynomial p in X is dependent of the other ones, you should call Reduce versus the rest of the polynomials i.e.

Reduce(p, Xp, T)
where
Xp := convert( convert(X,set) minus {p}, list );
Actually you should use a Groebner basis for Xp, otherwise the reduction could be incomplete (so, irrelevant).

In many situations Maple gives "generic" solutions.
For example, solve(a*x-2*a,x)  ==> x=2  (ignoring the case a=0).
However,  solve(a*x-2*a);  ==> {a = a, x = 2}, {a = 0, x = x}.
Your system has many equations of the form  a*b+c*d = 0.
solve([a*b+c*d]); ==> {a = -c*d/b, b = b, c = c, d = d},  so the solutions having b=0 are lost.

In such situation it is safer to use the Groebner package but unfortunately the system is too big for this.

 

First 107 108 109 110 111 112 113 Last Page 109 of 120