## 15359 Reputation

12 years, 100 days

## Code...

Two errors in your code. Instead of  (H[1]-x2)*(x2-x1) +(H[2]-y2)*(y2-y1)=0 and (x2-x1)*(y3-y1) +(x3-x1)*(y2-y1) <>0  should be  (H[1]-x3)*(x2-x1) +(H[2]-y3)*(y2-y1)=0 and (x2-x1)*(y3-y1) -(x3-x1)*(y2-y1) <>0

Let the vertices of the triangle will be  [x1,y1], [x2,y2], [x3,y3] . Firstly we find the coordinates of orthocenter:

restart:

sol:=solve({(x3-x2)*(x-x1)+(y3-y2)*(y-y1)=0, (x2-x1)*(x-x3)+(y2-y1)*(y-y3)=0}, {x,y});

assign(sol):

Next, we find the solution of the original problem. Note that can confine ourselves 4-loops instead of 6-loops, if we use the formula for the centroid. So we can increase the range of  search. Also, instead of lists we use sets, so exclude the same triangles (which are obtained by permutations of the vertices):

L:={}:

k:=50:

for x1 from -k to k do

for x2 from -k to k do

for y1 from -k to k do

for y2 from -k to k do

x3:=3-x1-x2: y3:=3-y1-y2:

if x2*y3-x1*y3+x1*y2-y2*x3+y1*x3-y1*x2<>0 and x=3 and y=3 then

L:={op(L), {[x1,y1], [x2,y2], [x3,y3]}}: fi:

od: od: od: od:

nops(L); L;

If the centroid of a triangle coincides with the orthocenter, then the triangle is equilateral. It is easy to prove that in 2D coordinates of all the vertices of this triangle can not be integers.

int(rho*(rho+1)*sin(phi), [rho = 0 .. R, phi = 0 .. Pi, theta = 0 .. 2*Pi]);

## Procedure...

Tridiag:=proc(Diag1, Diag, Diag2, n)

local m, A, i, j;

m:=nops(Diag);

A:=Matrix(m, n);

for i to m do

for j to n do

if i=j then A[i,j]:=Diag[i] else

if i=j+1 then A[i,j]:=Diag1[j] else

if j=i+1 then A[i,j]:=Diag2[i] else

A[i,j]:=0; fi; fi; fi;

od; od;

A;

end proc:

Example:

Tridiag([1,2,3,4,5], [2,3,4,5,6,7], [3,4,5,6,7,8], 8);

## Procedure...

We assume that the cylinder of a revolver has 6 chambers. The procedure returns a structure of each trial and vector of   times the trigger was pulled.

RR:=proc(N)  # N is the number of trials

local roll, i, a, L, j, b, M, Q, A;

roll:=rand(1..6);

for i to N do

a:=roll(); L:=[[a]];  # a is the chamber number in which the bullet

for j do

b:=roll(); if b=a then L:=[op(L), b]; break else  L:=[op(L), b]; fi;

od;

M[i]:=L;

od;

Q:=[seq(M[i], i=1..N)];

A:=Vector([seq(nops(Q[i])-1, i=1..nops(Q))]);

print(op(Q));

print(A);

end proc:

Example:

RR(10);

## Scheme procedure...

SolvingSystem:=proc(system, n)
if n=1 then method s1 fi;
if n=2 then method s2 fi;
if n=3 then metod s3 fi;
result;
end proc:

## Re...

0

## Error...

You have to write  exp(-10*x)  instead of  exp^(-10*x)

## Correction...

Should be:

l4:=animate(textplot3d, [[0, 0, 0.9*tend,'direction'], color=red, align={BELOW}, font=[TIMES,ROMAN,14]], tend=0..50, frames=150):

Coordinates of the end of a vector are the coordinates of the basis  plus the coordinates of the vector.

## Help...

See  help on commands  ?plots[matrixplot]  and  ?table

## Corrected code...

code1.mw

Your error: in the last lines should be the sign  :=  instead of  =

## Solution in Maple...

Let  x  is serial number 5, y  is serial number 6, z  is serial number 7.

`L:=[]:for x from 1 to 2 dofor y from 0 to 9 dofor z from 0 to 9 do if z=5-y then L:=[op(L), [x,y,z]]: fi:od: od: od:L; nops(L); combinat[numbperm]([9,8,7,7])*%; `
` [[1, 0, 5], [1, 1, 4], [1, 2, 3], [1, 3, 2], [1, 4, 1], [1, 5, 0],        [2, 0, 5], [2, 1, 4], [2, 2, 3], [2, 3, 2], [2, 4, 1],        [2, 5, 0]]                                  12                                 144`

## Correction...

Replace the last line by the line

solve({seq(lhs(U)[i] = rhs(U)[i], i = 1 .. 2)}, {Gx, Gy})

Solve command does not solve vector equations. Index  i  not equals to 3, because the last coordinate of lhs(U) does not contain  Gx  and  Gy .

Of course, we assume that  lhs(U)[3]=0 , otherwise there are no solutions.

## Error...

Assignment   i:='i'  is incorrect, since then  Term1:=i-1  has not a specific value, and therefore the command  add  can not be executed.

## Algsubs...

algsubs command  is more powerful than applyrule command.

Example:

`a:=x[2]+y-b+x[1]-c+x[5]+d+x[4]+x[3]+expand(sum(x[i], i=1..5)^2);applyrule(sum(x[i], i=1..5)=Sum(x[i], i=1..5),a);algsubs(sum(x[i], i=1..5)=Sum(x[i], i=1..5), a);`
 First 216 217 218 219 220 221 222 Last Page 218 of 239
﻿