janhardo

700 Reputation

12 Badges

11 years, 41 days

MaplePrimes Activity


These are questions asked by janhardo

With showstat( )  i can see procedure body 
But it is also possible for tools : assistant, math apps, tutors and tasks ?

In library all proc are public.

Should be that i was thinking on the use the arrow operator for a function definition and to use this for graphing this function
It becomes complicated.


 

restart;

 

the following piecewise-defined function was considered

exc set 4 task 1a
                                                                                

sin(3*x): # x <= 0 .. must be evaluated to true or false for branching to      #other second function
sin(x/3): # otherwise

h:=proc(x)
   if x<=0 then sin(3*x)
   else sin(x/3)
   fi;
end proc:

maplemint(h);

h(1); #

sin(1/3)

(1)

h(1.0);

.3271946968

(2)

Strange that this function notation e.g h(1) can be used for a expression ?, while the idea was to use this only for a function defintion with a arrow operator  ( function as a procedure )
Seems to be possible to use the notation e.g : h(1) or h(1.0) if the input parameter is numeric for a expression.

 

The condition in the if statement must be(can only) evaluated numeric..that seems to be not possible with the arrow operator definition in the procedure.

 

h(x);

Error, (in h) cannot determine if this expression is true or false: x <= 0

 

plot('h(x)'); # delay of the evaluation of h(x)

 

plot(h);

 

 


 

Download exc_set_4_task1.mw

 

Problem is here how to define the local variables?

Also the formatting of the code is not ideal

There is a error , but if the local variables are good defined , it could vanish    


 

task 6 newtons method

 Newton's Method (see worksheet)

   
 

Tasks:

CDExercises

(1)  Figure 3.9 shows the convergence of Newton's method to a root  r of  the equation sin x - xcos x = 0. This was for x[0] = 5.5 and `&epsilon;` = 0.1e-3, and gives  r = 4.503123428, approximately. Obtain a better approximation, as suggested in the book, by using `&epsilon;` = .000001. and altering the above code appropriately. Compare your answer with the approximation to r that you get by using Maple's  fsolve command. How close to zero is  E =| f (r)|  for each of these values of r ?

 

(2) Alter the above code for Newton's method and use it to draw the picture shown in Figure 3.10 in the book.

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

 

I make a procedure out of it 

f is function

a.. b endpoints interval x -range

e is the cutoff in the accuracy (tolerance?)

N is number of iterations

 

restart:

with(plots,display):

#
# Parameters - change as necessary
#
  a:= 0.8: b:= 2: N:= 100: e:= 0.0001:
  f:= x->x^2-1:

NewtonM:= proc(f, a, b, N, e)
               local n, tps, x0, E, A, x1, ps, x, j,  pf, pic :  
               uses plots:  
   n:=0: tps:={}:
   x0:=2.0: E:=evalf(abs(f(x0))):
   while ( E>e and n<N ) do
     A[n,1]:=x0;
     A[n,2]:=E;
     x1:=evalf(T(x0));
     E:=abs(f(x1));
     ps:={plot([[x0,0],[x0,f(x0)],[x1,0]],color=black,
                 thickness=2)}:   
     tps:=tps union ps:
     n:=n+1:
     x0:=x1:
   end do:
 
 for j from 0 to n-1 do x[j]=A[j,1],'E'=A[j,2]end do;

 pf:={plot(f(x),x=a..b)}:
 pic:=pf union tps:
 display(pic,tickmarks=[3,3]);
end proc:

maplemint(NewtonM);

Procedure NewtonM( f, a, b, N, e )
  These names were used as global names but were not declared:  black, color,
      thickness, tickmarks
  These local variables were used but never assigned a value:  x

 

NewtonM(x->x^2-1,0.8,2,100,0.0001);

Error, (in NewtonM) cannot determine if this expression is true or false: 0.1e-3 < abs(T(2.0)^2-1)

 

 


 

Download exc_set_3_task_6.mw

Could it be correct ?


 

If L= 1.158R  then half of smallest circle is covered  to proof

 

I derived a formulue for this in GX

 

 

 

restart;

abs(((((((L)^(2)*(-1))+((R)^(2)*4)))^(1/2)*L*(-1/2))+(arctan((((((L)^(2)*(-1))+((R)^(2)*4)))^(1/2)*(L)^((-1))))*(L)^(2))+(arctan((((((L)^(2)*(-1))+((R)^(2)*4)))^(1/2)*(((L)^(2)+((R)^(2)*(-2))))^((-1))*L))*(R)^(2)*(-1))));

abs(-(1/2)*(-L^2+4*R^2)^(1/2)*L+arctan((-L^2+4*R^2)^(1/2)/L)*L^2-arctan((-L^2+4*R^2)^(1/2)*L/(L^2-2*R^2))*R^2)

(1)

verg:=%;

abs(-(1/2)*(-L^2+4*R^2)^(1/2)*L+arctan((-L^2+4*R^2)^(1/2)/L)*L^2-arctan((-L^2+4*R^2)^(1/2)*L/(L^2-2*R^2))*R^2)

(2)

subs(R=1,verg);#  

abs(-(1/2)*(-L^2+4)^(1/2)*L+arctan((-L^2+4)^(1/2)/L)*L^2-arctan((-L^2+4)^(1/2)*L/(L^2-2)))

(3)

verg2:=%

abs(-(1/2)*(-L^2+4)^(1/2)*L+arctan((-L^2+4)^(1/2)/L)*L^2-arctan((-L^2+4)^(1/2)*L/(L^2-2)))

(4)

solve(verg2 = Pi,L); # area half small circle with R=1 => 2*Pi* R^2/2 = Pi ,

Warning, solutions may have been lost

 

L must be expressed in R ?

 

 


 

Download de_koe_in_het_weiland.mw

I try to make a procedure for this 

Was it by a example of Riemann sum that  x-values in a array are stored for  numerical value, but in this task it seems that the array must be filled with the symbol x1,x2 , etc 

Should this be needed ?

 

blz64.pdf

blz_65.pdf

excset  3  task4

 

Was it first for a partition about a interval ( example Riemannn sum) that i got  a list of numeric values

 a:= 0: b:= 5: N:= 30: i= 0..N :

X:= Array(0..N, [seq(j, j=a..b, (b-a)/N)]);

Array(%id = 18446745862042054398)

(1)

Now i want  to get a list  of  x-values in Array X ,  starting from  0  to N  :

example: array X =[x0= 0, x1=1/6, ...]

x[i]:= a+(b-a)*i/N; # for i = 0..N # endpoints subintervals

Error, invalid terms in product: 0 .. 30

 

# generate X-values for interval [a,b]

X:= Array(0..N, [seq(j, j=a..b, x[i])]);

Error, invalid input: seq expects its 3rd argument, step, to be of type numeric, but received x[i]

 

 

the values  x1,x2....stored  in Array X are used in further calulations
If there is a need for naming x1= 0 , x2= ..  in the Array A ? , probably not .

 


 

Download vraag_excset3_task_4.mw

  

First 16 17 18 19 20 21 22 Page 18 of 22