Kitonum

21500 Reputation

26 Badges

17 years, 60 days

MaplePrimes Activity


These are answers submitted by Kitonum

Var := indets(EQ):

A, V := LinearAlgebra[GenerateMatrix](EQ, Var);

evalf(LinearAlgebra[LinearSolve](A, V));

 

 

B:=cos(x)^2*sqrt(1-1/4*(3*sin(x)^2*cos(y)^2+cos(x)^2));

evalf(Int(B, [x=0..7*Pi/18, y=0..2*Pi]));

 List of errors:

1) Coding of  Pi .

2) Signs of multiplication.

3) Value of the function to the power  n  should be  f(x)^n  rather than  f^n (x) .

4) For double integrals ranges should be in brackets  [x=x1..x2, y=y1..y2] 

 

GAMMA  is the specific function in Maple, gamma is Euler's constant. See help for details.

 

evalf(gamma);

GAMMA(5);

               0.5772156649

                       24

ArePermutable:=proc(A::Matrix, B::Matrix)

local m, n, m1, n1, Rows, L, M, Columns, L1, K;

uses LinearAlgebra, combinat;

m:=RowDimension(A); n:=ColumnDimension(A); m1:=RowDimension(B); n1:=ColumnDimension(B);

if m<>m1 or n<>n1 then error "Matrices should be the same size" fi;

Rows:=permute([seq(A[i], i=1..m)]); L:=[seq(<op(Rows[i])>, i=1..m!)];

for M in L do

Columns:=permute([seq(M[..,i], i=1..n)]); L1:=[seq(<`<|>`(op(Columns[i]))>, i=1..n!)];

for K in L1 do

if Equal(K,B) then return true fi;

od; od;

false;

end:

 

Examples of use:

A:=<1,2,3; 4,5,6; 7,8,9>;  B:=<3,2,1; 9,8,7; 6,5,4>; C:=<2,1,3; 4,5,6; 7,8,9>;

ArePermutable(A,B);  ArePermutable(A,C);

 

 

Simple procedure  PartitionIntoPrimes  gives all possible partitions of a natural number  a  into  n  prime summands. By default, the procedure returns the list of lists of all partitions. If the third argument of the procedure is any symbol, then the procedure returns all of the corresponding sums. The procedure was written in Maple 12 classic.

PartitionIntoPrimes:=proc(a::posint, n::posint, s::symbol:=list)

local L, M, k, i, S, S1;

uses numtheory, combinat;

L:=[seq(ithprime(k)$n, k=1..pi(a))];

M:=choose(L, n); k:=0;

for i in M do

if `+`(op(i))=a then k:=k+1; S[k]:=i; fi;

od;

S:=convert(S, list):

if s=list then return S else S1:=map(t->`+`(op(map(x->``(x),t)))=a, S) fi;

for i in S1 do

print(i);

od;

end:

 

Examples of use:

PartitionIntoPrimes(30, 2);

PartitionIntoPrimes(30, 6);

PartitionIntoPrimes(30, 6, s);

 

 

 

f := simplify(evalc(int(cosh(a*x)*cos(b*x), x)));

 

 Addition:

simplify(convert(f, trig));

 

 

I made ​​some changes in your code. Write if you got what you wanted?

restart:

alias(C=binomial):

HybrFunc:=proc(N, M,tj)  # N=Number of subintervals,  M=Number of functions in subintervals

local B, i, kk, j1, w, aa, bb, OB;

global b; 

B:=(i,M,t) -> C(M,i)*(1-t)^(M-i)*t^i;

w[0]:=B(0,M,t);

for i from 0 to M

do

  kk:=0; 

  for j1 from 0 to i-1

  do

    aa[j1]:=int(B(i,M,t)*w[j1],t=0..1);

    bb[j1]:=int(w[j1]^2,t=0..1);

    kk:=kk+aa[j1]/bb[j1]*w[j1];

  od;

w[i]:=simplify(B(i,M,t)-kk);

w[i]/sqrt(int(w[i]^2,t=0..1));

OB[i]:=unapply(%,t);

od; 

b:=unapply(piecewise(t>=(n-1)*tj/N and t<n*tj/N, sqrt(N)*OB[m](N*t-(n-1)*tj), 0),n,m); 

simplify(Array(1..N, 0..M , b));

end proc:

 

Example: 

HybrFunc(2, 3, 1);

a:=sqrt(2)*T*I/sqrt(L*(k+2)*C):

simplify(exp(-a)*k^2+4*exp(-a)*k+exp(a)*k^2+4*exp(a)*k+4*exp(a)+4*exp(-a));

 

 

e^a  should be coded as  exp(a), because  in Maple  e  is just a symbol. 

C:=proc(x, E)

local i, n;

n:=nops(E);

if is(x<=E[1]) then return 1 else

for i from 1 to n do

if is(x<=E[i]) and is(x>E[i-1]) then return i  fi;

od; fi;

n+1;

end:

 

Examples of use:

E:=[0,2,7,15,26,40]:

C(-1, E),  C(3, E),  C(15, E),  C(41, E);

                      1, 3, 4, 7

 

Addition: another way

C1:=proc(x, E)

local F, y;

uses ListTools;

y:=evalf(x);

F:=sort([y, op(E)]);

Search(y, F);

end:

 

For any graph it is easy to check in Maple. The graph given by its adjacency matrix.

Example: 

A:=<0,1,1,1,1; 1,0,1,0,1; 1,1,0,1,1; 1,0,1,0,0; 1,1,1,0,0>;

d:=sort([seq(add(A[i,j], j=1..5), i=1..5)], `>`);

# Checking of all the conditions

type(add(d[i], i=1..5), even);

for k to 5 do

if add(d[i], i=1..k)<=k*(k-1)+add(min(d[i], k), i=k+1..5) then print(true); fi;

od;

 

 

a := [x+1, x+2, x+3, x+4]:

remove(i -> i=x+2, a);

               [x+1, x+3, x+4]

 

To generate a random number between -1 and 1, first you generate from 0 to 2, and then this number decreased by 1.

Example: the sequense 20 random numbers from -1 to 1:

seq(RandomTools[Generate](float(range=0..2, digits=5, method=uniform)) - 1, n=1..20);

    .2143, -.73336, -.50076, -.7856e-1, -.14992, -.46077, .5519, -.4999e-1, -.14926, -.57465, .8858, -.27223, -.4630e-1,    -.66349, .2290, .1925, .2208, .5704, .2130, -.15558

The penultimate line of code  

M[1..6,1..6]:=Matrix(3,3,shape=identity)

is not evaluated because it is written in text mode.

Yes, it's possible. Use the formula of differentiation of parametric function  Diff(y(x), z)=Diff(y(x), x)/Diff(z(x), x)

Example:

y:=x->sin(x): z:=x->x-y(x):

diff(y(x), x)/diff(z(x), x);

 

 

f:=x->piecewise(x>=2 and x<=6, sqrt(x), undefined);

D(f)(1);

plot(f, 0..7, 0..3, scaling=constrained);

 

 

First 231 232 233 234 235 236 237 Last Page 233 of 290