JAMET

400 Reputation

4 Badges

7 years, 35 days

MaplePrimes Activity


These are questions asked by JAMET

p eriode:=proc(r::rational)""  local a,b,c,f,i,k,l,p,q,s:  s:=couvert(evalf(abs(r)-trunc(r),50),string):  if  s[1]="." then s:=s[2..length(s)] fi:  a:=numer(simplify(r)): b:=denom(simplify(r)):  if  igcd(b,10)=1 then       q:=0:       p:=1:      while (10^(p) mod b)<>1 do  p:=p+1 od:  else      f:=ifactors(b)[2]:      k:=0:l:=0:      for i  ;
to nops(f) do
        if f[i][1]=2 then k:=f[i][2] fi:
        if f[i][1]=5 then l:=f[i][2] fi: 
     od:
   c:=b/(2^k*5^l):
   q:=max(k,l):
   if c=1 then p:=0 else p:=op(2,periode(1/c)) fi:
fi:
[q,p,[seq(parse(s[k]),k=1+q..q+p)]]
end:
Error, improper op or subscript selector
Error, reserved word `fi` unexpected
I don't understand these errors. Thank you.

How to show that any Pythagorean triplet can be obtained from <3,4,5> ? Thank you.
Can we simplify this program?

#Génération Géométrique et Algébrique des triplets Pythagoriciens
restart;
with(geometry);
with(LinearAlgebra);
_EnvHorizomtalName = 'x';
_EnvVerticalName = 'y';

with(plottools);
P := point([0, 0], color = black, symbol = cross, symbolsize = 25);
Oo := point([1/2, 1/2], color = black, symbol = cross, symbolsize = 25);
A := point([1, 1/2], color = black, symbol = cross, symbolsize = 25);
with(plots);
c1 := circle([1/2, 1/2], 1/2, color = blue);
NULL;
PA := line([0, 0], [1, 1/2], color = red);
eqC := (x - 1/2)^2 + (y - 1/2)^2 = 1/4;
eqPA := y = 1/2*x;
sol := solve({eqC, eqPA}, {x, y});

t1 := textplot([0, 0, 'typeset'("P"), font = [Times, Bold, 14]], 'align' = 'above');
t2 := textplot([1, 1/2, 'typeset'("A"), font = [Times, Bold, 14]], 'align' = 'right');
t3 := textplot([1/5, 1/10, 'typeset'("A'"), font = [Times, Bold, 14]], 'align' = 'above');
A1 := point([1 - 1/5, 1/10], color = black, symbol = cross, symbolsize = 25);
diff(A, x) := point([1/5, 1/10], color = black, symbol = cross, symbolsize = 25);
t4 := textplot([1 - 1/5, 1/10, 'typeset'("A1"), font = [Times, Bold, 14]], 'align' = 'right');
A2 := point([1 - 1/5, 1 - 1/10], color = black, symbol = cross, symbolsize = 25);
t5 := textplot([1 - 1/5, 1 - 1/10, 'typeset'("A2"), font = [Times, Bold, 14]], 'align' = 'right');
A3 := point([1/5, 1 - 1/10], color = black, symbol = cross, symbolsize = 25);
t6 := textplot([1/5, 1 - 1/10, 'typeset'("A3"), font = [Times, Bold, 14]], 'align' = 'right');

poly := Matrix([[1/5, 1/10], [1 - 1/5, 1/10], [1 - 1/5, 1 - 1/10], [1/5, 1 - 1/10]], datatype = float);
pol := polygonplot(poly, color = blue, transparency = 0.95);

display(c1, P, Oo, A, PA, seq(A || i, i = 1 .. 3), seq(t || i, i = 1 .. 6), pol, scaling = constrained, axes = none, size = [600, 600]);

R1 := Transpose(<<1, -2, 2> | <2, -1, 2> | <2, -2, 3>>);
R2 := Transpose(<<1, 2, 2> | <2, 1, 2> | <2, 2, 3>>);
R3 := Transpose(<<-1, 2, 2> | <-2, 1, 2> | <-2, 2, 3>>);
V := <3, 4, 5>;
MatrixVectorMultiply(R1, V);
MatrixVectorMultiply(R2, V);
MatrixVectorMultiply(R3, V);
t1 := <2225, 3648, 4273>;
t2 := MatrixVectorMultiply(1/R1, t1);
t3 := MatrixVectorMultiply(1/R3, t2);
t4 := MatrixVectorMultiply(1/R2, t3);
t5 := MatrixVectorMultiply(1/R1, t4);
t6 := MatrixVectorMultiply(1/R3, t5);
MatrixVectorMultiply(MatrixMatrixMultiply(MatrixMatrixMultiply(MatrixMatrixMultiply(MatrixMatrixMultiply(R1, R3), R2), R1), R3), V);
% - t1;
NULL;
 

restart;
_local(D, O);
with(Student:-MultivariateCalculus);
A := [0, 0, 0];
B := [a, 0, 0];
C := [a, b, 0];
D := [0, b, 0];
S := [0, 0, h];
O := [x, y, z];
lineSC := Line(S, C);
lineSD := Line(S, D);
H := Projection(A, lineSC);
K := Projection(A, lineSD);
OH := H - O;
OK := K - O;
OC := C - O;
M := Matrix([OH, OK, OC]);
O := eval(O, %);
R := simplify(Distance(O, H));
                               O

Student:-MultivariateCalculus:-LineApplyFunction([0,0,h],

  [Typesetting:-mtable(Typesetting:-mtr(Typesetting:-mtd(a, 

  rowalign = "", columnalign = "", groupalign = "", 

  rowspan = "1", columnspan = "1"), rowalign = "", 

  columnalign = "", groupalign = ""), Typesetting:-mtr(

  Typesetting:-mtd(b, rowalign = "", columnalign = "", 

  groupalign = "", rowspan = "1", columnspan = "1"), 

  rowalign = "", columnalign = "", groupalign = ""), 

  Typesetting:-mtr(Typesetting:-mtd(uminus0h, rowalign = "", 

  columnalign = "", groupalign = "", rowspan = "1", 

  columnspan = "1"), rowalign = "", columnalign = "", 

  groupalign = ""), foreground = "[0,0,0]", readonly = "false", 

  align = "axis", rowalign = "baseline", columnalign = "center", 

  groupalign = "{left}", alignmentscope = "true", 

  columnwidth = "auto", width = "auto", rowspacing = "1.0ex", 

  columnspacing = "0.8em", rowlines = "none", 

  columnlines = "none", frame = "none", 

  framespacing = "0.4em 0.5ex", equalrows = "false", 

  equalcolumns = "false", displaystyle = "false", side = "right", 

  minlabelspacing = "0.8em")],variables=[x,y,z],parameter=t,id=1)


Student:-MultivariateCalculus:-LineApplyFunction([0,0,h],

  [Typesetting:-mtable(Typesetting:-mtr(Typesetting:-mtd(0, 

  rowalign = "", columnalign = "", groupalign = "", 

  rowspan = "1", columnspan = "1"), rowalign = "", 

  columnalign = "", groupalign = ""), Typesetting:-mtr(

  Typesetting:-mtd(b, rowalign = "", columnalign = "", 

  groupalign = "", rowspan = "1", columnspan = "1"), 

  rowalign = "", columnalign = "", groupalign = ""), 

  Typesetting:-mtr(Typesetting:-mtd(uminus0h, rowalign = "", 

  columnalign = "", groupalign = "", rowspan = "1", 

  columnspan = "1"), rowalign = "", columnalign = "", 

  groupalign = ""), foreground = "[0,0,0]", readonly = "false", 

  align = "axis", rowalign = "baseline", columnalign = "center", 

  groupalign = "{left}", alignmentscope = "true", 

  columnwidth = "auto", width = "auto", rowspacing = "1.0ex", 

  columnspacing = "0.8em", rowlines = "none", 

  columnlines = "none", frame = "none", 

  framespacing = "0.4em 0.5ex", equalrows = "false", 

  equalcolumns = "false", displaystyle = "false", side = "right", 

  minlabelspacing = "0.8em")],variables=[x,y,z],parameter=t,id=2)


               /     2            2         / 2    2\ /
               |    h  a         h  b     h \a  + b / |
        HAssign|------------,------------,------------|
               | 2    2    2  2    2    2  2    2    2|
               \a  + b  + h  a  + b  + h  a  + b  + h \

                          /    2         2  /
                          |   h  b    h b   |
                   KAssign|0,-------,-------|
                          |   2    2  2    2|
                          \  b  + h  b  + h \

        /                2                       2               
        |               h  a                    h  b             
OHAssign|uminus0x + ------------,uminus0y + ------------,uminus0z
        |            2    2    2             2    2    2         
        \           a  + b  + h             a  + b  + h          

       / 2    2\ /
     h \a  + b / |
   + ------------|
      2    2    2|
     a  + b  + h \


            /                      2                    2  /
            |                     h  b               h b   |
    OKAssign|uminus0x,uminus0y + -------,uminus0z + -------|
            |                     2    2             2    2|
            \                    b  + h             b  + h \

          OCAssign(uminus0x + a,uminus0y + b,uminus0z)

M := Matrix(3, 3, {(1, 1) = Typesetting:-mrow(Typesetting:-mo("&\

  uminus0;"), Typesetting:-mi("x"), Typesetting:-mo("&plus;"), 

   Typesetting:-mfrac(Typesetting:-mrow(Typesetting:-msup(Typese\

  tting:-mi("h"), Typesetting:-mn("2")), Typesetting:-mo("&Invis\

  ibleTimes;"), Typesetting:-mi("a")), Typesetting:-mrow(Typeset\

  ting:-msup(Typesetting:-mi("a"), Typesetting:-mn("2")), 

   Typesetting:-mo("&plus;"), Typesetting:-msup(Typesetting:-mi(\

  "b"), Typesetting:-mn("2")), Typesetting:-mo("&plus;"), 

   Typesetting:-msup(Typesetting:-mi("h"), Typesetting:-mn("2"))\

  ))), (1, 2) = Typesetting:-mrow(Typesetting:-mo("&uminus0;"), 

   Typesetting:-mi("y"), Typesetting:-mo("&plus;"), Typesetting:\

  -mfrac(Typesetting:-mrow(Typesetting:-msup(Typesetting:-mi("h"\

  ), Typesetting:-mn("2")), Typesetting:-mo("&InvisibleTimes;"),\

   Typesetting:-mi("b")), Typesetting:-mrow(Typesetting:-msup(Ty\

  pesetting:-mi("a"), Typesetting:-mn("2")), Typesetting:-mo("&p\

  lus;"), Typesetting:-msup(Typesetting:-mi("b"), Typesetting:-m\

  n("2")), Typesetting:-mo("&plus;"), Typesetting:-msup(Typesett\

  ing:-mi("h"), Typesetting:-mn("2"))))), (1, 3) = Typesetting:-\

  mrow(Typesetting:-mo("&uminus0;"), Typesetting:-mi("z"), 

   Typesetting:-mo("&plus;"), Typesetting:-mfrac(Typesetting:-mr\

  ow(Typesetting:-mi("h"), Typesetting:-mo("&InvisibleTimes;"), 

   Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-msup(Type\

  setting:-mi("a"), Typesetting:-mn("2")), Typesetting:-mo("&plu\

  s;"), Typesetting:-msup(Typesetting:-mi("b"), Typesetting:-mn(\

  "2"))))), Typesetting:-mrow(Typesetting:-msup(Typesetting:-mi(\

  "a"), Typesetting:-mn("2")), Typesetting:-mo("&plus;"), 

   Typesetting:-msup(Typesetting:-mi("b"), Typesetting:-mn("2"))\

  , Typesetting:-mo("&plus;"), Typesetting:-msup(Typesetting:-mi\

  ("h"), Typesetting:-mn("2"))))), (2, 1) = Typesetting:-mrow(Ty\

  pesetting:-mo("&uminus0;"), Typesetting:-mi("x")), (2, 2) = 

   Typesetting:-mrow(Typesetting:-mo("&uminus0;"), Typesetting:-\

  mi("y"), Typesetting:-mo("&plus;"), Typesetting:-mfrac(Typeset\

  ting:-mrow(Typesetting:-msup(Typesetting:-mi("h"), 

   Typesetting:-mn("2")), Typesetting:-mo("&InvisibleTimes;"), 

   Typesetting:-mi("b")), Typesetting:-mrow(Typesetting:-msup(Ty\

  pesetting:-mi("b"), Typesetting:-mn("2")), Typesetting:-mo("&p\

  lus;"), Typesetting:-msup(Typesetting:-mi("h"), Typesetting:-m\

  n("2"))))), (2, 3) = Typesetting:-mrow(Typesetting:-mo("&uminu\

  s0;"), Typesetting:-mi("z"), Typesetting:-mo("&plus;"), 

   Typesetting:-mfrac(Typesetting:-mrow(Typesetting:-mi("h"), 

   Typesetting:-mo("&InvisibleTimes;"), Typesetting:-msup(Typese\

  tting:-mi("b"), Typesetting:-mn("2"))), Typesetting:-mrow(Type\

  setting:-msup(Typesetting:-mi("b"), Typesetting:-mn("2")), 

   Typesetting:-mo("&plus;"), Typesetting:-msup(Typesetting:-mi(\

  "h"), Typesetting:-mn("2"))))), (3, 1) = Typesetting:-mrow(Typ\

  esetting:-mo("&uminus0;"), Typesetting:-mi("x"), Typesetting:-\

  mo("&plus;"), Typesetting:-mi("a")), (3, 2) = Typesetting:-mro\

  w(Typesetting:-mo("&uminus0;"), Typesetting:-mi("y"), 

   Typesetting:-mo("&plus;"), Typesetting:-mi("b")), (3, 3) = 

   Typesetting:-mrow(Typesetting:-mo("&uminus0;"), Typesetting:-\

  mi("z"))})


Error, invalid input: eval received Matrix(3, 3, {(1, 1) = -x+h^2*a/(a^2+b^2+h^2), (1, 2) = -y+h^2*b/(a^2+b^2+h^2), (1, 3) = -z+h*(a^2+b^2)/(a^2+b^2+h^2), (2, 1) = -x, (2, 2) = -y+h^2*b/(b^2+h^2), (2, 3) = -z+h*b^2/(b^2+h^2), (3, 1) = -x+a, (3, 2) = -y+b, (3, 3) = -z}), which is not valid for its 2nd argument, eqns
       /     1       / 2  2      2        2  2    2  2    2  2
  R := |------------ \a  h  - 2 a  h z + a  x  + a  y  + a  z 
       | 2    2    2                                          
       \a  + b  + h                                           

            2      2  2      2        2  2    2  2    2  2
     - 2 a h  x + b  h  - 2 b  h z + b  x  + b  y  + b  z 

            2      2  2    2  2    2  2\\      
     - 2 b h  y + h  x  + h  y  + h  z /|^(1/2)
                                        |      
                                        /      
Why this error ? Thank you.

How to find all occurrences with Fibonacchi numbers?
100=89+8+2+1=89+5+3+1=55+34+8+2+1 etc...

fib := proc(n::nonnegint) option remember; if n <= 1 then n; else fib(n - 1) + fib(n - 2); end if; end proc;
zeck := proc(n::posint) local k, d; k := 2; while fib(k) <= n do k := k + 1; end do; d := n - fib(k - 1); if d = 0 then k - 1; else k - 1, zeck(d); end if; end proc;
zeck(100);
E := [fib(11), fib(6), fib(4)]; add(E[i], i = 1 .. nops(E));

Cong:=proc(n)
 local  a,b,An,Bn,Cn,Dn:
if n mod 2 = 1    
An:=0:     Bn:=0:    
for a  from (round(-sqrt(n/(2)))) to round(sqrt(n/(2)) )
do:           
for b  from (round(-sqrt(n)) )to round(sqrt(n) )do :               
if (sqrt(n-2*a^(2)-b^(2)) )/(32)isInteger                      
then An:=An+1                
elif (sqrt(n-2*a^(2)-b^(2)) )/(8) isInteger                      
then Bn:=Bn+1  fi:          
od:  od:
 if 2*An=Bn  
 return(True)  else  return(False)
fi: else if n mod 2 = 0 : 
Cn:=0:  Dn:=0:      
for a  from (round(-sqrt(n/(8)))) to round(sqrt(n/(8)) )
do :          
 for b  from (round(-sqrt(n/(2)))) to round(sqrt(n/(2))) do:                 
f (sqrt(n/(2)-4*a^(2)-b^(2)) )/(32)isInteger                      
then Cn:=Cn+1                
elif (sqrt(n/(2)-4*a^(2)-b^(2)) )/(8) isInteger
then Dn:=Dn+1 fi: od:  od:  
if 2*Cn=Dn:   
return(True)  else  return(False)fi:  
end:  

Why do I get this messge : Error, unterminated procedure. Thank you.

3 4 5 6 7 8 9 Last Page 5 of 31