tomleslie

13806 Reputation

19 Badges

14 years, 151 days

MaplePrimes Activity


These are replies submitted by tomleslie

@JAMET 

I said in my original response that I have absolutely no idea what construction you are trying to produc. Your latest comment is equally confusing.

For example, you state

leave fixed the circumscribed triangle P1P2P2

This makes no sense. There is no such thing as a "circumscribed triangle" in geometry. You can define a triangle P1P2P3 and then a "circumscribed circle", which is the circle that passes through the points P1, P2, P3. This is the green circle in my first answer

You further state

make mobile the triangle inscribed AM2 M3

This makes no sense. There is no such thing as a "inscribed triangle" in geometry.. You can define a triangle AM1M2 and then an "inscribed circle", which is the circle tangent to all three edges of that triangle.This is the blue circle in my first answer

Since I still have no idea what construction you are trying to produce, and you are incapable of explaining what you want, I have added a "stationary" triangle to my previous answer, (and relabelled some points)


 

  restart;
  with(geometry):
  with(plots):
  _EnvHorizontalName='x':
  _EnvVerticalName='y':
  R := 5.0:
  ang := evalf~([2/3*Pi, -3*Pi*1/4, -Pi*1/6]):
  seq( point( `||`(P, i),
              [ R*cos(ang[i]),
                R*sin(ang[i])
              ]
            ),
       i = 1 .. 3
     ):
  triangle( T1,
            [seq(`||`(P, j), j=1..3)]
          ):
  incircle(C1, T1):
  circumcircle(C2, T1):

  porism:= proc(t)
                local theta:=ang[1]+t,
                      A, M1, M2, L, II, T2,j;
              #
              # local point A is somewhere on the (global)
              # circumcircle C2
              #
                point( A,
                       [ R*cos(theta),
                         R*sin(theta)
                       ]
                     ):
              #
              # Get the tangent lines from (local) A to
              # the (global) incircle C1
              #
                TangentLine(L, A, C1):
              #
              # Find the intersection of these tangent lines
              # with the (global) circumcircle C2. Note that
              # each tangent line, intersects C2 at two points,
              # one of which is (local) point(A). So for
              # both tangent lines, determine the intersection
              # point whihc isn't A
              #
                intersection(II, L[1], C2):
                if   distance(II[1], A) > distance(II[2], A)
                then point( M1,
                            coordinates(II[1])
                          );
                else point( M1,
                            coordinates(II[2])
                          );
                fi:
                intersection( 'II', L[2], C2):
                if   distance(II[1], A) > distance(II[2], A)
                then point( M2,
                            coordinates(II[1])
                          );
                else point( M2,
                            coordinates(II[2])
                          );
                fi:
                triangle( T2,
                          [A, M1, M2]
                        ):
                display
                ( [ draw
                    ( [ P1(color=black, symbol=solidcircle, symbolsize = 12),
                        P2(color=black, symbol=solidcircle, symbolsize = 12),
                        P3(color=black, symbol=solidcircle, symbolsize = 12),
                        A(color=black, symbol=solidcircle, symbolsize = 12),
                        M1(color=black, symbol=solidcircle, symbolsize = 12),
                        M2(color=black, symbol=solidcircle, symbolsize = 12),
                        T1(color=black, thickness=4),
                        T2(color=red),
                        C1(color=blue),
                        C2(color=green)
                      ]
                    ),
                    textplot
                    ( [ [ coordinates(A)[], "A", align=[above, right], color=red],
                        [ coordinates(M1)[], "M1", align=[above, right], color=red],
                        [ coordinates(M2)[], "M2", align=[above, right], color=red],
                        [ coordinates(P1)[], "P1", align=[below, left]],
                        [ coordinates(P2)[], "P2", align=[below, left]],
                        [ coordinates(P3)[], "P3", align=[below, left]]
                      ],
                      align=[above, right]
                    )
                  ],
                  axes=none
                );
        end proc:
  nf:=60:
  display
  ( [ seq
      ( porism(j),
        j=0..evalf(2*Pi), evalf(2*Pi/nf)
      )
    ],
    insequence=true
  );

 

 


 

Download ponTheo2.mw

So

It is one line with two simple commands.

is better than one line with one simple command

So you want to

  1. read a file containing maple code, converting that code to a string
  2. parse the string to reproduce/execute the maple code

rather than

  1. read/execute a file containing Maple code

I guess if you like doing things the hard way..........

You cannot 'assign' to a procedure parameter within the procedure. A procedure parameter is supplied with arguments when the procedure is called. so in the code snip you provided, the following statements are invalid

A:= <x1,y1>;
B:= <x2,y2>;
P :=<x3, y3>; 

You also appear to have forwardquotes, rather than backquotes around H in the final line of the procedure - tricky to tell from a cut-and-paste, which is another reason for posting a worksheet.

If you do want to write you own routine to get the projection of a point on a line, then a functional version of your code is shown in the attached. Note that this does no error-checking for whether the projection is possible. You might want to consider when the calculation will fail!

It is also possible to perform the same calculation using te geometry() package as shown in the attached

  restart;
  ProjPL:= proc(P, A, B)
                local H, t:
                H:= A+t*(B-A);
                solve( (P-H)^+ . (B-A), t );
                return eval( H, t=% );
           end:
  ProjPL( <1, 1>, <2, 3>, <4, 5>);

Vector(2, {(1) = 1/2, (2) = 3/2})

(1)

  restart:
  _EnvHorizontalName:='x':
  _EnvVerticalName:='y':
  ProjPL:= proc( P, A, B)
                 uses geometry:
                 local P0, P1, P2, l, q:
                 point(P0, P[1], P[2]):
                 point(P1, A[1], A[2]):
                 point(P2, B[1], B[2]):
                 line(l, [P1, P2]);
                 projection(Q, P0, l);
                 return coordinates(Q);
           end proc:
  ProjPL( <1, 1>, <2, 3>, <4, 5>);

[1/2, 3/2]

(2)

 

Download proj.mw

 

I understand the problem. Supplied code seems to execute - see the attached.

Might be better if you upload a worksheet which illustrates your problem using the big green up-arrow in the Mapleprimes toolbar

  restart;
  A:= <x1,y1,z1>;
  B:= <x2,y2,z2>;
  P :=<x3, y3, z3>;
  H:=A+t*(B-A);
  solve( (P-H)^+ . (B-A), t );
  'H'=eval(H, t=`%` );

` restart`

 

Vector(3, {(1) = x1, (2) = y1, (3) = z1})

 

Vector(3, {(1) = x2, (2) = y2, (3) = z2})

 

Vector(3, {(1) = x3, (2) = y3, (3) = z3})

 

Vector(3, {(1) = x1+t*(x2-x1), (2) = y1+t*(y2-y1), (3) = z1+t*(z2-z1)})

 

(x1^2-x1*x2-x1*x3+x2*x3+y1^2-y1*y2-y1*y3+y2*y3+z1^2-z1*z2-z1*z3+z2*z3)/(x1^2-2*x1*x2+x2^2+y1^2-2*y1*y2+y2^2+z1^2-2*z1*z2+z2^2)

 

H = Vector[column](%id = 36893488148219079244)

(1)

 

 


 

Download prob.mw

pretty much the same construction, but uses the geometry() package


 

  restart;
  with(geometry):
  with(plots):
  _EnvHorizontalName='x':
  _EnvVerticalName='y':
  R := 3:
  ang := [0, (1/3)*Pi, 3*Pi*(1/4)+2/10, 7*Pi*(1/6)+4/10, 8*Pi*(1/5), 13*Pi*(1/7)]:
  seq( point( `||`(P,i), [R*cos(ang[i]), R*sin(ang[i])]), i=1..6):
  circle(cir, [ point(OO, [0,0]), 3]):
  seq( TangentLine( `||`(tang, i), `||`(P, i), cir), i=1..6):
  seq(intersection(`||`(Q, i), `||`(tang, i), `||`(tang, irem(i, 6)+1)), i=1..6):
  seq(segment(`||`(S, i), `||`(Q, i), `||`(Q, irem(i, 6)+1)), i=1..6):
  seq(line(`||`(L, i), [`||`(P, i), `||`(P, irem(i, 6)+1)]), i=1..6):
  seq(line(`||`(L, 6+i), [`||`(Q, i), `||`(Q, i+3)]), i=1..3):
  seq(intersection(`||`(P, i+6), `||`(L, i), `||`(L, i+3)), i=1..3):
  line(L10, [P7,P9]):
  display( [ draw( [P1(symbol=solidcircle, symbolsize=8, color=blue),
                    P2(symbol=solidcircle, symbolsize=8, color=blue),
                    P3(symbol=solidcircle, symbolsize=8, color=blue),
                    P4(symbol=solidcircle, symbolsize=8, color=blue),
                    P5(symbol=solidcircle, symbolsize=8, color=blue),
                    P6(symbol=solidcircle, symbolsize=8, color=blue),
                    P7(symbol=solidcircle, symbolsize=8, color=red),
                    P8(symbol=solidcircle, symbolsize=8, color=red),
                    P9(symbol=solidcircle, symbolsize=8, color=red),
                    S1( color=green, thickness=4),
                    S2( color=green, thickness=4),
                    S3( color=green, thickness=4),
                    S4( color=green, thickness=4),
                    S5( color=green, thickness=4),
                    S6( color=green, thickness=4),
                    Q1(symbol=solidcircle, symbolsize=8, color=black),
                    Q2(symbol=solidcircle, symbolsize=8, color=black),
                    Q3(symbol=solidcircle, symbolsize=8, color=black),
                    Q4(symbol=solidcircle, symbolsize=8, color=black),
                    Q5(symbol=solidcircle, symbolsize=8, color=black),
                    Q6(symbol=solidcircle, symbolsize=8, color=black),
                    L1( color=magenta, linestyle=dash),
                    L2( color=magenta, linestyle=dash),
                    L3( color=magenta, linestyle=dash),
                    L4( color=magenta, linestyle=dash),
                    L5( color=magenta, linestyle=dash),
                    L6( color=magenta, linestyle=dash),
                    L7( color=orange),
                    L8( color=orange),
                    L9( color=orange),
                    L10( color=blue, thickness=4),
                    cir
                  ]
                ),
             textplot( [seq( [ coordinates(`||`(P, i))[], convert(`||`(P, i), string)],
                             i=1..6
                           )
                       ],
                       'align' = {'above', 'left'}
                     ),
             textplot( [seq( [ coordinates(`||`(Q, i))[], convert(`||`(Q, i), string)],
                             i=1..6
                           )
                       ],
                       'align' = {'above', 'left'}
                     ),
             textplot( [ [ coordinates( P7)[], "beta"],
                         [ coordinates( P8)[], "gamma"],
                         [ coordinates( P9)[], "alpha"]
                       ],
                       'align' = {'above', 'right'}
                     )
           ],
           view=[-6..10,-15..6],
           scaling=constrained,
           size=[800,800],
           axes=none
       )

 

 

 

Download hexplot2.mw

"Indexed variable names"

fooled me. If you jut want suffixed names where the suffix may (or may not) be an inert subscript then as others have stated you need Maple's concatenation operators - either cat(), or ||.

When using the latter, I generally prefer to do so in prefix form - consider the "toy" examples in the attached

  seq( `||`(R, i)=i^2, i=1..10);
  seq( cat(R, i)=i^2, i=1..10);
  seq( `||`(R__, i)=i^2, i=1..10);
  seq( cat(R__, i)=i^2, i=1..10);
  

R1 = 1, R2 = 4, R3 = 9, R4 = 16, R5 = 25, R6 = 36, R7 = 49, R8 = 64, R9 = 81, R10 = 100

 

R1 = 1, R2 = 4, R3 = 9, R4 = 16, R5 = 25, R6 = 36, R7 = 49, R8 = 64, R9 = 81, R10 = 100

 

R__1 = 1, R__2 = 4, R__3 = 9, R__4 = 16, R__5 = 25, R__6 = 36, R__7 = 49, R__8 = 64, R__9 = 81, R__10 = 100

 

R__1 = 1, R__2 = 4, R__3 = 9, R__4 = 16, R__5 = 25, R__6 = 36, R__7 = 49, R__8 = 64, R__9 = 81, R__10 = 100

(1)

 

Download suff.mw

 checking the "backup" files which Maple produces about every 15minutes (by default).

On a windows machine, these backup files are usually stored in C:/Users/yourUserName/maple/Backup/ where you can browse for likely possibilities, either by file name or creation time. If you find any likely candidates, you can restore from the menus with File->RestoreBackup

the point T lies on another ellipse withe equation x^2/121 + y^2/81 - 2 = 0, as shown in the attached.

  restart:

  with(plots):
  with(geometry):
  _EnvHorizontalName := 'x':
  _EnvVerticalName := 'y':

  a := 11:
  b := 9:
  ellipse(el, x^2/a^2 + y^2/b^2 - 1):
  
  tg1:=(x*a*cos(t)/a^2 + y*b*sin(t)/b^2)^2 = 1:
  tg2:=(x*a*cos(t+Pi/2)/a^2 + y*b*sin(t+Pi/2)/b^2)^2 = 1:
  ellipse( e2, simplify(tg1+tg2)):
  Equation(e2);

  point(F1, coordinates~(foci(el))[1]):
  point(F2, coordinates~(foci(el))[2]):

  Fig:= proc(t)
             global a, b, el, e2, F1, F2;
             local t1 := t,
                   t2 := t+Pi/2,
                   M1, M2, L1, L2, L3, L4,
                   tag1, tang2, T, c1;
             uses geometry, plots:
             point(M1, a*cos(t1), b*sin(t1)):
             point(M2, a*cos(t2), b*sin(t2)):
             line(L1, [F1, M1]):
             line(L2, [F2, M2]):
             line(L3, [F1, M2]):
             line(L4, [F2, M1]):
             line( tang1, x*a*cos(t1)/a^2 + y*b*sin(t1)/b^2 = 1):
             line( tang2, x*a*cos(t2)/a^2 + y*b*sin(t2)/b^2 = 1):
             intersection(T, tang1, tang2):
             circle( c1, [T, distance(T, L4) ] ):
             display( [ textplot
                        ( [ [ coordinates(F1)[], "F1"],
                            [ coordinates(F2)[], "F2"] ,                         
                            [ coordinates(M1)[], "M1"],                          
                            [ coordinates(M2)[], "M2"],
                            [ coordinates(T)[],  "T"]
                          ],
                          align={"above",'right'}
                        ),
                        draw
                        ( [ c1(color=blue),
                            el(color=red),
                            e2(color=red, linestyle=dash),
                            M1(color=black, symbol=solidcircle, symbolsize=16),
                            M2(color=black, symbol=solidcircle, symbolsize=16),
                            T(color=black, symbol=solidcircle, symbolsize=16),           
                            L1(color=black),
                            L2(color=green),
                            L3(color=black),
                            L4(color=green),
                            tang1(color=blue),
                            tang2(color=blue),
                            F1(color=blue, symbol=solidcircle, symbolsize=16),                    
                            F2(color=red, symbol=solidcircle, symbolsize=16)
                          ]
                        )
                     ],
                     scaling=constrained,
                     axes=none
                   );
            end proc:
  nFig := 60:
  Figs := seq(Fig(2*Pi*i/nFig), i = 0 .. nFig):
  display(Figs, insequence = true);

(1/121)*x^2+(1/81)*y^2-2 = 0

 

 

 

Download ell3.mw

you do not upload the relevant worksheet, instead you cut and paste a few random commands. Am I supposed to be able to work out what this pile of garbage is expected to do?

If it is anything other than a simple animation of the construction which I prtoduced earlier ell.mw  here - then you are out of luck because the attached is based on the former

  restart:

  with(plots):
  with(geometry):
  _EnvHorizontalName := 'x':
  _EnvVerticalName := 'y':

  a := 11:
  b := 9:
  ellipse(el, x^2/a^2 + y^2/b^2 - 1):
  point(F1, coordinates~(foci(el))[1]):
  point(F2, coordinates~(foci(el))[2]):

  Fig:= proc(t)
             global a, b, el, F1, F2;
             local t1 := t,
                   t2 := t+Pi/2,
                   M1, M2, L1, L2, L3, L4,
                   tag1, tang2, T, c1;
             uses geometry, plots:
             point(M1, a*cos(t1), b*sin(t1)):
             point(M2, a*cos(t2), b*sin(t2)):
             line(L1, [F1, M1]):
             line(L2, [F2, M2]):
             line(L3, [F1, M2]):
             line(L4, [F2, M1]):
             line( tang1, x*a*cos(t1)/a^2 + y*b*sin(t1)/b^2 = 1):
             line( tang2, x*a*cos(t2)/a^2 + y*b*sin(t2)/b^2 = 1):
             intersection(T, tang1, tang2):
             circle( c1, [T, distance(T, L4) ] ):
             display( [ textplot
                        ( [ [ coordinates(F1)[], "F1"],
                            [ coordinates(F2)[], "F2"] ,                         
                            [ coordinates(M1)[], "M1"],                          
                            [ coordinates(M2)[], "M2"],
                            [ coordinates(T)[],  "T"]
                          ],
                          align={"above",'right'}
                        ),
                        draw
                        ( [ c1(color=blue),
                            el(color=red),
                            M1(color=black, symbol=solidcircle, symbolsize=16),
                            M2(color=black, symbol=solidcircle, symbolsize=16),
                            T(color=black, symbol=solidcircle, symbolsize=16),           
                            L1(color=black),
                            L2(color=green),
                            L3(color=black),
                            L4(color=green),
                            tang1(color=blue),
                            tang2(color=blue),
                            F1(color=blue, symbol=solidcircle, symbolsize=16),                    
                            F2(color=red, symbol=solidcircle, symbolsize=16)
                          ]
                        )
                     ],
                     scaling=constrained,
                     axes=none
                   );
            end proc:
  nFig := 60:
  Figs := seq(Fig(2*Pi*i/nFig), i = 0 .. nFig):
  display(Figs, insequence = true);

 

 

Download ell2.mw

@pgdv 

see the attached

interface(version);
simplify(sqrt((x^2 + y^2)/x)/sqrt(x^2 + y^2)) assuming x>0, y>0;

`Standard Worksheet Interface, Maple 2022.2, Windows 7, October 23 2022 Build ID 1657361`

 

1/x^(1/2)

(1)

 

Download simp.mw

@JAMET 

against using the big, green, up-arrow in the Mapleprimes toolbar to upload a worksheet?

See the attached

  restart:
  with(plots):
  with(geometry):
  _EnvHorizontalName := 'x':
  _EnvVerticalName := 'y':
  a := 11:
  b := 9:
  c := sqrt(a^2 - b^2):
  t1 := (3*Pi)/4:
  t2 := (-4*Pi)/5:
  ellipse(el, x^2/a^2 + y^2/b^2 - 1):
  point(M1, a*cos(t1), b*sin(t1)):
  point(M2, a*cos(t2), b*sin(t2)):
  point(F1, -c, 0):
  point(F2, c, 0):
  line(L1, [F1, M1]):
  line(L2, [F2, M2]):
  line(L3, [F1, M2]):
  line(L4, [F2, M1]):
  line( tang1, x*a*cos(t1)/a^2 + y*b*sin(t1)/b^2 = 1):
  line( tang2, x*a*cos(t2)/a^2 + y*b*sin(t2)/b^2 = 1):
  intersection(T,tang1,tang2):
  circle( c1, [T, distance(T, L4) ] ):
  display( [ textplot
             ( [ [ -c, 0, "F1"],
                 [ c,  0, "F2"] ,                         
                 [ coordinates(M1)[], "M1"],                          
                 [ coordinates(M2)[], "M2"],
                 [ coordinates(T)[], "T"]
               ],
               align={"above",'right'}
             ),
             draw
             ( [ c1(color=blue),
                 el(color=red),
                 M1(color=black, symbol=solidcircle, symbolsize=16),
                 M2(color=black, symbol=solidcircle, symbolsize=16),
                 T(color=black, symbol=solidcircle, symbolsize=16),           
                 L1(color=black),
                 L2(color=green),
                 L3(color=black),
                 L4(color=green),
                 tang1(color=blue),
                 tang2(color=blue),
                 F1(color=blue, symbol=solidcircle, symbolsize=16),                    
                 F2(color=red, symbol=solidcircle, symbolsize=16)
               ]
            )
          ],
          scaling=constrained,
          axes=none
       );

 

 

Download ell.mw

using the SAT solver, you might want to take a look at

https://www.maplesoft.com/applications/Detail.aspx?id=154483

where the solver is used to complete "The world's hardest Sudoku"

which you can try.

  1. Find a BVP for which the analytic solution (definitely!)  known. Compare this analytic solution, with a numeric solution of the same BVP. Any differences should be very small.
  2. Use Maple's odetest() command. Essentially this substitutes the proposed analytic solution into the original ODE, and returns 0 if the ODE is satisfied. If the ODE is not satisfied then it returns the "error" term, which is generally given by computing lhs(ODE)-rhs(ODE). Your propsed Anaytical_Solution fails this test.

Both approaches are illustrated in the attached.

solAna.mw

I suggest you learn the difference between indexed variables and suffixed variables.

Indexed variables (eg W[2], which will display as W2) refers to the second element of an indexable container W, which willl be a list, array, vector etc - something whose entries you can identify by the index

Suffixed variables (eg W__2, which will also display as W2) refers only to a name, which happens to have an inert suffix.

In your latest worksheet  Q4.mw, the assignment to eqs, contains all 'W' as  indexed variables (eg W[2]), but the call to indets() is only looking for variables W which are suffixed of which of course there are none

The attached contains two solutions - one where the variables you want are indexed and one where they are suffixed.

The final result in both cases is assigned to the indexable column vector W.

suffInd.mw

First 6 7 8 9 10 11 12 Last Page 8 of 207
´╗┐