janhardo

695 Reputation

12 Badges

11 years, 39 days

MaplePrimes Activity


These are replies submitted by janhardo

@vv 

Thanks

Can't follow the proof , because i don't know what the intended use for some commands is ( F,Sx and S )

Is it a proof by induction ?

Also the task introduce a integral and suggest to expand the integrand in a serie for getting  also a proof ?

@tomleslie 
Thanks!

I use also help in Maple, yes
Your explanation should also to be read in the manual ?

@tomleslie 

Thanks 

It is all understood now with the graphs, but suppose should i try to program this, then i need the plots of the left-hand-right-hand and mid-sum, that's i what a mean there.
My sentence was not complete, sorry. 

----------------------------------------------------

One command seq has a question : there is a  [ ] included  :  a list-building operator to initialize a list construction ? 

seq
                   ( [ [ X[i],   Y[i+1] ],
                       [ X[i+1], Y[i+1] ]
                     ][ ],
                     i=0..N-1
                   ),
--------------------------------------------

Also filling 1 Array Ymid  is little bit complicated with nested ~  


Ymid:=f~(X+~(b-a)/(2*N)); # X+ 1/2 partition 
indeed powerful with only this ~ symbool to do this

@janhardo 

Amazing programming to see the whole picture.

But using a drawing of the 3 riemann sums is needed (for me ) to see the structure of the points of the tread-riser plot

@tomleslie 

Thanks

Well, i do have some  experience with a simple procedure making and thougth that one from @ CarlLove is a advanced one not for a beginner like me.

But thougth from making a procedure  from you code example seems to me easier to follow.
Yes, i think i can follow it.

Works great with bookexamples!

@tomleslie 

Thanks!

That look' s great : the tread-riser patern is clearly to see for the Riemann sum cases.

But i you are this far in the programming: the final step to a procedure and to make it general is not far anymore ?
(Although it is not asked in the task)

Note: it is not about using maple in-built command, because it is exercise in programming.
Although it could be handy to use them.

It is another programming style you used then in the book i showed, but that's good..


 

@Carl Love 

Thanks

Its simple idea : a tread-riser, but i can't figure it out to plot  

@acer 

Thanks

Its all about clearity
For this Riemann sum (right hand rule )example it is drawing 3 plots ( 2 verical lines:interval and the tread-riser outline sements )

Well, how to get the points for the plot( seq( points), i=1..10) ?  
 

@acer 
Thanks

On the the frontpage is written: An introduction to Programming using Maple

There is lot help in the book how Maplecommands can be used in this book.
Indeed it is not for learning how to use maple , their must be some base understanding for finding you way in Maple

Also as the authors note : Often the code for doing a given task can be made clearer by using arrays even though the task can be done without them.

Ofcourse clarity comes at the expense of using storage space in memory.
Examples shows that it is often necessary to sacrify this storage space by creating arrays, because the values of xi,yi,i=0..,N , are needed not only needed in calcullation  of sums ( example) , but also at other places in the code. 

Is memory these days a issue on high end computer ?

It could be translate it to moderner seq and map and other techniques? in maple as i have seen in another your example of task solutions. 
I will analyze how it can be done on the "modern" maple way

 

@Carl Love 

Thanks

This is a procedure you made, but that's not needed in this task ( even before the procedure is introduced in the book )
Its too difficult for me now in the learning process to understand the procedure.

.
I enclosed the worksheet where i am struggling to try to getting to draw the magenta lines for the Riemann rightsum rule

Above is the Riemann lefthand rule drawed with the tread-riser outline 

Note: the tread-riser  is made out of 3 points connected with linesegments
There is no +1:  y -value possible yet in the code what i needed to get a point for the tread riser step 

The undersum (rectangle under graph) starts at X0 and the uppersum(rectangle above graph)  by X1 for calculating the sum.  

There are 3 plots : a vertical line at a and a vertical line at b and the tread riser step    


 

restart;with(plots):

 task 1 (a)

 

N:=10: # code op blz 47 parabool (x^2+1)

dX:=(b-a)/N: #

X:=a: Y:=f(X): s:=0:

for i from 1 to N do

   s:= s+Y*dX; # geen i,is f(x).dx gesommeerd

   X:= X+dX; Y:=f(X); #geen i

end do:

 

 

Wat doe de code hierboven ? : de loop telt  y.dx  (f(x).dx)  op  in een som s
s= s+ y0.dx = y0.dx
s = s+y1.dx = y0dx + y1.dx

s=  .........

s= s+ yN-1.dx = y0.dx+y1.dx+ ....+yN-1.dx (alg )

 

task 1(b)Via Array

X:=Array(0..N); Y:=Array(0..N);

`Array(0..10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0})`

 

`Array(0..10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0})`

(1)

dX:=(b-a)/N:

X[0]:=a: Y[0]:=f(X[0]):

s:=0:

for i from 1 to N do

  s:= s+Y[i-1]*dX; #linkersom

  X[i]:= X[i-1]+dX; Y[i]:=f(X[i]);

end do:

 

 

xi en yi worden opgeslagen in een array  en word ook een som gemaakt s als in het voorgaand vb

task 2

 

vb 3.2 : riemann som met graphics (linkersom)

with(plots,display);

[display]

(2)

Before we can do any calculations, we need a function  f  to work with, so we choose the following polynomial function and use the interval [0, 1]:

 

a:=0;b:=1;

0

 

1

(3)

 

f:=x->x^2-x^4+1;

proc (x) options operator, arrow; x^2-x^4+1 end proc

(4)

 

The staircase pattern consists of "treads" and "risers" and we will produce the plots of these as we do the calculations.

The initial computations are done with N =10. The partition points x are stored in an array X and the values y = f (x) are stored in an array Y. The tread/riser plots are stored in an array called tr.

 

N:=10;

10

(5)

X:=Array(0..N); Y:=Array(0..N);tr:=Array(1..N);

`Array(0..10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0})`

 

`Array(0..10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0})`

 

Array(%id = 18446745233214237262)

(6)

 

Next we calculate Delta*x = (b - a) / N, assign values to x[0],  y[0] = f (x[0]), initialize the summation variable s, and plot the left-hand vertical part of the outline, which is stored in ver0.

 

dX:=evalf((b-a)/N);X[0]:=a;Y[0]:=f(X[0]);s:=0;

.1000000000

 

0

 

1

 

0

(7)

ver0:=plot([[X[0],0],[X[0],Y[0]]],color=magenta): #verticale lijn bij x0 = a (intervalgrens)

 

Now we can do the main calculation of the left-hand rule Riemann sum and produce the remaining parts of the outline with the following do loop:

 

for i from 1 to N do

  s:=s+Y[i-1]*dX:

  X[i]:=X[i-1]+dX; Y[i]:=f(X[i]):

  tr[i]:=plot([[X[i-1],Y[i-1]],[X[i],Y[i-1]],[X[i],Y[i]]],color=magenta): # plot van trapje is 2 lijnstukkken ( 3 punten)

end do:

verN:=plot([[X[N],0],[X[N],Y[N-1]]],color=magenta): # verticale lijn bij x= b (interval grens)

hor:=plot(0,x=a..b,color=magenta):

p:=plot(f(x),x=a..b,color=black,thickness=2):

 

display({seq(tr[i],i=1..N),hor,ver0,verN,p},scaling=constrained,axes=none);

 

 

 

Opgave 2(i) rechterhandregel (via bovensom : interval van x1 ..N
Bovensom van x1..N
Ondersom van x0 ..N-1

 

with(plots,display);

[display]

(8)

Before we can do any calculations, we need a function  f  to work with, so we choose the following polynomial function and use the interval [0, 1]:

 

a:=0;b:=1;

0

 

1

(9)

 

f:=x->x^2-x^4+1;

proc (x) options operator, arrow; x^2-x^4+1 end proc

(10)

 

The staircase pattern consists of "treads" and "risers" and we will produce the plots of these as we do the calculations.

The initial computations are done with N =10. The partition points x are stored in an array X and the values y = f (x) are stored in an array Y. The tread/riser plots are stored in an array called tr.

 

N:=10;

10

(11)

X:=Array(0..N); Y:=Array(0..N);tr:=Array(1..N);

`Array(0..10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0})`

 

`Array(0..10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0})`

 

Array(%id = 18446745233214192806)

(12)

 

Next we calculate Delta*x = (b - a) / N, assign values to x[0],  y[0] = f (x[0]), initialize the summation variable s, and plot the left-hand vertical part of the outline, which is stored in ver0.

 

dX:=evalf((b-a)/N);X[0]:=a;Y[0]:=f(X[0]);s:=0;

.1000000000

 

0

 

1

 

0

(13)

ver0:=plot([[X[0],0],[X[0],Y[1]]],color=magenta): #verticale lijn bij x0 = a (intervalgrens) #aangepast

 

NULL# rechter riemann som

 

Now we can do the main calculation of the left-hand rule Riemann sum and produce the remaining parts of the outline with the following do loop:

 

for i from 1 to N do
s:= s+Y[i-1]*dX;  
X[i]:= X[i-1]+dX; Y[i]:=f(X[i]);
tr[i]:=plot([[X[i-1],Y[i]],[X[i],Y[i]],[X[i],Y[i-1]]],color=magenta): # plot van trapje is 2 lijnstukkken ( 3 punten)
end do:

verN:=plot([[X[N],0],[X[N],Y[N]]],color=magenta): # verticale lijn bij x= b (interval grens)

hor:=plot(0,x=a..b,color=magenta):

p:=plot(f(x),x=a..b,color=black,thickness=2):

display({seq(tr[i],i=1..N),hor,ver0,verN,p},scaling=constrained,axes=none);

 

? riemann sum

 


 

Download exc_set_3_task_1_a_b.mw

 

 

@janhardo 

This question is curve handled by a vector-valued function

exc_set_2_task_8_info_bijgevoegd_en_vraag.mw

@janhardo 

Don't know how to start with this asked vector-valued function for a Curve in this task
Could be too difficult for me ?

Note: some background information how to handle Curves

exc_set_2_task_8_info_bijgevoegd_en_vraag.mw 

@Carl Love 

Thanks

The parametric description i can understand with calculus, but with vector-Calculus i should do need more experience.    

@Carl Love 

Thanks

I will look at it

First 62 63 64 65 66 67 68 Last Page 64 of 73