vv

8995 Reputation

18 Badges

5 years, 208 days

MaplePrimes Activity


These are answers submitted by vv

You could use inert Sum instead of sum and then, when needed do e.g.:
value(eval(a, N=4));

This is obviously a cooked up example.
The minimum is 0, but it is attained not only for x=y=z=1,  but also for  any x=1, y=a, z=a  (a>=1).

int(sin(log(x+1)),x=-1..1, method=FTOC);

Should work in Maple 17 (the function has an elementary antiderivative).

So, you have

restart;
alias(a1 = a1(r), a2 = a2(r), a3 = a3(r));
#                           a1, a2, a3
array1 := [a1, a2, a3];
#                     array1 := [a1, a2, a3]
array2 := [seq(cat(a, i), i = 1 .. 3)];
#                    array2 := [a1, a2, a3]
array1 - array2;
#                             [0,0,0 ]
diff(array1, r),   diff(array2, r);
#              [ d       d       d    ]           
#              [--- a1, --- a2, --- a3], [0, 0, 0]
#              [ dr      dr      dr   ]           

To understand (and see) what happens, let's use macro instead of alias
 

restart;
macro(a1 = a1(r), a2 = a2(r), a3 = a3(r));
#                           a1, a2, a3
array1 := [a1, a2, a3];
#                array1 := [a1(r), a2(r), a3(r)]
array2 := [seq(cat(a, i), i = 1 .. 3)];
#                     array2 := [a1, a2, a3]
array1 - array2;
#            [-a1 + a1(r), -a2 + a2(r), -a3 + a3(r)]
diff(array1, r),  diff(array2, r);
#          [ d          d          d       ]           
#          [--- a1(r), --- a2(r), --- a3(r)], [0, 0, 0]
#          [ dr         dr         dr      ]           

So, as we see, array1 and array2 are totally distinct, array2 does not contain arguments.
The fact that array1 - array2  evaluates to  [0,0,0]  (for alias only!) is (most probably) due to (automatic?) simplification where the alias acts.

In general, when using alias (or macro), it is not wise to use "special" constructs such as your cat (involving aliased names). But at least, with macro, we see how Maple interprets our expressions.
 

An alternative for Carl's solution.

delind:=proc(T::table, S::set, M::set(list):={}) 
  local i,X; 
  unassign(subs(X=T, [seq(X[i],i=S),seq(X[i[]],i=M)])[])
end proc:

T:=table([11,22,33,44,55,66]): T[a,b]:=c: eval(T);
#           TABLE([1 = 11, 2 = 22, 3 = 33, 4 = 44, 5 = 55, 6 = 66, (a, b) = c ])

delind(T, {2,3});
delind(T, {1,5}, {[a,b],[6]});  eval(T);
#           TABLE([4 = 44])

Edit. @Carl. I think that you prefer:

delind:=proc(T::table, S::set, M::set(list):={}) 
  local X; 
  unassign(subs(X=T, `?[]`~(X,`[]`~(S)) union `?[]`~(X,M))[])
end proc:

 

Statistics is a modern package, full of modules and generated modules, not easy to debug.
For a workaround, as you noticed, it's possible to use (for the moment)

HR:=(X, t) -> (PDF(X, t)/(1 - CDF(X, t)));

HR(1/2*X1 + 1/2*X2, 0.4); 
        2.352941176

Use Tabulate(DF):  instead of  print(Tabulate(DF));
(notice the colon).

It is almost correct, but why don't you read at least a tutorial first?

Crunch := proc(x::positive)
if x >= 100 then
  return x/100
else
  return x + Crunch(10*x)
fi
end proc;

(if you allow x <=0, it results an infinite recursion).

You can use the (pseudo)type satisfies

restart;
test:=table([1=[1,2,3],2=[6,5,4]]):
mytype:=satisfies(e -> e::'table', e -> [indices(e,nolist)]::list(integer),  e -> [entries(e,nolist)]::list(list(integer))):
type(test, mytype);

     true

restart;
with(LinearAlgebra):
A := Matrix([[4, 2, -1], [2, 0, 2], [-1, 2, 0]], shape=symmetric, datatype=float):
x0:= <-1., 0., 1.>:
tol:=1e-4:
x1:=Normalize(A.x0, 2):
for i to 100 while Norm(x1-x0)>tol do
  x0,x1 := x1, Normalize(A.x1, 2); 
od:
x1^*.A.x1, x1, iter=i;
Eigenvalues(A); #check

Your matrix is defective (after plugging the conditions); for the 0 eigenvalue there are only 3 true eigenvectors.
You may want the Jordan form instead.

 

EIGENVECTOR-J.mw

 

 

A series is not designed to be used like this. It has a special structure, and you are messing with its operands. 
Note that e.g.   2 + series(exp(x),x,3)  cannot be simplified by simplify

There are (too) many solutions. E.g.

F:=(n,k) -> piecewise(k=2, n, k=n+1, n!, arbitrary);

F(F(n,n+1),2) assuming n<>1;
        n!

It is also possible to write

F:=proc(n,k)
if k=n+1 then return n! fi;
if k=2 then return n fi;
'F'(n,k) # arbitrary
end;

In this case, assuming is not necessary.
 

When the order of the field is prime, simply use LinearAlgebra:-Modular.
For a general finite field, use F:=GF(...) to define the field and then use the generic functions in the package LinearAlgebra:-Generic, e.g.  MatrixInverse[F](...).

The simplified version is:

restart;
f:=k->Int(BesselJ(1, t)*BesselJ(0, k*t), t=0..infinity):
value(f(k));               # 1, wrong
value(f(k)) assuming k>1;  # 0, ok
value(f(k)) assuming k<1;  # 1, wrong (for k<=-1)
value(f(k)) assuming k<-1; # unevaluated,  why?
value([f(1/2),f(1),f(2)]) = evalf([f(1/2),f(1),f(2)]); # [1,1/2,0] , ok

 

1 2 3 4 5 6 7 Last Page 1 of 92