Kitonum

21525 Reputation

26 Badges

17 years, 75 days

MaplePrimes Activity


These are answers submitted by Kitonum

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

eliminate({x-lambda*p=0, y-lambda=0}, lambda):

p=solve(op(%[2]), p);

           p=x/y

Example:

S:={[1, 1], [2, 1], [2, 2], [3, 1], [3,2]}:

f:=proc(x,y)

x^2+y^2:

end proc:

seq(f(op(S[i])), i=1..nops(S));

              2, 5, 8, 10, 13

If you frequently use the symbol perpendicularity it makes sense to write a special procedure. Formal arguments: L - a list of the coordinates of the center of the character, l - length of a stick, th - thickness, c - color, alpha - angle of the vertical stick from the positive direction of the horizontal axis.

PerpSymb:=proc(L, l, th, c, alpha)

local A, B;

uses plottools;

A:=line(L,[L[1]+l*cos(alpha), L[2]+l*sin(alpha)], color=c, thickness=th);

B:=line([L[1]-l*sin(alpha)/2, L[2]+l*cos(alpha)/2], [L[1]+l*sin(alpha)/2, L[2]-l*cos(alpha)/2], color=c, thickness=th);

A, B;

end proc;

 

Example:

plots[display](PerpSymb([1,0.7], 0.15, 2, red, 2*Pi/3), PerpSymb([1.5,1], 0.2, 4, black, Pi/2), PerpSymb([2,0.7], 0.25, 6, blue, Pi/3), view=[0..3, 0..2], scaling=constrained);

 

with(LinearAlgebra):

do M:=RandomMatrix(3, 3, generator=1..9):

if Determinant(M)<>0 then break: fi:

od:

v:=RandomVector(3, generator=1..9):

'M'=M, 'v'=v;

x=LinearSolve(M, v);

The easiest way to solve this problem is by generating functions, noting that the number of integer and positive roots of the equation is the number of non-negative integer roots of the equation

2a +3 b +10 c = 2010 - (2 +3 +10) = 1995

coeff(convert(series(1/(1-x^2)/(1-x^3)/(1-x^10),  x=0,  1996), polynom),  x^1995);

                                                              33367

 

The problem can be also solved programmatically as follows:

restart:

n:=0:

for a from 1 to floor(2010/2) do

for b from 1 to floor((2010-2*a)/3) do

for c from 1 to floor((2010-2*a-3*b)/10) do

if 2*a+3*b+10*c=2010 then n:=n+1: fi:

od: od: od:

n;

                                                       33367

 

Maple incorrectly decided your example 3. This equation has only one root, and this root is positive.

In accordance with your wishes

Newton := proc( f, x0, n, tol)

local x, g, k;

g := D(f);

x[0] := evalf(x0);

for k from 1 to n do

while evalf(abs(g(x[k-1])))<=10^(-8) do

x[k-1]:=x[k-1]+0.00001; od;

x[k] := evalf( x[k-1] - f(x[k-1])/g(x[k-1]) );

if abs(x[k]-x[k-1]) < tol then

return x[k]; fi;

od;

x[k-1];

end proc;

 

Examples:

Newton(x->1-x^2, 0, 20, 10^(-6));

             1.000000002

Newton(x->x^2-2, 0, 20, 10^(-6));

              1.414214589

             

You can build any number of triangles for which the coordinates of the vertices and the coordinates of the center of circle circumscribed  are integers as follows:

1) Take  any three points with integer coordinates that do not lie on a straight line. Let be points A, B, C.

2) Find the coordinates of the center of circle circumscribed about triangle ABC as the point of intersection of three planes. The coordinates of this point will be rational numbers.

3) Find the least common multiple of the denominators of the fractions.

4) Multiply the coordinates of all the points on this number.

As it should be |sin(x)|<=1, then we are looking for solutions only in the range x = -8 .. 8 .

The code:

RootFinding[Analytic](sin(x)=x/8, re=-8..8, im=-1..1);

Add the condition

(y1*z2-z1*y2)^2+(z1*x2-x1*z2)^2+(x1*y2-y1*x2)^2<>0

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