janhardo

335 Reputation

8 Badges

11 years, 96 days

MaplePrimes Activity


These are questions asked by janhardo

A complicated programmed task for me
I must analyze this 

In this plot there are vertical  walls connected with the step area's , but that its not wanted.
Also the domain is showed by adding 0 in the plot 3d( {0, 'g(x,y)'}, ...) and this distract the plot with the step area's
Its not needed the domain in the plot ( in order to get the 0 value for z )     

The 3 axis x,y,z  are not visible in the plot 
Seems to be not complete programmed as it just to be.


 

restart

 

f:=proc(A,B,T,x,y)

     local n,m,i,j,val;

     n:=nops(A);m:=nops(B);

       for i from 1 to n-1 do

         for j from 1 to m-1 do

         if (A[i]<=x and x<A[i+1]) and

            (B[j]<=y and y< B[j+1]) then val:=T[i,j];

         end if;

          end do;

       end do;

     val;

   end proc:

 

 

A:=[0,1,2];B:=[0,1,2];T:=array([[1,2],[1.5,1]]);

A := [0, 1, 2]

 

B := [0, 1, 2]

 

array( 1 .. 2, 1 .. 2, [( 2, 1 ) = (1.5), ( 1, 1 ) = (1), ( 2, 2 ) = (1), ( 1, 2 ) = (2)  ] )

(1)

 

g:=(x,y)->f(A,B,T,x,y);

proc (x, y) options operator, arrow; f(A, B, T, x, y) end proc

(2)

 

plot3d({0,'g(x,y)'},x=0..2,y=0..2,axes=normal,
           scaling=constrained,orientation=[-37,75],
           projection=0.8,tickmarks=[3,0,2],
           shading=XYZ,lightmodel='light3');

 

 


 

Download texc_set_4_-task_3_-forumvraag.mw

 

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

First 12 13 14 15 16 17 18 Page 14 of 18