vv

13827 Reputation

20 Badges

9 years, 316 days

MaplePrimes Activity


These are answers submitted by vv

After studying Maple such things will be possible. E.g.

funny := module() option package;  export `<`;
   `<`:= proc(a::list(realcons), b::realcons) option overload;
              select(t -> t<b, a);
         end proc;
end module:

with(funny):
a:=[1,2,3,4,5]:
b:=a<4;

                         b := [1, 2, 3]

 

Suppose you want F[i, j,...](x, y,...)  to return  x^i + y^j + ...

F:=proc()
  local ind:=op(procname); 
  add( [args] ^~ [ind] )
end:

F[i,j,99](x,y,z);
   
x^i+y^j+z^99

Of course some parameter checks in the procedure are recommended.

b:=A[..,6]:
C:=A[..,[1..5,7..11]]:
(C^(-1).b)[6];

 

(simplify@expand@convert)( abs(u+v)^2+abs(u-v)^2, conjugate );

       

1.   As documented.

2. Because is tries to be smart.
Also:
is(0.5 = 1/2);
     true

3. Because is is not perfect.
Also:
is(exp(1)+Pi, rational);
    false
Should be FAIL, the result is not known (yet)!

 

f:=exp(t^(1/3)-2*t^(7/4)):
s:=series(f,t,6);

 

 

sort(s,t,ascending);


 

 

 

restart;

s:=Sum(binomial(i+k,k),i=0..infinity);

Sum(binomial(i+k, k), i = 0 .. infinity)

(1)

eval(s,k=7); value(%);

Sum(binomial(i+7, 7), i = 0 .. infinity)

 

infinity

(2)

value(s);

0

(3)

value(s) assuming k>0;

infinity

(4)

sum(binomial(i+k,k),i=0..infinity, parametric);

piecewise(k <= -2, 0, -1 <= k, Sum(binomial(i+k, k), i = 0 .. infinity))

(5)

So, the sum for an arbitrary k was 0 because this is true for k <= -2, a "generic" result!

 

BTW, in mathematics there exist several generalized summation methods.
For example the Poisson summation:

Sum(a[n],n=0..infinity) = Limit(Sum(a[n]*x^n,n=0..infinity),x=1,left);

Sum(a[n], n = 0 .. infinity) = Limit(Sum(a[n]*x^n, n = 0 .. infinity), x = 1, left)

(6)

In our case:

sum(binomial(i+k,k)*x^i,i=0..infinity) assuming x<1,x>0;

1/(1-x)^(k+1)

(7)

agrees with (5) for  k<-1  because

limit(%, x=1, left) assuming k<-1;

0

(8)

 

Now, for

sum(n, n=0..infinity, formal);

-1/12

(9)

 

is as you said, but in this case it was not the Poisson summation used (which gives infinity).

Here the sum was seen as Zeta(-1)

 

Zeta(-1);

-1/12

(10)

# Recall that

 Zeta(z) = Sum(1/n^z, n=1..infinity) assuming Re(z)>1;

Zeta(z) = Sum(1/n^z, n = 1 .. infinity)

(11)

[  the value -1/12 is obtained by the unique holomorphic extension for this function to C \ {1} ]

The timing seems to be similar.

t:=time[real]():
L:=combinat:-permute([1,1,1,1,0,0]):
C:=Iterator:-CartesianProduct([seq(1..15)]$6):
n:=0:
T:=table():
for c in C do
if add(L[c[i]][1],i=1..6)<>4 or
   add(L[c[i]][2],i=1..6)<>4 or
   add(L[c[i]][3],i=1..6)<>4 or
   add(L[c[i]][4],i=1..6)<>4 or
   add(L[c[i]][5],i=1..6)<>4 or
   add(L[c[i]][6],i=1..6)<>4 then next fi;
n:=n+1;
T[n]:=Matrix([seq(L[c[i]],i=1..6)]);
od:
'num'=n, 'time'=time[real]()-t;

        num = 67950, time = 65.329

Edit. We gain about 2 seconds if one of the 6 tests inside if is removed.

@shimaa sadk 

The inner sum can be computed symbolically. Do it.
Fot the outer one use evalf(Sum(...,T=0..infinity);

Unfortunately evalf for GAMMA and also Zeta is VERY slow for large arguments. E.g.

evalf( GAMMA(1+10^20*I));

The evalf operations are known to be hard/impossible to interrupt.

It seems that for infinite complex limits Maple applies some nonvalid transforms (fractional powers).

K:=Int(1/(s^2+1), s = 1-I*infinity .. 1+I*infinity):
eval(K, infinity=1000):
evalf(%);

    -9.*10^(-13)+0.1999998661e-2*I

Transforming by hand the complex limits also works (IntegrationTools:-Change  fails):

J:=Int(  1/((1+I*t)^2+1)*I, t=-infinity..infinity):
evalf(%);

    1.110223025*10^(-16)*I

 

[1.] p1 is not function (in mathematical sense, i.e. a procedure in Maple). It is an expression.

[2.] diff works, but not as you expect. You should be aware that p1 could be nowhere differentiable; this depends of a(t).
For example if a(t) = 1 for a rational t and 0 otherwise then you cannot differentiate p1.

[3.] p1(1) is a nonsense, see [1.].  Think e.g. at the meaning of  sin(t)(1).

[4.] The simplification is indeed strange, the first vector has disappeared.

[5.] See again [1.]

int~(int~(a, t=0..t), t=0..t) + v0*t + r0;

or even shorter:

int~(a, t=0..t, t=0..t) + v0*t + r0;

 

Actually the system is linear, so it can be solved exactly even without dsolve.
The solutions are huge, so must be ploted only near 0.

A:=<1.052936200*10^5,+70106.19000,+35169.00000;
    70106.19000,+71031.61000,+35511.00000;
    35169.00000,+35511.00000,+36100.00000>:
    Y0:=<1e-06, 1.0e-06, 0>:

sol:=LinearAlgebra:-MatrixExponential(A,t).Y0;

_rtable[18446744074359610774]

(1)

plot([sol[1],sol[2],sol[3]], t=0..0.0001);

 

 

Eigenvalues uses special algorithms to obtain best accuracy for the result (float[8] entries).
Computing the inverse of RS introduces large roundoff errors.
Note also that RS is almost singular; its determinant is ~ 10^(-1208);

First 83 84 85 86 87 88 89 Last Page 85 of 120