janhardo

700 Reputation

12 Badges

11 years, 42 days

MaplePrimes Activity


These are replies submitted by janhardo

@Carl Love 

Thanks

Indeed i am struggling with the loops and try to improve this
Two forms of the do loop 
- for-from loop
- for -in loop

Your loopexample in the SumList procedure seems to be advanced ( don't know r+)
Tried making the factorial procedure, but make no progress yet.

Yes, the simpler loop example for the procedure SumList you mentioned, is for now easier to understand 
The capital S in the  do loop is a remainder that S is the last executed statement ?

@acer 

Thanks 

I found them back the worksheets from Roger Kraft about programming in Maple 

https://www.maplesoft.com/applications/view.aspx?SID=4744

@dharr 

Thanks

Cannot be shorter :)

@Axel Vogt 

Thanks 

Thereis not much to find about this in the book until now  

@Pascal4QM 

Thanks

@Carl Love 

Thanks

The use of the until statement, why to apply in what code context is yet not clear for me

@Axel Vogt 

Thanks

Yes,but is now by using a procedure for a general case..for all N 

@acer 

Thanks

Interesting books for starting for programming and hopefully i can make some progress

It is not my goal to go very deep in the programming skills, because its probably not neccesary and difficult

@rlopez 

Thanks

Yes, i did, but decided to use the book short introduction for now.

@acer 

Thanks

Makes it not easier to learn some programming in Maple (only one edition from 2002) 

I think there is no other book what teaches a introduction in programming in Maple ?

Can't folllow your explanation what is all wrong with this procedure  

Must a variable be declared in a procedure to be local ?, if not they are global ? : assigned outside the scope of the procedure   

 

CD2-6.MWS 

i@Preben Alsholm 

Thanks

The book mathematical computing -An ntroduction to programming using Maple   is way back from 2002 ( don't think there is newer version ? ) 

When i execute the code nothing happens.

 

@acer 

Thanks 

Makes the graphs really looking good with the legenda! 
i did some adjustment to your code in order to follow the task in two parts
 (part1 :draw 5 deratives, part 2: draw f, f' and f'' and reasoning  geometric the 3 graphs)

betounes_ex_set_task_4def_acc_aangepast.mw 

 

Thanks

I chanced at start at options the Output display to Maple input,that's the culprit

its my own fault..forget that i did this

Well,it is solved now 

betounes_ex_set_task_4def.mw


 

 

restart;

with(Student:-Calculus1):
with(plots):

#f := x -> exp(x)^(-x)*sin(x);# wrong

f := x -> exp(-x)*sin(x); intvx:= 0..3;

proc (x) options operator, arrow; exp(-x)*sin(x) end proc

 

0 .. 3

(1)

 

 to be a one-dimensional array for storing the first five deratives

A:=Array(1..5); #functions

Vector[row](5, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0})

(2)

P:=Array(0..5);# plots functions  

 

 

Array(%id = 18446745684388898686)

(3)

i must make a general expression for f and deratives of f

 

F1:=D(f); F2:=D(F1);F(3):=D(F2); ....... using the D operator and a do loop for this would be

 

F:=Array(0..5);
F[0]:=eval(f);
for i from 1 to 5 do
F[i]:=D(F[i-1])
end do;

Array(%id = 18446745684388899766)

 

proc (x) options operator, arrow; exp(-x)*sin(x) end proc

 

proc (x) options operator, arrow; -exp(-x)*sin(x)+exp(-x)*cos(x) end proc

 

proc (x) options operator, arrow; -2*exp(-x)*cos(x) end proc

 

proc (x) options operator, arrow; 2*exp(-x)*cos(x)+2*exp(-x)*sin(x) end proc

 

proc (x) options operator, arrow; -4*exp(-x)*sin(x) end proc

 

proc (x) options operator, arrow; 4*exp(-x)*sin(x)-4*exp(-x)*cos(x) end proc

(4)

 

 

step(2) Graph all functions in one plot and use a array for coloring the graphs ?
Try to find out how to do this....

 

# P[i]:=plot(F[i],intvx):

# P[0]:=plot(f(x),intvx,color=black);

for i from 0 to 5 do
  F[i]:
  P[i]:=plot(F[i],intvx ):
end do:

P[0]:=plot(F[0],intvx,color=black):

with(plots):

display({seq(P[i],i=0..5)}):

 

Task was using an array to assign colors to each function and scaling plots above ?

 

C:=Array(0..5); #color functions

C[0]:=color =red:

Array(%id = 18446745686456624422)

(5)

C[1]:=color =blue:

C:

display({seq(P[i],i=0..1)}):

for i from 0 to 5 do
  F[i]:
  P[i]:=plot(F[i],intvx ):
end do:

 

P[0]:=plot(F[0],intvx,C[0],thickness=3):

P[1]:=plot(F[1],intvx,C[1],thickness=3):

 

Ok got a color red in one plot with a C[1] array element

 

C[0]:=color =red; C[1]:=color =blue; C[2]:=color =green; C[3]:= color =black;C[4]:=color =magenta; C[5]:=color =yellow;

color = red

 

color = blue

 

color = green

 

color = black

 

color = magenta

 

color = yellow

(6)

 

 for i from 0 to 5 do

  P[i]:=plot(F[i],intvx,C[i],thickness=2);
 end do:

 

 

display({seq(P[i],i=0..5)});

 

 

Complicated to get a function and his 5 deratives and all colored different by using array's


 

Download betounes_ex_set_task_4def.mw

@janhardo 

exercise set 2-task2

So, the fo  rmula for the [i,j] element is i^j , as i goes from 1 to 3 and j goes from 1 to 4. (Realizing this is likely one of the purposes of the execise.)

A := Array(1..3,1..4):

for i from 1 to 3 do
  for j from 1 to 4 do
    A[i,j] := i^j;
  end do;
end do:

A;

Matrix(3, 4, {(1, 1) = 1, (1, 2) = 1, (1, 3) = 1, (1, 4) = 1, (2, 1) = 2, (2, 2) = 4, (2, 3) = 8, (2, 4) = 16, (3, 1) = 3, (3, 2) = 9, (3, 3) = 27, (3, 4) = 81})

Download doubleloop.mw

But look at these:

Array(1..3,1..4,(i,j)->i^j);

               [1  1  1   1 ]
               [2  4  8   16]
               [3  9  27  81]

A := Array(1..2,1..4):
for i from 1 to 2 do
  for j from 1 to 4 do
    A[i,j] := i^j;
  end do;
end do:
A;

               [1  1  1  1 ]
               [2  4  8  16]

Array(1..2,1..4,(i,j)->i^j);

               [1  1  1  1 ]
               [2  4  8  16]
First 66 67 68 69 70 71 72 Page 68 of 73