Kitonum

21925 Reputation

26 Badges

17 years, 282 days

MaplePrimes Activity


These are answers submitted by Kitonum

For this example, you can use  print  command also, but only without  cat  command:

Sol1:=1/4: Sol2:=1/5: Sol3:=1/7:
print(`Solution: `*A=Sol1, B=Sol2, C=Sol3);

                                     

When we specify a function by means of a formula, it is usually assumed that the argument takes finite values. We can extend the definition of a function to infinity or to singular points if we use the  limit  function and  piecewise  function.

Example:
f:=x->sin(x)/x;
f(infinity);
limit(f(x), x=infinity);

# Or
f(0);
limit(f(x), x=0);
                                 


f:=x->piecewise(x<>0 and x<>infinity, sin(x)/x, x=0, 1, x=-infinity or x=infinity, 0);
f(0), f(infinity), f(Pi/6);
                         

 

 

 

It can be done if we replace 1/2 with 0.5 and use  cat  command:

ss1:=-2:  ss2:=0.5:  ss3:=-5:
print(`The 3 equation in A, B, C for `*s=ss1,s=ss2*` and `*cat(s,`=`,ss3,` :`));
                    

            

 

P1 := y^2 = x^3+x^2:
P2 := y = 2*x+1:
plots:-implicitplot([P1,P2], x=-2..10, y=-2..10, color=[red,blue], gridrefine=3);
map2(fsolve, [P1,P2], [{x=-1,y=-1}, {x=-0.5,y=0.5}, {x=4,y=10}]);
                           

It's easy:

Eq:=x + y*F(x)=0:
diff(Eq, x);
                                      

                                     

 

The term "Minor of a matrix A of order p" is used in two meanings:
1. As a certain square submatrix of order p of a matrix A.
2. As the determinant of this submatrix.

Two simple 1-line procedures solve problems 1 and 2.

The code of the first procedure:
Minors_submatrices:=[(A::Matrix,p::posint)->seq(seq(A(r,c), c=combinat:-choose([$1..op(1,A)[2]],p)), r=combinat:-choose([$1..op(1,A)[1]],p))]:

The code of the second procedure:
Minors_determinants:=[(A::Matrix,p::posint)->seq(seq(LinearAlgebra:-Determinant(A(r,c)), c=combinat:-choose([$1..op(1,A)[2]],p)), r=combinat:-choose([$1..op(1,A)[1]],p))]:


Examples of use:

A:=LinearAlgebra:-RandomMatrix(3,4, generator = -9 .. 9);
Minors_submatrices(A,2);
Minors_determinants(A,2);

                               
 

 

Sol:=eval([A, B, C], sol);
Sol[1];

                                      Sol:=[1, 2, 3]
                                              1

Set  Digits  to 10 (by default) and everything will be alright (for better viewing, I slightly increased the ranges):

Digits := 10: 
AA := inequal(eq5 <= 0, beta = -5 .. 10, alpha = -5 .. 10, axes = normal, labels = ["&beta;", "&alpha;"], title = [Delta = Del1]);

                           

 

Try  subs  command (after restart command):

restart;
subs([A=-7/6,B=4/15,C=19/10], A/(s+1)+B/(s-2)+C/(s+3));

 

                                


Edit.  

We assume that some function  f: X -> Y   is given by the set of pairs  [x, y] , where  y=f(x) . Two simple procedures solve the problem.

IsOneToOne:=proc(F::set(list))
local L;
uses ListTools;
L:=[Categorize((x,y)->x[2]=y[2], convert(F,list))];
if nops(L)=nops(F) then true else false fi;
end proc:

Examples of use:
IsOneToOne({[1,1], [2,3], [3,3]});
IsOneToOne({[1,1], [2,3], [3,4]});

                                                         false
                                                          true


In the second procedure  IsOnTo  additionally the set  Y  must be specified.

IsOnTo:=proc(F::set(list), Y::set)
local Y0;
Y0:=map(t->t[2], F);
if nops(Y0)=nops(Y) then true else false fi;
end proc:

Examples of use:
IsOnTo({[1,1],[2,3],[3,3]}, {1,3});
IsOnTo({[1,1],[2,3],[3,3]}, {1,3,4});
                                                                 
true
                                                                false

                                                                

 

The procedure  N  for any  n  gives the total number of such sequences of length  n:

N:=n->sum(binomial(m+1,n-m), m=floor(n/2)..n);


Examples of use:
N(1), N(2), N(3), N(4), N(10), N(100);

                                   2, 3, 5, 8, 144, 927372692193078999176


Addition. It is interesting that there is equality  N(n)=F(n+2), where  F(n)  is  Fibonacci sequence. See  https://en.wikipedia.org/wiki/Fibonacci_number

Example:

r:=rand(1..6):
L:=['r'() $ 30];
ListTools:-Occurrences(5, L);

Use the functional assignment:

f:= eta -> 1 - exp(-eta);

1. A function  f  can be applied only to one object or to a list (or to a set or to array) of objects by elementwise operation.

2. A argument (arguments) of a function  f  should be inside of parenthesis.

f([seq(i, i = 1 .. 2)][]);                      
f(add(i, i = 1 .. 2));

  

First 144 145 146 147 148 149 150 Last Page 146 of 292