Kitonum

21475 Reputation

26 Badges

17 years, 52 days

MaplePrimes Activity


These are answers submitted by Kitonum

(a/a)/expand((a+b)/a);

Possible variant:

P:=proc(L::list)

local T, S, a, U, i;

T:=L; S:=[];

while nops(T)>0 do

a:=T[1]; S:=[op(S), a];  U:=[];

for i to nops(T) do

if T[i]=a then U:=[op(U), i]; fi;

od;

T:=subsop(seq(U[k]=NULL, k=1..nops(U)), T);

od;

S;

end proc;

 

Example:

 L:=[1, 5, 4, 1, 2, 4, 5, 1, 6]:

P(L);

    [1, 5, 4, 2, 6]

Draw a circle and parallel lines can be a variety of ways:

1) By plot command.

2) By plots[implicitplot] command if the lines are given as  implicit functions.

3) Using the primitives of the plottools package.

Read help on these commands!

with(Statistics):

X := RandomVariable(Normal(64.3,2.6)):

PDF(X, x); # Probability density function

int(%, x=-infinity..56.5);

This can be done without loops as follows:

DetVanMat:=proc(A::list)

local B;

B:=combinat[choose]({seq(i, i=1..nops(A))}, 2);

mul(A[B[k,2]]-A[B[k,1]], k=1..nops(B));

end proc;

 

Example:

DetVanMat([seq(x[i], i=1..4)]);

      (x[2]-x[1])*(x[3]-x[1])*(x[4]-x[1])*(x[3]-x[2])*(x[4]-x[2])*(x[4]-x[3])

The procedure finds the Nth term of the sequence of lists defined by the recurrence

f(0)=[0., 0]

f(n)=[f(n-1)[1]+1/n, n]

in lines:

1)   ftn:=arg[1];

2)  srtpt:=args[2];

3)  print('please change another starting point');

4)  error solution 'not' found;  

  

Right-click on the animation and choose  Export As -> GIF .  The created file can look in any modern browser or player, or download here as below:

plots[animate](plot, [a*(2*x^3 + x^2 - 3*x), x=-2..2, thickness=2], a=1..10, frames=100 );

r :=t->(cos(t)+t*sin(t))*i+(sin(t)-t*cos(t))*j+5*k:

 D(r)(t);  # Vector T

r1 := t->(3*cos(t))*i+(3*sin(t))*j+2*t^(3/2)*k:

D(r1)(t):

 int(sqrt(coeff(%, i)^2+coeff(%, j)^2+coeff(%, k)^2), t=0..3);  # Length of the curve

                t cos(t) i + t sin(t) j

                           14

First, using the command  combinat [choose](A, 10) , you create a list of all subsets of A, containing 10 elements. Then, in a loop checking all these subsets.

A simple example: to find all the subsets of 5 elements of the set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} such that the sum of their elements is 20.

Solution:

A:={seq(i, i=1..10)}:

L:=combinat[choose](A, 5):

S:=[]:

for k in L do

if add(k[i], i=1..5)=20 then S:=[op(S), k]: fi:

od:

S;

beta := 0.25:

alpha0 := 0.2580:

alphad := 0.545:

Bmax := 0.7:

Alpha := 0..Pi/2:

A := plot((1-beta-beta*cos((Pi*alpha)/(0.8*alpha0)))*Bmax, alpha=0..0.8*alpha0, color=red, thickness=3):

B := plot(Bmax, alpha=0.8*alpha0..alphad, color=blue, thickness=3): 

plots[display](A, B, scaling=constrained, view=[Alpha, -0.2..1]);

Markiyan Hirnyk

1) Why condition if ... end if?

restart; a(1) := 4; a(2) := -2; a(3) := 1; N := 50;

for n from 3 to N do  a(n+1) := a(n)-5*a(n-1)+a(n-2) end do: a(N);

 

2) Your code is slower in 2 - 3 times. Compare for N = 100000.

a:=4:  b:=-2:  c:=1:

for i to 47 do

d:=c:  c:=d-5*b+a:  a:=b:  b:=d:

od:

c;

             43463309239573150

a:=n->((-1)^(n+1)+4*n-1)/2:

seq(a(n), n=1..8);

           2, 3, 6, 7, 10, 11, 14, 15

First 274 275 276 277 278 279 280 Last Page 276 of 290