das1404

135 Reputation

6 Badges

12 years, 46 days

MaplePrimes Activity


These are replies submitted by das1404

@Kitonum 

Here is the full Valentine program as promised.

D

restart;

with(plots):

N := 92:   #192

t1:=textplot([-.5,4.5,`Betty`]):

A := seq(plot([[.85*sin(t)^3-2+1.25*i/N, .85*(13*cos(t)*(1/15)-(1/3)*cos(2*t)-2*cos(3*t)*(1/15)-(1/15)*cos(4*t)), t = 0 .. Pi*i/N], [-.85*sin(t)^3-2+1.25*i/N, .85*(13*cos(t)*(1/15)-(1/3)*cos(2*t)-2*cos(3*t)*(1/15)-(1/15)*cos(4*t)), t = 0 .. Pi*i/N], [sin(t)^3+2-1.25*i/N, 13*cos(t)*(1/15)-(1/3)*cos(2*t)-2*cos(3*t)*(1/15)-(1/15)*cos(4*t), t = 0 .. Pi*i/N], [-sin(t)^3+2-1.25*i/N, 13*cos(t)*(1/15)-(1/3)*cos(2*t)-2*cos(3*t)*(1/15)-(1/15)*cos(4*t), t = 0 .. Pi*i/N], textplot[-.5,1.5,`Betty`]], color = red, thickness = 5, view = [-2.3 .. 2.4, -2.2 .. 2]), i = 1 .. N):

#A:=A union t1:

##P[i]:=textplot([(`+`(T[i][])/3)[],S[i]], font=[TIMES,ROMAN,8]);

##od;

# font=[times,`if`(i<=3,12,14)]

##plots[display](seq(L[i], i=1..n), seq(polygon(T[i]), i=1..n),seq(P[i], i=1..n),scaling=constrained, axes=none);

 

plots[display](A, insequence = true, scaling = constrained, axes = none, title ="Alf & Betty" );

@Kitonum

Hi

  Since last writing I have managed to get Maple 7 to interpret the Padovan program.  There are some  minor issues like the greater choice of standard colors.  Itt doesn't have 'lightyellow',  for example.  (As an aside, I'm concerned about my eyesight as the 'lightyellow' triangles in your later Maple version output seemed a greyish hue to my eyes!)  

   It balked at the `if` command used in both the font and color choices.  It seems this is a useful addition to later versions of Maple.

 font=[times,`if`(i<=3,12,14)] Maple 7 seems to even be finicky about 'times' being in lower case.
In the Padovan program you use this statement

 P[i]:=textplot([(`+`(T[i][])/3)[],S[i]], font=[TIMES,ROMAN,8]);

in a loop.  I'm particularly intrigued with the use of `+`.  I searched for helpon this under 'arithop' and found a posting on the Maple Primes site from March 31 2012.  

A:=Vector(6,c):  d:=convert(A,`+`);

outputs c(1)+c(2)+...   ...+c(6)

  I recently posted about a Valentine program involving the cardioid and lemniscate.  It used insequence and output an animation of two hearts coming together.

In this Valentine program there is long statement of the coordinates, starting:

>A := seq(plot([[.85*sin…..

and ending

 ...Pi*i/N], textplot[-.5,1.5,`Betty`]], color = red, thickness = 5, view = [-2.3 .. 2.4, -2.2 .. 2]), i = 1 .. N):

EXCEPT for the textplot[-.5,1.5,`Betty`] which I added.  I was hoping to put some text, namely say 'Alf' and 'Betty' by the hearrts - or even have the names written in the hearts as the two hearts merge.  Maple didn't come up with a syntax error, as I'd expected, but neither was there any textplot output when the animation was run.

  I might write again with thefull Valentine program.  In the meantime I'd appreciate your comments on inserting the textplot command into an animation.

David 
 

 

 

@Robert Israel 

Thanks again for much simpler, shorter version.

David

David 

 

@acer 

Thanks for all your valuable information and advice.  I've been tired with the temperature here of around 29C, but will look at your suggestions when it cools - probably around midnight!

David

@acer 

Thanks for your prompt answers.  Regards running the program, what I meant was that I merely pressed the 'Enter' key.  There is a restart command at the start of the code, so I imagined that all variables etc would be reset and the output would be exactly the same each time - but you are saying this is not necessarily the case.  I haven't yet tried out your s=`s` etc suggestion, but recall that in the program there is the union set operator used  with backquotes - `union`.  I'm also in the process of sending the program to the technical people at Maple: they have asked for a copy.

    I'm not familiar with functional operators and your one line program blew me away!  In the program below I was trying to get my head around creating another matrix, K, using what I thought was simpler code than the binomial.function.  To my dismay it produced a 2 x 4 matrix, and it's taken me a while to figure out what was happening.  In the code for matrix B (i,j) is just assigned a numerical value, while in matrix K, the cell is being replaced by a 1 x 2 vector/array.  I'm rather embarrassed at how long it took me to igure that out!:-(  

   Another question was how to multiply matrices eg matrix C is the product of M(2) and B(2).  The product is given in symbolic form.  I first tried to put   C:=eval(Multiply(M(2),B(2)));  which didn't do anything.   Later I realised the M(2) and B(2) were obtained from the functional operator, so made copies of tthe matrices, eg C1:=C:and this worked fine.

   Again thanks very much for your help.

   David

> restart:

# # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Matrix program - intro to learn matrices

#

# From 'In praise of Small Digits' by Marc Chamberland p 167

# # # # # # # # # # # # # # # # # # # # # # # # # # # #

with(LinearAlgebra):

#Row 1   1 nC1  nC2  nC3…    …nC(n-1)

#Row 2   nC(n-1)  1  nC1…      …nC(n-2)

#Row 3  nC(n-2)  nC(n-1)  1…  …nC(n-3)

#...

#Row n  nC1  nC2 nC3…        …1

 

M:=n->Matrix(n,(i,j)->binomial(n,i-j mod n)):

M(2);

LinearAlgebra:-Determinant(M(2));

B:=n->Matrix(n,(i,j)->binomial(n+j,i+j mod n)):

K:=n->Matrix(n,(i,j)->(n+j,i+j mod n)):

print(`Matrix B`);

B(2);

C:=Multiply(M(2),B(2));

E:=Multiply(B(2),M(2));

print(`Inverse matrix of E`);

E^(-1);

F=Multipy(C,E);

G=Multipy(E,C);

K(2);

  I entered Acer's three line code at the beginning of my program, and was amazed at how fast it works.  For n=12 the output from Acer's code for Maple 7 is:

    12 x 12 Matrix

Data type: anything

Storage: rectangular

Order: Fortran order

     ...the above being enclosed between matrix type square braces.  Then there was a zero - the correct determinant of the matrix. My initial thought was that this couldn't be right because it took such a short time to answer.  In maple 7 this differing format comes in at n=11; for lower values the whole numeric matrix is displayed.

  It's rather academic now, but my question as to the erratic output behaviour of my program has not been answered.  I suspect it is to do with the seq command and sets.  Sets are not ordered, so the interaction with other commands may not be consistent.  I might try and contact the Maple technical team to see if they agree with this.

   Thanks again.

   David  

@tomleslie 

Maple 7 balked at the following code:

A[1,..]:=Vector([seq(binomial(n,i), i=0..n-1)]):

   Presumably this A[1,...] is later version  shorthand for the matrix A.  I can find a workaround in this case using for loops.  Also Maple 7 didn't recognise the command CircularShift

  A[j,..]:=ArrayTools:-CircularShift(A[j-1,..],1);

  In the matrix in question, it is symmetric about the main diagonal, so I used that property in my code.

Again, thanks for your help.  While the commands didnt' work in version 7, your code inspired me to find a Maple 7 solution!  

 

 

    

 Thanks Acer for your program and comments.  Sadly, I have only just found your reply:-(  I did try the program tomleslie gave, but it is too sphisticated for Maple 7.  I was going to do a separate post, as I have different questions.  The program below seems to work in Maple 7, but the output is not consistent.  At present n=4 and the matrix displayed has some zero elements.  If the same program is run again the matrix elements differ again.  If you put n=2 then it likely gives the correct matrix - but sometimes it gave the 2 x 2 identity matrix.  For n=12, it appeared to have storage problems.  I'm using the `union` operator, but the connection between items in sets s, u and v bear little relation to the matrix entries.

    I'm unsure whether there is a fault in my program, or a bug with Maple software?  The matrix output is sometimes correct - but run it again and the output changes.  Weird?!

Again any help would be most appreciated.

David 

 

restart:

# # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Matrix program - intro to learn matrices

# From 'In praise of Small Digits' by Marc Chamberland p 167

# # # # # # # # # # # # # # # # # # # # # # # # # # # #

 

with(LinearAlgebra):

#Row 1   1 nC1  nC2  nC3…    …nC(n-1)

#Row 2   nC(n-1)  1  nC1…      …nC(n-2)

#Row 3  nC(n-2)  nC(n-1)  1…  …nC(n-3)

#...

#Row n  nC1  nC2 nC3…        …1

n:=4:

 

for j from 1 to n do

s[j]:={seq(  (j,i)=binomial(n,n-j+i), i=1..n)};

u[j]:={seq(  (i,j)=binomial(n,n-j+i), i=1..n)};

 

od:

s:=`union`(seq(  s[i], i=1..n));

u:=`union`(seq(  u[i], i=1..n));

v:=s union u;  #`union`(s,u);

 

A:=Matrix(n,n,v);

 

LinearAlgebra:-Determinant(A);

 

 

Output:

@tomleslie 

Thanks heaps!  I thought here must be a shorter method.

David

I should have looked in Maples archives earlier.  There's an answer by Carl Love on the use of the Determinant command.

LinearAlgebra:-Determinant(M);  works fine!   I notice it is fussy about the spelling - determinant doesn't work.

Thanks.

  David

Thanks for that.  I haven't unfortunately been able to get it working in Maple 7.  Some minor things like symbol=solidcircle, and paraminfo it doesn't recognise.  I'm not sure if the plots, animate command is recognised in Maple 7.

     I used to think that the t in the animate command stoood for time, but was blown away when I used the binomial example in the Help section.  I'd always thoughht of the binomial being the integer coefficients, but Maple is presumably using the gamma function to calculate non-integer factorials.

  David

Thanks Kitonum.  Don't know how I managed to miss this post first time round - maybe it was so short.  It works just as you said.  I need to do a bit of homework on those "magic arrows" - or 'functional operators" as Maple calls them.

Thanks again.

   David

Thanks for your comments.  Sadly, my initial joy and exuberance has been dashed because your programs don't work in Maple 7.  For example the  Sol:=[eval(solve....    ....explicit][2];  statement isn't being recognised as intended in your version of Maple.  There is no mention of explicit in the Maple 7 documentation (apart from differentiation), yet Maple does not come up with an error message.  For the [2] it seems to take this as a subscript, and in the "solutions" it just returns Sol or Sol, with a subscript 2.

    Similarly with the Miquel 5 circle program, I can't get that to work either.  I have the start of my own version, which at present just shows the five circles arranged around the circle.  I'll try and incorporate some of your program ideas.  Looking at your code, you havestuck to sequences i=1..5.  I would have put the number of circles as nocirc:=5  and all portions of the program would refer to this.  Then one could alter the value to nocirc:=6, 7, 8... and see what patterns emerge - if any?

    I recently came across formulae for the lengths of angle bisectors and medians, and your Maple program has given the rather horrendous formula for the sides given altitudes.  I might try and see if there are formulae for the sides given combinations of these eg a median length, an altitude and an angle bisector length.  Your program on altitudes could be modified easily to answer these questions.  I might have to consider getting a latest version of Maple - but I still have not mastered Maple 7.:-(

      Thanks again for your time and patience.

   David    .

Thanks Kitonum for the awesome program!

   Regards the solve command I am OK now when the output is numbers ie floating point.  But what about symbolic program output?  Below is some Maple code which takes the three altitude equations - hA, hB, hC - and I was expecting a formula for for the lengths of sides, a, b,c in terms of the altitudes hA, hB, hC.

This is solving three simultaneous equations.  I decided to do the math by hand, by eliminating b and c and obtaining an expression for a in terms of the altitudes.  To my surprise the 'a' divided out and I was left with:

   hC=hAhB/{(hA-1)(hB-1)-1}

   I checked my working in the 3-4-5 right angle triangle and it worked.  However, checking it in the equilateral triangle of side 1: a=b=c=1; hA=hB=hC=sqrt(3)/2 hC was negative!

   It seems the equations are linearly dependent, so as far as Maple is concerned it may be unable to find unique answers?  I aplologise for taking your time, but I'm embarrased about putting a new post as there may be something very simple I'm missing.

     Given two altitudes, the third is specified by my above formula - or there is something about the triangle which must hold, for the formula to work.  I can't seem to visualise this geometrically.  Is there something I'm not seeing?  Any help/comments would be most appreciated.

 

   
restart:

# # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Altitude exploration 

# Trying to obtain expressions for the sides a,b,c of a triangle
# given the altitudes.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # #

#with(plots):

#with(plottools):

#with(geometry):

Sol->[solve({hA=(a+b+c)/a, hB=(a+b+c)/b, hC=(a+b+c)/c},{a,b,c}  )];  #,explicit)];

#  ???Is explicit needed?? Is it a Maple 7 feature?

 

abc:=simplify(eval(Sol,[hA=sqrt(3)/2,hB=sqrt(3)/2, hC=sqrt(3)/2]));  #should give a=b=c=1

gf:=eval(Sol, a=1);

 

Warning, the name changecoords has been redefined

 

3 4 5 6 7 8 Page 5 of 8