Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I am interested and intrigued by optical illusions, such as that entitled 'Drawing A Hole in Line Paper

 - 3D Trick Art' by artist Jonathan Stephen Harris. Check out this YouTube video  to appreciate the following. Not being good at art, I tried to replicate this illusion using Maple..  The program below is merely a start towards this goal.  I have a procedure which draws the outline of the letter A.  Different letters have different peculiarities: I chose the letter A since it is relatively easy in that it does not have curves.  It does have a triangular region, so I created a separate procedure for that.  The whole letter A can be rotated through an angle phi.   Also I have drawn a grid of parallelograms for use as the lines drawn on the paper - but this I think has bugs. .

     The method I have used is rather long and messy, just using coordinate geometry, for the vertex points of the A, then rotating them through an angle phi.   Also in the program is a grid of parallelograms, for use in drawing the lines across the page.  That's as far as I've got.  Major problems I foresee is seeing/calculating where these lines meet the outline of the letter A, where vertical lines would be drawn.  Also, the artist draws in shading - how can that be done in Maple?  My attempt at the task has brought up some issues that there must be a simpler, better method of doing this.  eg first put the coords in a vector, and use matrix multiplication to calculate the new coords.  My method is long and error prone. 

   I'd appreciate some feedback about any attempts similar to this.  In my program I tried to fill the color of the polygon which was the boundary of the A, but it filled in the base trapezoidal region as well.  On top of that I failed to color the small triangular region a different color.  As always, any help or suggestions would be gratefully received. 

.   

restart:

printlevel:=0:

with(plots):

with(plottools):

# nrows= Number of rows ncols is one more than nrows

nrows:=8:ncols:=9:

x0:=0:y0:=0:theta:=Pi/12:psi:=Pi/3:
#Width, w, and length, l, of sides of the parallelograms/polygons c[i,j]

w:=2:l:=3:

 

for i from 0 to nrows do

  for j from 0 to ncols do

#c[i,j] := rectangle([i+1,j], [i,j+1], color=red):

c[i,j] := polygon([[x0,y0],[x0+i*w*cos(psi),y0+i*w*sin(psi)],[x0+i*w*cos(psi)+j*l*cos(theta),y0+i*w*sin(psi)+j*l*sin(theta)], [x0+j*l*cos(theta),y0+j*l*sin(theta)]], filled=true,color=red):

 

  end do:

end do:

plots[display](seq(seq(c[i,j], j=0..ncols),i=0..nrows), scaling=constrained);

#t1:=textplot([2,3,`David`]):

#for i from 0 to nrows do

#  for j from 0 to ncols do

   #c[i,j] := rectangle([j+1,i], [j,i+1], color=white):

#  end do;

#end do;

#pl1:=plots[display](seq(seq(c[j,i], i=0..ncols),j=0..nrows), scaling=constrained):

pl1:=plots[display](seq(seq(c[i,j], i=0..ncols),j=0..nrows), scaling=constrained):

 

plots[display](pl1);

 

# To draw the letter A

# Using proc poly_out:  also to put in initial coords (x0,y0) of lower left foot of A, then rotate the letter A through an angle of phi

#thet:=Pi/3:phi:=Pi/2:

# thet is angle the left "diagonal" makes with the horizontal.

# l is the length of the diagonals - ie the left and right hand sloping sides of the letter A

# w is width of the feet of the letter A.  (Both equal width)

# topl is the "top length" of the horizontal top part of the letter A.

# (x0, y0) are the coords of the bottom left point of the letter A.

# phi is the anti-clockwise angle of rotation about (0,0)

 

poly_out:=proc(thet,l,w, topl, x0, y0, phi)

local outA, outAr,trig, trigr,D,E,F,G, corr, eps:

#l:=10:thet:=Pi/3:w:=4:

#topl:=3:

eps:=3*w/4:corr:=.3*w:

trig:=polygon([[x0+(2*l*cos(thet)+topl)/2, y0+l*sin(thet)-eps],[x0+w+(l/3+corr*w)*cos(thet), y0+(l/3+corr*w)*sin(thet)],[x0+2*l*cos(thet)+topl-w-(l/3+corr*w)*cos(thet), y0+(l/3+corr*w)*sin(thet)]]):

 

trigr:=polygon([[(x0+(2*l*cos(thet)+topl)/2)*cos(phi)-(y0+l*sin(thet)-eps)*sin(phi),(x0+(2*l*cos(#thet)+topl)/2)*sin(phi)+(y0+l*sin(thet)-eps)*cos(phi)],[(x0+w+(l/3+corr*w)*cos(thet))*cos(phi)-(y#0+(l/3+corr*w)*sin(thet))*sin(phi),(x0+w+(l/3+corr*w)*cos(thet))*sin(phi)+(y0+(l/3+corr*w)*sin(th#et))*cos(phi)],[(x0+2*l*cos(thet)+topl-w-(l/3+corr*w)*cos(thet))*cos(phi)-(y0+(l/3+corr*w)*sin(th#et))*sin(phi),(x0+2*l*cos(thet)+topl-w-(l/3+corr*w)*cos(thet))*sin(phi)+( #y0+(l/3+corr*w)*sin(thet))*cos(phi)]], color=white,filled=true):

 

outA:=polygon([[x0,y0],[x0+l*cos(thet),y0+l*sin(thet)],[x0+l*cos(thet),y0+l*sin(thet)],[x0+l*cos(thet)+topl,y0+l*sin(thet)],[x0+2*l*cos(thet)+topl,y0], [x0+2*l*cos(thet)+topl-w,y0],[x0+5*l*cos(thet)/3+topl-w,y0+l*sin(thet)/3],[x0+l*cos(thet)/3+w,y0+l*sin(thet)/3], [x0+w,y0]]):

 

outAr:=polygon([[x0*cos(phi)-y0*sin(phi),x0*sin(phi)+y0*cos(phi)],[(x0+l*cos(thet))*cos(phi)-(y0+l*sin(thet))*sin(phi),(x0+l*cos(thet))*sin(phi)+(y0+l*sin(thet))*cos(phi)],[(x0+l*cos(thet))*cos(phi)-(y0+l*sin(thet))*sin(phi),(x0+l*cos(thet))*sin(phi)+(y0+l*sin(thet))*cos(phi)],[(x0+l*cos(thet)+topl)*cos(phi)-(y0+l*sin(thet))*sin(phi),(x0+l*cos(thet)+topl)*sin(phi)+(y0+l*sin(thet))*cos(phi)],[(x0+2*l*cos(thet)+topl)*cos(phi)-y0*sin(phi),(x0+2*l*cos(thet)+topl)*sin(phi)+y0*cos(phi)], [(x0+2*l*cos(thet)+topl-w)*cos(phi)-y0*sin(phi),(x0+2*l*cos(thet)+topl-w)*sin(phi)+y0*cos(phi)],

[(x0+5*l*cos(thet)/3+topl-w)*cos(phi)-(y0+l*sin(thet)/3)*sin(phi),(x0+5*l*cos(thet)/3+topl-w)*sin(phi)+(y0+l*sin(thet)/3)*cos(phi)],

[(x0+l*cos(thet)/3+w)*cos(phi)-(y0+l*sin(thet)/3)*sin(phi),(x0+l*cos(thet)/3+w)*sin(phi)+(y0+l*sin(thet)/3)*cos(phi)], [(x0+w)*cos(phi)-y0*sin(phi),(x0+w)*sin(phi)+y0*cos(phi)]], color=grey,filled=true):

 

 

 

plots[display](outAr,trigr, axes=none, scaling=constrained);  # view=[-l..l,-l..l]);

#outA & trig removed from display – these give the `upright` #letter A

end proc:

plot1:=poly_out(Pi/3,15,3,3, 0,0, Pi/15):

plots[display](plot1, pl1);

I'm just unable to see how this could be correct, if someone can take a look it would be much appreciated.

 


 

sum((piecewise(6 = k, 1, 6 <> k, 0)-3*frac((1/3)*N)*piecewise(6 = k+1, 1, 6 <> k+1, 0))*floor((1/3)*N*3^(k-floor(ln((1/3)*N)/ln(3))-1)), k = 1 .. floor(ln((1/3)*N)/ln(3))+1)

sum((piecewise(6 = k, 1, 6 <> k, 0)-3*frac((1/3)*N)*piecewise(6 = k+1, 1, 6 <> k+1, 0))*floor((1/3)*N*3^(k-floor(ln((1/3)*N)/ln(3))-1)), k = 1 .. floor(ln((1/3)*N)/ln(3))+1)

(1)

simplify(sum((piecewise(6 = k, 1, 6 <> k, 0)-3*frac((1/3)*N)*piecewise(6 = k+1, 1, 6 <> k+1, 0))*floor((1/3)*N*3^(k-floor(ln((1/3)*N)/ln(3))-1)), k = 1 .. floor(ln((1/3)*N)/ln(3))+1))

piecewise(k = 5, -3*(floor((-ln(3)+ln(N))/ln(3))+1)*floor(27*3^(-floor((-ln(3)+ln(N))/ln(3)))*N)*frac((1/3)*N), k = 6, (floor((-ln(3)+ln(N))/ln(3))+1)*floor(81*3^(-floor((-ln(3)+ln(N))/ln(3)))*N), 0)

(2)

``


 

Download mapleHELP.mw

Dear users! I need the help in attached file. Please see and fix it. I am waiting your positive answer.

File_to_help.mw

Dear All

I need to minimize a quadratic function with constraints, but i get

Error, (in Optimization:-QPSolve) unexpected parameters


restart;
with(Optimization);
with(plots);

obj := (c0-x)^2+(c1-(2/3)*x-(1/3)*y)^2+(c2-(1/3)*x-(2/3)*y)^2+(c3-y)^2;
cnsts := 32*x+19*y = 15*c0+18*c1+15*c2+3*c3;
          Minimize(obj, cnsts);

I would like to obtain the optimal parameter ( x,Y) that satisfies the minimization problem with constraints , and the results must depend on c0,c1,c2 and c3. 

Many thanks for your help

 

 

 

How to solve matrix in maple.

Example: Set A := Matrix(3, 3, [[2, -3, 1], [-3, 5, 0], [1, 0, 5]]). Find matrix L such that A = L^T*L.

I can solve by hand but how to use Maple?

I have a list L:=[[0,0,0], [1,0,0], [1,1,0], [0,1,0], [0,0,1], [1,0,1], [1,1,1], [0,1,1]] (8 vertices of a cube). How can I select four vertices of the list to make a regular tetrahedron?

Hello,

I am experiencing some trouble with the function Minimize of the Optimization package. I have some trouble understanding what Maple is doing with nice functions already.

f := (x-2)^2+1;
                                 2    
                          (x - 2)  + 1
Minimize(f, {x >= -2, x <= 2});
             [1., [x = HFloat(1.9999999999999998)]]
Minimize(f(x), {x >= -2, x <= 2});
                    [1., [x = HFloat(2.0)]]
g := proc (x) options operator, arrow; (x-2)^2+1 end proc;
            2    
x -> (x - 2)  + 1
Minimize(g, {x >= -2, x <= 2});
Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of  procedures
Minimize(g(x), {x >= -2, x <= 2});
             [1., [x = HFloat(1.9999999999999998)]]

Hello there!

I have just an elemental question. Given an equation as input, how could I write a procedure to know the variables involved in that equation? 

For example, my input is 2x+3y=0, and I would like to have the output  {x,y}.

Thanks in avance for the help!

Hi all,

I am attempting to have the piecewise function

Render using either mathML or Letex in maple, using the syntax:

f := piecewise(-Pi <= x and x < 0, 1, 0 <= x and x < Pi, 0);

la := latex(f);

mml := MathML[ExportPresentation](f);

 

Unfortunately, as you will notice the latex produces some really annoying "and" words amongst the code.  While the MathML produces some equally annoying "&wedge;", and symbols, amongst the code.

Any help would be appreciated.

 

Mark

Hello,

I have a question about the Import of .txt file:

I can import the following .txt, but everytime I want to convert in a matrix or something else, maple chrashes. 

I need some parts (smaller matrices) of this data (for example: all values from coloumn 200-400 and row 100-600)

I hope somebody can help me

Thanks 
Martin

-Validierung-Stahl-AI-.txt

 

 

Hey 

i want to solve these 3 eqations 

21000 = ((10/1000)/60)*4181*983*(x-y)

H = -((10/1000)/60)*4181*ln(1-((x-y)/(x-40)))

H = 124+102'ln(x-40)+(7+2*ln(x-40))

 

with the result of:

H,x,y

 

how do i do that?

 

Thanks

Hi everyone, I am trying to plot field lines but I face problem in plotting field plot. kindly help me if anyone can do it. Find the code in the attached file. Thank you.

Field_lines.mw

tomleslie 2300Mohsen 20 @Carl Love @Markiyan Hirnyk @maple fan 175 @asa12 405  @Adri van der Meer 1253 

restart;

f:=5*x^3-5*x+1;

5*x^3-5*x+1

(1)

s:=[solve(f)]; evalf(%);  # All the roots are real

[(1/30)*(-2700+(300*I)*219^(1/2))^(1/3)+10/(-2700+(300*I)*219^(1/2))^(1/3), -(1/60)*(-2700+(300*I)*219^(1/2))^(1/3)-5/(-2700+(300*I)*219^(1/2))^(1/3)+((1/2)*I)*3^(1/2)*((1/30)*(-2700+(300*I)*219^(1/2))^(1/3)-10/(-2700+(300*I)*219^(1/2))^(1/3)), -(1/60)*(-2700+(300*I)*219^(1/2))^(1/3)-5/(-2700+(300*I)*219^(1/2))^(1/3)-((1/2)*I)*3^(1/2)*((1/30)*(-2700+(300*I)*219^(1/2))^(1/3)-10/(-2700+(300*I)*219^(1/2))^(1/3))]

 

[.8788850663-0.2e-9*I, -1.088033915-0.2598076212e-9*I, .2091488484+0.2598076212e-9*I]

(2)

max(s);  # ?

Error, (in simpl/max) complex argument to max/min: (1/30)*(-2700+(300*I)*219^(1/2))^(1/3)+10/(-2700+(300*I)*219^(1/2))^(1/3)

 

type(s,list(realcons)); # Wrong, the type realcons should not be purely syntactic; or is it?

false

(3)

R:=convert(s,RootOf):

max(R);  #  For nested RootOfs fails

Error, (in simpl/max) complex argument to max/min: (1/30)*RootOf(_Z^3+2700-300*RootOf(_Z^2+1, index = 1)*RootOf(_Z^2-73, index = 1)*RootOf(_Z^2-3, index = 1), index = 1)+10/RootOf(_Z^3+2700-300*RootOf(_Z^2+1, index = 1)*RootOf(_Z^2-73, index = 1)*RootOf(_Z^2-3, index = 1), index = 1)

 

sort(s): evalf(%);  # Wrong

[.8788850663-0.2e-9*I, .2091488484+0.2598076212e-9*I, -1.088033915-0.2598076212e-9*I]

(4)

 

Workaround

 

S:=[seq(RootOf(f,x,index=i),i=1..3)];

[RootOf(5*_Z^3-5*_Z+1, index = 1), RootOf(5*_Z^3-5*_Z+1, index = 2), RootOf(5*_Z^3-5*_Z+1, index = 3)]

(5)

evalf(S);

[.2091488484, .8788850662, -1.088033915]

(6)

min(S);max(S);  # OK

RootOf(5*_Z^3-5*_Z+1, index = 3)

 

RootOf(5*_Z^3-5*_Z+1, index = 2)

(7)

sort(S);   # Wrong!

[RootOf(5*_Z^3-5*_Z+1, index = 1), RootOf(5*_Z^3-5*_Z+1, index = 2), RootOf(5*_Z^3-5*_Z+1, index = 3)]

(8)

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

r:=(sqrt(2)+I)^3 + (sqrt(2)-I)^3;

(2^(1/2)+I)^3+(2^(1/2)-I)^3

(9)

type(r,realcons);  # Purely syntactic?

false

(10)

type(expand(r),realcons);

true

(11)

max(r,13);  # Even for such a simple expression?

Error, (in simpl/max) complex argument to max/min: (2^(1/2)+I)^3+(2^(1/2)-I)^3

 

 


Download TryHarder.mw

So I've got a function and try to find an extrema (and there is one on the plot), but Maple gives me empty brackets.

First, earlier it gave me 2 x-coordinates with extrema (both empty), but now (after reloading) it gives one and empty.

Second, how do I set an interval, if I want to look for extrema from x=0 to x=1, for example? I tried extrema (V, {0,1}, x) and (V, {x=0, x=1}, x), but nothing seems to work.

2.mw

Hi everybody,

I use the Grid package to do intensive computations.

For some reason I'm ignorant about, the test case described in the Grid[Server][StartServer] 

 help page doesn't work with Maple 2015 (neither on Mac OS X, neither on Windows 7 ; here is the mw file run on MAC Os X)

Could someone explain me why (probably something I did not read with enough attention ... some license maybe) ?
Thanks in advance

GridServer.mw

First 854 855 856 857 858 859 860 Last Page 856 of 2219