Kitonum

21500 Reputation

26 Badges

17 years, 61 days

MaplePrimes Activity


These are answers submitted by Kitonum

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

Topological structure is the same as in the figure. The form can be changed.

tubeplot({[(cos(5*t/2)+13/5)*cos(t), (cos(5*t/2)+13/5)*sin(t), 3*sin(5*t/2)/5],[(2/5*cos(7*t/3)+12/5)*cos(t), (2/5*cos(7*t/3)+12/5)*sin(t), 2*sin(7*t/3)/7]}, t=0..6*Pi, radius=1/5, style=surface,numpoints=2500, scaling=constrained, lightmodel=light4, orientation=[50, 20]);

Include your assumptions into the system.

 

Example:

solve(x^2=1, x>0});

        {x=1}

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