Maple 7 Questions and Posts

These are Posts and Questions associated with the product, Maple 7

Padovan is a British architect, more of whom van be found by googling 'Padovan series'.

  The program below draws the first few equilateral triangles of sides of which are in a series something akin to the Fibonacci sequence.  P(n)=P(n-2)+P(n-3).  It starts 1, 1, 1, 2,...The program below outputs a display of the first few such triangles, but is very klutsy.  It has a "manual input" for the various triangles.  I wondered if there was a quick way of doing this perhaps using theseq command?

  Thanks in advance.  David

 

 

 

 restart:

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

#

#  Padovan

#

#  Series of equilaterla triangles of sides of length:

#  P(n)=P(n-2) + P(n-3)

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

with(plots):

with(plottools):

# etring_up draws an equilateral triangle of side s, pointing up with # [x0,y0] being the coords of the "western most" vertex.

etring_up:=proc(x0,y0,s)

local tt, h:

h:=s*sqrt(3)/2:

tt:=polygon([[x0,y0],[x0+s/2,y0+h],[x0+s,y0]], color=brown, linestyle=1, thickness=1);

plots[display]([tt], scaling=constrained);

end proc:

 

# etring_down draws an equilateral triangle of side s, pointing down

# with [x0,y0] being the coords of the "western most" vertex.

etring_down:=proc(x0,y0,s)

local tt, h:

h:=s*sqrt(3)/2:  #2*s/sqrt(3):

#Only difference between two procs is the minus sign in [x0+s/2,y0-h]

tt:=polygon([[x0,y0],[x0+s/2,y0-h],[x0+s,y0]], color=red, linestyle=1, thickness=1);

plots[display]([tt], scaling=constrained);

end proc:

#etring_down(0,0,2);

#etring_up(0,0,2):

plots[display]([etring_down(0,0,1),etring_up(0,0,1),etring_down(1/2,sqrt(3)/2,1),etring_up(1/2,-sqrt(3)/2,2), etring_down(3/2, sqrt(3)/2,2),etring_up(1/2,sqrt(3)/2,3), etring_down(-2, 2*sqrt(3),4),etring_up(-9/2,-sqrt(3)/2,5),etring_down(-9/2,-sqrt(3)/2,7),etring_up(-1,-4*sqrt(3),9),etring_down(2,2*sqrt(3),12),etring_up(-2, 2*sqrt(3),16),etring_down(-15,10*sqrt(3),21)], scaling=constrained);

I originally was trying to verify that the determinant of an nxn matrix of binomial coefficients is zero if n is a multiple of 6. A description of the coefficients is shown in my program below under Row 1, Row 2 etc, using the old fashioned notation for binomial coefficients nCr=n!/r!/(n-r)!    I came across this in the interesting book 'Single Digits: in praise of small numbers' by Marc Chamberland. page 167.

   My pathetic attempt is below.  I tried to create a 5 x 5 matrix of binomial coeffs.  There is a procedure shft which attempts to create the rows of the matrix: the rows are just shifted along.  I've been successful in obtaining two rows, then after that gave up:-(  Thinking I'd try something easier, I thought I'd find the determinant of the matrix using the determinant command in the linear algebra package - without success.

  Any help would be most appreciated. 

 

 restart:

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

# Matrix program - intro to learn matrices

# The proc shft shifts the elements of an array one to the right and the

# first becomes the last

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

with(plots):

with(plottools):

#with(linalg);

with(LinearAlgebra);

#a:=array([1, 2, 3, 4, 5]);

#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:=5:

a:=array([seq(binomial(n,i), i=0..n-1)]);

acopy:=array([seq(binomial(n,i), i=0..n-1)]);

 

#shift := (f::procedure) -> ( x->f(x+1) ):

#shift(a[1]);

shft := proc(a::array)

local i, b::array:

global n:

#printf("n=%d\n",n);

for i from 1 to n do

#printf("n=%d\n",n);

b[i]:=a[i]:

end do:

#nn:=n-1:

for i from 1 to n-1 do

if i<>n-1 then

a[i+1]:=b[i]:

      else

a[1]:=a[5]:

a[n]:=b[n-1]:

end if:

printf("In loop a[%d}=%5.3f\n", i, a[i]);

end do:

end proc:

 

shft(a);

for i from 1 to n do

#printf("n=%d\n",n);

   bnew[i]:=a[i];

printf("bnew[%d]=%d\n",i,bnew[i]);

end do:

bmatrix:=array(1,n,[seq(bnew[i], i=1..n)]);

 

#for m from 2 to n do

   #shft([seq(bmatrix[1,kk], kk=1..m)],[seq(bmatrix[1, k], k=1..n-m)]);

    shft(bmatrix);

printf("In for loop:  bnew[%d}=%5.3f\n", m, bnew[m]);

#end do:

#s:={seq((1,j)=eval(A[1,j]), j=1..n), (2,2)=1,(3,3)=1,(4,4)=1, (5,5)=1}:

s:={(1,1)=1,(1,2)=5,(1,3)=10,(1,4)=10,(1,5)=5, (2,2)=1,(3,3)=1,(4,4)=1, (5,5)=1}:

 

SSs:=Matrix(5,5,s);

determinant(SSs);

simplify(evalf @(determinant(SSs)));

Determinant(SSs,method=float);

 

#A := Matrix(2,2,[[9,9],[1,2]]);

print(`Printing matrix`);

#A[3,3]:=1;

A := Matrix(m,5,[[seq(acopy[i], i=1..5)],[seq(bnew[j], j=1..5)]]);

#end do;

for i from 1 to n do

  printf("a[%d}=%5.3f\n", i, a[i]);

end do:

 

The program below is of two circles in the design of a simple ear-ring: baasically a large circle with a circle of varying radius removed.  I have tried to display the animation with the position of the centreof mass, but the animation is too fast and "jittery".  I'd like to slow the animation down to better see if my calculations are correct.  Is there some way of doing this, other than the Animation/Slower/Faster keys?.

 

restart:

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

# Earing Two circles

# A small circle (sc) of radius r, is drawn inside and tangential to

# a bigger circle,(bc), of radius R.  The origin (0,0) is at the bottom of

# the big circle. The small circle is removed to obatain a shape in the

# form of an earing.  x_bar is the distance from the origin of the

# centroid.

# When the centroid is on the circumference of the small circle then the

# ratio R/r = the golden ratio 1.645(?)

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

with(plots):

with(plottools):

Digits:=4:

R:=20:

#r:=10:

#circles

#sc := disk([0,2*R-r], r, color=white):  #in for loop

bc := disk([0,R], R, color=red):

 

for r from 1 by 1 to R do

  x_bar:=eval((R^2+R*r-r^2)/(R+r)):

printf("x_bar =%4.2f   R/r =%5.3f\n", x_bar, R/r);

  sc[r] := disk([0,2*R-r], r, color=white):

  Pt[r]:=point([0,x_bar],color=black):

#plots[display](sc,bc, scaling =constrained);

#t1[r]:=textplot([4*R/3,4*R/3,cat("xbar",convert(x_bar, string))]):

Rat:=R/r:

t1[r]:=textplot([4*R/3,4*R/3,convert(x_bar, float)]):   t2[r]:=textplot([2*R,4*R/3,convert(Rat, float)] ):

 

  p[r]:= plots[display](Pt[r],sc[r],t1[r],t2[r],bc ):       

end do:
 

#for loop to give individual images

#for r from 1 to R do
 

plots[display]({seq(p[r], r=1..R)}, scaling=constrained,axes=none,insequence=true);


#animate({seq(p[r], r=1..R)},t=1..4, scaling=constrained,axes=none);  #,frames=50);

#plots[display]({p[r]},scaling=constrained,axes=none,insequence=true);

#end do;

The program below is a high school problem, related to the area a horse can graze, given it is tethered to a rectangular barn.  The level of difficulty is related to the length of rope.  

   I wanted to display some graphics of the field, barn and tethered horse - this latter being the most difficult.  I experimented with a .png picture of a plain silouhette of a horse, imported this into Photoshop, then saved it as a .pdf file, importing this into Maple,  I managed to import this into the worksheet, but I wanted a scaled down version of the horse in the program plots[display] section.  I was unsuccessful in this.  Undeterred, I decided to try and draw a version of a horse using the plots/plottools packages.  The resulting "horse" looks more like a cat, warthog,  mouse or chameleon! 

   I understand later versions of Maple are able to import graphic images.   I'd appreciate some feedback as to how easy this is, and the quality of the resulting images in Maple output.

Thanks,

    David  .  .    

 

restart:

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

# Horse tethered to barn - what area of grass?

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

with(plots):

with(plottools):

macro(palegreen=COLOR(RGB, .5607, .9372, .5607)):

col1:=`black`:

print(`A horse is tethered to the corner of a barn, 10 m wide and 20 m long.  Find the area`);

print(`the horse can graze, if the length of rope is:`);

print(` i.)   5 m   ii.)  25 m  amd iii.)  50 m`);

#Length of rope

L:=10:

#Dims of barn

len:=20:wid:=10:

#Position of bottom left corner of barn

x_barn:=50:y_barn:=50:

len:=20:wid:=10:

 

#dimensions of field

flen:=120:fwid:=110:

 

rect_barn:=rectangle([x_barn,wid+y_barn], [len+x_barn,y_barn], color=brown):

rect_field:=rectangle([0,fwid], [flen,0], color=palegreen):

 

#Position of horse

x0:=37:y0:=32:

a := 4: b := 2.5:

belli := ellipse([x0,y0], a, b, filled=true, color=col1):

legf:=line([x0-1,y0-2], [x0-2,y0-6], color=col1, linestyle=1, thickness=1):

legf2:=line([x0-2,y0-2], [x0-3,y0-6], color=col1, linestyle=1, thickness=2):

rleg:=line([x0+1,y0-2], [x0+2,y0-6], color=col1, linestyle=1, thickness=2):

 

rleg2:=line([x0+2,y0-2], [x0+3,y0-6], color=col1, linestyle=1, thickness=2):

head := polygon([[x0-6,y0+3],[x0-5,y0+4], [x0-2,y0+5], [x0-3,y0+2]], color=brown, linestyle=3, thickness=2):

tail:=line([x0+6,y0-4], [x0+4,y0+1], color=col1, linestyle=1,thickness=2):

 

a := arc([x0+13,y0+3], 15, Pi/2..Pi+.1, color=blue):

plots[display](a,tail,head,belli,legf,legf2,rleg,rleg2,rect_barn,rect_field, scaling=constrained, axes=none);

I ran the short program below in trying to understand how the read statement works.  The read statement output the expected values of a, b, c to the screen.  I was curious to find where it had stored the file named 'tempor', so inspected my hard drive in the directory where the program was stored - to find it wasn't there.  I then commented the a, b, c statements and the save command so the program is now as in the second version below:

 

 restart:

a:=2:b:=3:c:=4:

save a, b, c, "tempor";

read tempor;

eval(a);

 

  I ran this program, expecting an error message, but it gave me the same output as before.   I again unsuccessfully searched for the file.   I then turned the computer off after saving the program, rebooted and ran thhe same program below.  It output the same values as before.  I'm thinking that Maple creates a special file, and appends it to the program, something like a table.  I'm not quite sure how this would be used, as opposed to just stating te values of a, b,c in the program.

   Any advice or comments gratefully received.

David 

 

restart:

#a:=2:b:=3:c:=4:

#save a, b, c, "tempor";

read tempor;

eval(a);

The program below is meant to use the  solve command to find the sides a, b, c of a triangle, given the lengths of the three altitudes, hA, hB and hC.  This program came from a higher version of Maple and I wondered what the word 'explicit' is meant to do in the  Sol->[solve({hA=(...statement.  The output just gives the name Sol - when I would have liked it to either give a solution for the sides in terms of the altitudes hA,hB,hC - or numeric float values.  For the attempted values of the altitudes all being equal to sqrt(30/2, the triangle is equilateral of side 1.

  Any suggestions to get this to work in Maple 7would be most appreciated.

Thanks,

   David

 

 

> 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

 

I am trying to draw a tetrahedron and square based pyramid, having its triangular faces the same asthat of the tetrahedron.  While the geom3d package in Maple 7 has several polyhedra, a pyramid, or pentahedron(?) seem to be missing.  The closest is the octohedron - but this is two square pyramids "glued" together!   I'm totally bamboozled by the Polyhedron command with all its options.  Is it possible to somehow cut the octohedron in two, to get a pyramid?  Below is my Maple program, including at the end aplottools command to draw a separate ocotohedron.  

  Any help gratefully received.

     David

restart:
> #Puzzle Problem with tetrahedron and pyramid.  How many faces will
> #resultant polyhedron have when a triangular face of the pyramid is "glued" to  the tetrahedron.
> with(geom3d):

> print(`A pyramid and tetrahedron are shown: the triangular faces of each being the same dimensions. The`);
> print(`triangular face of the pyramid is attached to a triangular face of the tetrahedron.`);

> print(`How many faces does the resulting polyhedron have?`);
> print(`  a.) 5    b.) 6     c.) 7     d.) 8     e.) 9`);

> # octahedron, hexahedron, cube, icosahedron, dodecahedron - but pentahedron not supported in Maple 7 :-(
> RegularPolyhedron(d,[3,4],point(o,4,4,0),3):
> #dodecahedron(t,point(p,5,0,0),3):

> tetrahedron(t,point(p,5,0,0),3):
> #draw([d(color=red),t(color=green)],cutout=7/8,lightmodel=light4,
> draw([d(color=red),t(color=green)],title=`Tetrahedron & pyramid`,orientation=[45,45]);
> with(plottools):
> f := octahedron([0,0,0],1):  #, octahedron([1,1,1],0.5):
> plots[display](f,style=patch);

I am perplexed about the geometry and plots packages.  When starting a programme involving geometric shapes, how does one decide which to use?  ..Or can the two packages be used in the same programme?  To iiiustrate my question there is a text program below which draws a diagram of a large square, with a circle inscribed tangentially to the square.  There is then a further smaller concentric circle, with a square drawn inside; the vertices touching this circle.  (It isdesigned as a problem suitable for young high-school teenagers.)

   I wanted to fill in various regions of this diagram in colors red and green.  I believe the with(geometry) package does this easily.  However, as I'm more used to the with(plots) package I stuck to this.  To get the coloured regions I drew a sequence of colored lines.  I also drew a colored square (See    SmallSq:=[op(SmallSq),sq_small||ii]:   ) by drawing a seq of concentric squares.  At the end of my program there are two almost identical plots[display] commands.   The difference is that the first does not incude the SmallSq.  I was expecting the two displays to be identical, since I'd specified the color white.  The first display has a dark colored square.  Why?? .  

   .   The program is very klutsy!  I'm embarrassed to publish it:-(  The SmallSq is adequate for my purposes, but has several white spaces - almost dots - on the dark version.  The thickness and style of the lines was the widest possible  - perhaps I should have set the larger rarius R, to a bigger value?

   And I have a feeling this diagram could have been constructed ib the geometry package in far fewer lines of code!

As always, any comments, suggestions would be most appreciated.

  David

 

 

> restart:
> # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Maple 7
> # Area puzzle involving squares & circles
> #To Do:  fill areas with color
> #  Use segment command and seq to make a set of colored lines
> #NB  Numbering for lines L1 is 1,2,3,4 for N,E,S,West
> #    Numbering for lines L2 is 1,2,4,3 for N,E,S,West
> # # # # # # # # # # # # # # # # # # # # # # # # # # # #
> with(plots):
> with(plottools):
> print(`The diagram shows two squares and two circles.`);
> print(`The red and green regions are equal in area.`);
> print(`To find the ratio of the radius of the large circle to the
> smaller.`);

> #Doesn't seem to like a combination of geometry & with plots
> #with(geometry);
> r:=R*sqrt((4-Pi)/(Pi-2));  #for the pretty printout only!
> R:=49:
> r:=R*sqrt((4-Pi)/(Pi-2)):  #give r a numerical value
> c_big := circle([0,0], R, color=red):
> c_small := circle([0,0], r, color=green):
> sq_big := rectangle([-R,R], [R,-R], color=white):
> #sq_small := rectangle([-r/sqrt(2),r/sqrt(2)], [r/sqrt(2),-r/sqrt(2)],
> color=white):
> #y:=R/2:

> SmallSq:=[]:
> for ii from 1 to round(r) do
> sq_small||ii := rectangle([-ii/sqrt(2),ii/sqrt(2)],
> [ii/sqrt(2),-ii/sqrt(2)], color=white,linestyle=1 , thickness=3):
> SmallSq:=[op(SmallSq),sq_small||ii]:
> end do:

> Llines1:=[]:Llines2:=[]:Llines3:=[]:Llines4:=[]:
> for yy from 1 by 1 to R do
> l1||yy := line([-R,yy], [-sqrt(R^2-yy^2),yy], color=red, linestyle=1 ,
> thickness=3):
> l2||yy := line([sqrt(R^2-yy^2),yy], [R,yy], color=red, linestyle=1 ,
> thickness=3):
> l3||yy := line([sqrt(R^2-yy^2),-yy], [R,-yy], color=red, linestyle=1 ,
> thickness=3):
> l4||yy := line([-sqrt(R^2-yy^2),-yy], [-R,-yy], color=red, linestyle=1
> , thickness=3):
> #List of lines is Llines
> Llines1:=[op(Llines1),l1||yy]:
> Llines2:=[op(Llines2),l2||yy]:
> Llines3:=[op(Llines3),l3||yy]:
> Llines4:=[op(Llines4),l4||yy]:
> end do:
> first:=round(r*(sqrt(2))/2)+1:
> last:=round(r):
> L2lines1:=[]:L2lines2:=[]:L2lines2D:=[]:L2lines3:=[]:L2lines3Up:=[]:L2
> lines4:=[]:
> for yy from first by 1 to last do
> l2_1||yy := line([-sqrt(r^2-yy^2),yy], [sqrt(r^2-yy^2),yy],
> color=green, linestyle=1 , thickness=3):
> #l2_2||yy := line([yy,r/sqrt(2)],[yy,sqrt(r^2-yy^2)],  color=green,
> linestyle=1 , thickness=3):
> l2_2||yy := line([yy,sqrt(r^2-yy^2)],[yy,0],  color=green, linestyle=1
> , thickness=3):
> l2_2D||yy := line([yy,-sqrt(r^2-yy^2)],[yy,0],  color=green,
> linestyle=1 , thickness=3):

> l2_3||yy := line([-yy,-sqrt(r^2-yy^2)],[-yy,0],  color=green,
> linestyle=1 , thickness=3):
> l2_3Up||yy := line([-yy,sqrt(r^2-yy^2)],[-yy,0],  color=green,
> linestyle=1 , thickness=3):

> l2_4||yy := line([-sqrt(r^2-yy^2),-yy], [sqrt(r^2-yy^2),-yy],
> color=green, linestyle=1 , thickness=3):
> #List of lines is Llines
> L2lines1:=[op(L2lines1),l2_1||yy]:
> L2lines2:=[op(L2lines2),l2_2||yy]:
> L2lines2D:=[op(L2lines2D),l2_2D||yy]:
> L2lines3:=[op(L2lines3),l2_3||yy]:
> L2lines3Up:=[op(L2lines3Up),l2_3Up||yy]:
> L2lines4:=[op(L2lines4),l2_4||yy]:
> end do:


> plots[display](c_big,c_small,Llines1,Llines2,Llines3,L2lines1,L2lines2
> ,L2lines2D,Llines4, L2lines3,L2lines3Up,L2lines4,
> scaling=constrained);
> plots[display](c_big,c_small,Llines1,Llines2,Llines3,Llines4,L2lines1,
> L2lines2,L2lines2D,L2lines3,L2lines3Up,
> L2lines4,SmallSq,scaling=constrained);


Warning, the name changecoords has been redefined

Warning, the name arrow has been redefined


            The diagram shows two squares and two circles.


             The red and green regions are equal in area.


  To find the ratio of the radius of the large circle to the small\
        er.


                                     4 - Pi
                         r := R sqrt(------)
                                     Pi - 2
 

I'd like to find the harmonic mean of the lengths of the three altitudes of a triangle.  I believe this to be equal to the radius of the incenter of the triangle.  I haven't used the geometry package  much, but notice it has some interesting features like Harmonic mean. (Incidentally, it has a vertex, and vertices command, but these don't seem to be recognised in Maple 7 - not even in the Help section.)  I would normally tackle thissue  problem using coordinate geometry, and give a diagram of the triangle using the plots [display] command.  Id like some advice about the interactivity of commands in geometry and plots packages eg  can I find the coordinates of the base of an altitudemail using the geometry package?  There is an altitude command which gives the àltitude's equation.  For this the coding would be

:triangle(ABC, [point (A,0,0),point (B,,2,0), point (C,1,3)]:

altitude (hA1,A, ABC);

detail (hA1);

   I think I have answered my own question!  I see there is a DefinedAs command which would give me the coords.   Am I correct in thinking the geometry package is the best method of doing this.  Later I was hoping to display animation, to see how the Harmonic mean changes with varying different triangles.

Thanks for reading this and Happy New Year.

David  

How to plot an Elliptical Function of Third kind complete or incomplete, eg. EllipticPi(n,k) if n and k are not constants?

as The function I wish to plot and explore contains Elliptical Function of Third kind complete and incomplete with complicated form of n and k.

Please reply asap.

Regards

Hi, I am new in Maple. If I have an electric network as in the figure, I want to get the Transfer Function V2(s)/Vi(s) from this equation system:

Vi=R1.I1+V1

Vi=R2.I2+V2

I1-I2=C1.dV1/dt

I2=C2.dV2/dt

Which are the commands that I may write to get this?? Before hand, Thanks by your answers!

I wish to compare five letter words in a list of 5 letter words with a string like "*e*d*".  The asterisks represent unknown letters; the e and d, known letters.  I wish to compare this string with each word in the list and discard any words which do not match.  I would end up with a list of matching words eg ["fends", "sends", . . .]   Is there a string function to compare partial matches?  I've looked at the compare and match commands,  but they don't seem applicable.

   Any suggestions would be most appreciated.

Regards, David 

how i can simplify

(f(x[n])/Df(x[n]));
in code

restart;
taylor(f(x), x = gamma, 8);
f(x[n]) := subs([x-gamma = e[n], f(gamma) = 0, seq(((D@@k)(f))(gamma) = factorial(k)*c[k]*(D(f))(gamma), k = 1 .. 1000)], %);

1 2
f(gamma) + D(f)(gamma) (x - gamma) + - @@(D, 2)(f)(gamma) (x - gamma)
2

1 3 1 4
+ - @@(D, 3)(f)(gamma) (x - gamma) + -- @@(D, 4)(f)(gamma) (x - gamma)
6 24

1 5 1 6
+ --- @@(D, 5)(f)(gamma) (x - gamma) + --- @@(D, 6)(f)(gamma) (x - gamma)
120 720

1 7 / 8\
+ ---- @@(D, 7)(f)(gamma) (x - gamma) + O\(x - gamma) /
5040
2 3
c[1] D(f)(gamma) e[n] + c[2] D(f)(gamma) e[n] + c[3] D(f)(gamma) e[n]

4 5 6
+ c[4] D(f)(gamma) e[n] + c[5] D(f)(gamma) e[n] + c[6] D(f)(gamma) e[n]

7 / 8\
+ c[7] D(f)(gamma) e[n] + O\e[n] /

taylor(D(f)(x), x = gamma, 8);
Df(x[n]) := subs([x-gamma = e[n], f(gamma) = 0, seq(((D@@k)(f))(gamma) = factorial(k)*c[k]*(D(f))(gamma), k = 2 .. 1000)], %);

D(f)(gamma) + @@(D, 2)(f)(gamma) (x - gamma)

1 2 1 3
+ - @@(D, 3)(f)(gamma) (x - gamma) + - @@(D, 4)(f)(gamma) (x - gamma)
2 6

1 4 1 5
+ -- @@(D, 5)(f)(gamma) (x - gamma) + --- @@(D, 6)(f)(gamma) (x - gamma)
24 120

1 6
+ --- @@(D, 7)(f)(gamma) (x - gamma)
720

1 7 / 8\
+ ---- @@(D, 8)(f)(gamma) (x - gamma) + O\(x - gamma) /
5040
2
D(f)(gamma) + 2 c[2] D(f)(gamma) e[n] + 3 c[3] D(f)(gamma) e[n]

3 4
+ 4 c[4] D(f)(gamma) e[n] + 5 c[5] D(f)(gamma) e[n]

5 6
+ 6 c[6] D(f)(gamma) e[n] + 7 c[7] D(f)(gamma) e[n]

7 / 8\
+ 8 c[8] D(f)(gamma) e[n] + O\e[n] /

(f(x[n])/Df(x[n]));
this last term did not use f(x[n]) value from above to solve it. plxx help if any one can solve it...

how i can find order of convergence of newton method by expanding taylor series?? plz send me code???

 

 

Hi

    The following code displays values of the subscripted variables slf[], a positive integer, and a string variable filler[] which is just a set of spaces depending on how big the corresponding value of slf[] s.  This is to make the printout lined up nicely.  

printf("%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d\n", filler[1],slf[1],filler[2],slf[2],filler[3],slf[3],filler[4],slf[4],filler[5],slf[5],filler[6],slf[6],filler[7],slf[7],filler[8],slf[8],filler[9],slf[9],filler[10],slf[10]);

   This works fine,but thought there might be a better way.  I tried:

printf("%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d\n",seq(filler[k],slf[k],k=1..10));

but this came up with an error message.  Is there  a way of doing this more efficiently?

thanks,   David 

 

1 2 3 4 Page 3 of 4