janhardo

700 Reputation

12 Badges

11 years, 41 days

MaplePrimes Activity


These are replies submitted by janhardo

@janhardo 

Indeed a parabola in standard position
A error ..division by 0  


 

restart; with(plots):

conics:=proc(A,B,C,D,E)

  local N,M,ans;

    if A<>0 and B<>0 then #(1)

         M:=evalf((B*C^2+A*D^2-4*E*A*B)/(4*A*B));

           if M=0 then

                 if A*B>0 then ans:= "point"

                 else ans:="two lines"

                 end if;

           elif M<>0 then

              if (M/A)>0 and (M/B)>0 then  ans:="ellipse"

             elif (M/A)<0 and (M/B)<0 then ans:="no graph"

             else ans:="hyperbola"

             end if;

           end if;

     elif A=0 and B<>0 #(2)

           then N:=-E/B+D^2/(4*B^2);

            if C<>0 then ans:="parabola"

            elif C=0 then

              if N>0 then ans:="two lines"

              elif N=0 then ans:="point"

                else  ans:="no graph"

              end if;

            end if;

     elif A<>0 and B=0 #3
           then N:=-E/B+D^2/(4*B^2);

            if C<>0 then ans:="parabola"

            elif C=0 then

              if N>0 then ans:="two lines"

              elif N=0 then ans:="point"

                else  ans:="no graph"

              end if;

            end if;

     elif A=0 and B=0 then #(4)

           if C<>0 or D<>0 then ans:="line"

           elif E=0 then ans:="the whole plane"

           else ans:="no graph"

           end if;

      end if;

      ans;

     end proc:

 conics(1,-1,-6,5,3);   

"hyperbola"

(1)

 

 

 

conics(2,0,5,1,-7);

Error, (in conics) numeric exception: division by zero

 

implicitplot(2*x^2-5*x+y+7=0,x=-4..4,y=-8..4);

 

 


 

Download antw_symmetry_of_cases.mw

@Carl Love 

Thanks

That's a ingenious way to look at this problem!
Then in case # 2 (A =0) and B not 0 ) the parabola is laying one
For case #3 (a is not 0 and B=0 ), the parabola is in normal position  

All other in # case 2 stays the same in #case 3
Try this out with the code 

@acer 

Thanks


 

 

restart;

The following procedure is for classifying conic sections and starts on page 84 of the text.   The input to the procedure are coefficients of a quadratic equation of the form

Ax^2+By^2+Cx+Dy+E = 0

and the ouput is the type of conic section the equation describes.

 

conics:=proc(A,B,C,D,E)

  local N,M,ans;

    if A<>0 and B<>0 then #(1)

         M:=evalf((B*C^2+A*D^2-4*E*A*B)/(4*A*B));

           if M=0 then

                 if A*B>0 then ans:= "point"

                 else ans:="two lines"

                 end if;

           elif M<>0 then

              if (M/A)>0 and (M/B)>0 then  ans:="ellipse"

             elif (M/A)<0 and (M/B)<0 then ans:="no graph"

             else ans:="hyperbola"

             end if;

           end if;

     elif A=0 and B<>0 #(2)

           then N:=-E/B+D^2/(4*B^2);

            if C<>0 then ans:="parabola"

            elif C=0 then

              if N>0 then ans:="two lines"

              elif N=0 then ans:="point"

                else  ans:="no graph"

              end if;

            end if;

      elif A<>0 and B=0  then ans:="Exercise" #(3)EXERCISE

      elif A=0 and B=0 then #(4)

           if C<>0 or D<>0 then ans:="line"

           elif E=0 then ans:="the whole plane"

           else ans:="no graph"

           end if;

      end if;

      ans;

     end proc:

 

 

Example 1

Let's test the procedure on a few equations.  We will start with ones we can classify on sight.  For instance the circle  x^2+y^2 = 4 .

 

conics(1,1,0,0,-4);

"ellipse"

(1)

 

If we look back at the code we see that this is the correct output.  The procedure classifies a circle as an ellipse whose foci coincide.  Let's try another example.

Example 2

conics(2,3,1,5,-7);

"ellipse"

(2)

This corresponds to the equation

2*x^2+3*y^2+x+5*y-7 = 0

We can visually check this by looking at the graph.

 

with(plots):

implicitplot(2*x^2+3*y^2+x+5*y-7=0,x=-4..4,y=-5..5,grid=[75,75]):

 

In the procedure conics as extra to add a small plot as output next to the classification name .  
For case # 3 ( A ≠ 0 o B= 0 )  EXERCISE we need a derived formula based on (1.6) -section start formula

``

 

start formula

   

For case # 3 ( A ≠ 0 o B= 0 )

 

((a,b)->sort(a,order=plex(A,B))=sort(numer(-b),order=plex(C,D))/denom(-b))(temp);

((1/2)*C/A+x)^2*A+((1/2)*D/B+y)^2*B = (1/4)*(B*C^2+A*D^2-4*E*A*B)/(A*B)

(3)

from this formula (3) to this formula below  for further analyse
How to this with Maple?

A(x+C/2*A)^2 = -C(x-E/C+D^2/4*B*C);

A(x+(1/2)*C*A)^2 = -C(x-E/C+(1/4)*D^2*B*C)

 


 

Download vraag_2_herleiding_conic_sections_formule.mw

@Carl Love 

Thanks

The procedure conics must show this too the degenerate cases

@acer 

Thanks

This formula is good enough.

((1/2)*C/A+x)^2*A+((1/2)*D/B+y)^2*B = (1/4)*(B*C^2+A*D^2-4*E*A*B)/(A*B)

 

The whole analyse starts with

A*x^2+B*y^2+C*x+D*y+E= 0 
 It defines , conics , lines, point, plane , nothing ,  ?

It are preparations for a new procedure for classifying conic sections 
At page 83 of the enclosed pdf  at number 1 : it starts with a characterization

 

@acer 

Thanks

Looks the correct formula, yes and the command used to produce this is not simple.

With order of addens you mean : leftside of equation : starts with A ?
That doesn't matter here, although the book starts with A( )^2 +.B( )^2 

M is now the new name of rhs of the equation

M = (BC^2+AD^2-4EAB)/4AB shows the book

Maple can do it all, but it is specialized use

I must investigate your derived formula for different conditions for M(=0) and A and B for sign combinations.
It seems to be quicker done by hand, then using Maple for this ?   
blz83.pdf

blz84.pdf

@janhardo 


 

restart;

B:=Array(1..5,1..2);

Matrix(5, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0, (3, 1) = 0, (3, 2) = 0, (4, 1) = 0, (4, 2) = 0, (5, 1) = 0, (5, 2) = 0})

(1)

T2:=Array([[0.5,-1],[1,2],[1.5,1],[1.75,2],[2,2.5]]);

Matrix(5, 2, {(1, 1) = .5, (1, 2) = -1, (2, 1) = 1, (2, 2) = 2, (3, 1) = 1.5, (3, 2) = 1, (4, 1) = 1.75, (4, 2) = 2, (5, 1) = 2, (5, 2) = 2.5})

(2)

op(eval(T2));

1 .. 5, 1 .. 2, {(1, 1) = .5, (1, 2) = -1, (2, 1) = 1, (2, 2) = 2, (3, 1) = 1.5, (3, 2) = 1, (4, 1) = 1.75, (4, 2) = 2, (5, 1) = 2, (5, 2) = 2.5}, datatype = anything, storage = rectangular, order = Fortran_order

(3)

op([2],T2); # go further with this

1 .. 5, 1 .. 2

(4)

Can select all : 1..5 , 1 and 5  ;  1..2 , 1 , 2

op([2,1],T2);

1 .. 5

(5)

op([2,1,1],T2);

1

(6)

op([2,1,2],T2);

5

(7)

op([2,2],T2);

1 .. 2

(8)

op([2,2,1],T2);

1

(9)

op([2,2,2],T2);

2

(10)

 

#op([1],T2); nothing ,[2] is two-dimensional?

op([2],T2);

1 .. 5, 1 .. 2

(11)

 

 

whattype(op([2],T2));

exprseq

(12)

upperbound(T2);

5, 2

(13)

lowerbound(T2);

1, 1

(14)

op([2,1,2], T2) ;

5

(15)

 

op(2, op(1, op(2, T2)));

Error, invalid input: op expects 1 or 2 arguments, but received 3

 

 

 

 


 

Download utzoeken_array_dimensie.mw

 

@Carl Love 

Thanks

The content of the array and the array indexing  are related in this programming of "view" is that it? 
Its a way of modern programming then.

The wireframe ranges for domain must also be made general for any array procedure input

 

@acer 
Thanks

Looking to this explanation ...complicated

Compared with the original bookprogramming is this new programming more advanced , because the intervals for x, y and z  for the 3 axis by a given  input  array are also calculated  by the "view "code in the procedure.

Only how the view code this handles seems to be complicated. 

 

 

 

@acer 

Thanks
I agree with you, to stay in a context for better understanding

@Carl Love 

Thanks

Works great , its the wireframe what's doing the job.
To program this from scratch could be complex to figure out.

Its shows the domain for the planes and compaired with the bookprogramming example, this is so much better.

@janhardo 

It is that the x-axis and y-axis are not visible anymore

 

  restart;
  with(plots):
  T:=Array([[1,2],[1.5,1]]):
  rooster:= plot3d(0,x=0..2, y=0..2,grid=[3,3],color=white):
  display
  ( rooster, [ seq
      ( seq
        ( plot3d
          ( T[i,j],
            x=i-1..i,
            y=j-1..j,
            shading=zhue,
            style=surface,
            axes=normal,
            view=[0..2,0..2,0..2]
          ),
          i=1..2
        ),
        j=1..2
      )
    ]
  );

 

 


 

Download arrplot2domain.mw

@acer 
Thanks

Maybe i can solve this learned by other tasks ?

The domain of a f(x,y) in plot3d is a set of points
Drawing the points with a seq statement..

@tomleslie 

Thanks

Its trivial and straight on for you, but  i need to analyze it compared with the bookexample.

Note:  also for teaching it is not advisable to stress out: how easy or trivial it is for students if they are in their learning process: it can make them unsure. 
Mostly youngster are susceptible for this. (secondairy schools) 
Not everyone can teach.

Your programming looks easier, but its not formulated as a step function. 
Also a domain roster should be informative

In the bookprogramming there is a domain checking, but in this procedure it works differently

 

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

 

h:=(x,y)->doPlot(T);

@tomleslie 

Thanks

Looks good!

Yes, its now indeed a real stepfunction with isolated step area's : what i want.
Also the scaling of the xyz axis is now correct

And no showing domain anymore is now correct and perhaps however adding roster of gridlines to show the domain 
 

No nested do loop and if statements anymore , it looks easier your code,but its not a general procedure yet and making one could be complicated?
 

Note: I try to decipher in the programming book also how the first programming example is set up

First 57 58 59 60 61 62 63 Last Page 59 of 73