Author Topic: High School type Math questions solved using Python 3.x ...  (Read 32849 times)

Offline David

  • Hero Member
  • *****
  • Posts: 644
    • View Profile
Re: High School type Math questions solved using Python 3.x ...
« Reply #15 on: May 16, 2016, 04:02:32 PM »
More review ...

Expanded, what is:

(x + a)**2 = ?

(x - a)**2 = ?

(x + a)*(x - a) = ?


Factor these next:

(Hint, a difference of squares)

x**2 - a**2 = ?


(Hint, next two are 'perfect' squares)

x**2 - 2*a*x + a**2 = ?

x**2 + 2*a*x + a**2 = ?



2*x**2 - 3*x + 1 = ?

3*x**2 + 4*x + 1 = ?

3*x**2 - x - 2 = ?

10*x**2 + 11*x - 6 = ?


Answers to last 4 ...

Factors are:

2*x**2 - 3*x + 1   = (2*x - 1)*(x - 1)

3*x**2 + 4*x + 1   = (3*x + 1)*(x + 1)

3*x**2 - x - 2     = (3*x + 2)*(x - 1)

10*x**2 + 11*x - 6 = (5*x - 2)*(2*x + 3)




Describe how these two parabolas compare:
part (a)
1st:  y = 2*(x-3)*(x+6)

2nd:  y = 2*(x-6)*(x+3)

part (b): Prove it.

Hint:
One way might be to convert each to 'vertex' form
So ...
firstly expand each,
then convert each to  vertex form and compare vertices
and note that both have the same distance (span) between each pair of roots
and note shift in roots and shift in vertices is same ...
so 3 corresponding points are each shifted the same ...

so one parabola is exactly the same as the other, excepted shifted ... how much ?

To go from 1st, to 2nd, just shift each point  (Right or Left?) (and how much?)



Answers to 'advanced' question above:
(The easiest way to do this is ... )

(It is easy to see that) the '1st' parabola has roots (i.e. zero's) at:
at x = -6 and x = 3 and the mid-point is (-6+3)/2 = -3/2 (i.e. -1.5)

i.e. the axis of symmetry for the first parabola,
is a line parallel to the y-axis that intersects the x-axis at x = -3/2

And substituting in (-3/2) for x we get:

2*(-3/2-3)*(-3/2+6)
= 2*(-9/2)*(9/2)
= -81/2

So vertex point here is at:  (-3/2, -81/2)

The 2nd parabola has roots -3 and 6, and mid-point 3/2
and all these values are the same as the corresponding first parabola values
shifted 3 units to the right.

Now substituting in 3/2 for x we get:

2*(3/2-6)*(3/2+3) = 2*(-9/2)*(9/2) = -81/2

So vertex point here is at:  (3/2, -81/2)

And this point also is the same as the vertex point
of the 1st parabola shifted 3 units to the right

So since 3 unique points determine a unique parabola,
and the 2nd 3 points are all the same as the 1st 3 unique points
each shifted 3 units to the right ...
the 2nd parabola is the very same as the 1st parabola
but every point on the 1st is shifted 3 units to the right
to get the graph of the 2nd parabola.

q.e.d.




SOME ... Grade 9 review stuff:

(Note that I'm using the Python notation for exponentiation,
 i.e. 2**3 means 2*2*2, i.e. 3 factors of 2.)


3*x**2 + 4*x + 5
- x**2 + 3*x - 7
= ?


If a car starts off at time t0 with an initial velocity of 44 mph,
and travels at that constant velocity due west for 1 and 1/2 hours,
how far west will it be from the starting point it had at time t0?


If a fenced field takes the shape of a rectangle with opposite sides of length (2*x + 3) and
(3*x + 1) what is the perimeter and area if x is any positive real number?

If the sides are scaled up to be each side longer by a factor of 2,
how will that change the new perimeter and area?


What is another way we write: (x**n)**m = ?
where x is any non-zero real number and n and m are any integer numbers ... ?



Also, what is another way we write: (x**n)/(x**m) = ?


Re-express adding and multiplying these two decimal numbers, a and b if
a =  32.1 and b = 12.3 using powers of 10 notation,

i.e. for example:  a = 3*10**1 + 2*10**0 + 1*10**(-1)


and thus show that we have been using many properties of numbers,
like the commutative law of adding and multiplying ...
the distributive law, and the associative law also.



Answers to SOME Grade 9 review questions:


3*x**2 + 4*x + 5
- x**2 + 3*x - 7
=
2*x**2 + 7*x - 2


If a car starts off at time t0 with an initial
velocity of 44 mph due west and travels at that constant velocity for 1 and 1/2 hours,
how far west will it be from the starting point it had at time t0?

Answer:

44*(1+1/2)
i.e. it will be 66 miles due west of the point it started from at time t0.


If a fenced field takes the shape of a rectangle with opposite sides of length (2*x + 3) and (3*x + 1),
what is the perimeter and area if x is any positive real number?

Answer:

Perimeter is:
2*((2*x + 3) + (3*x + 1)) = 10*x + 8

Area is:
(2*x + 3) * (3*x + 1) = 6*x**2 + 11*x + 3

If the sides are scaled up to be each side longer by a factor of 2,
how will that change the new perimeter and area?

Answer:
The perimeter is doubled (times 2 - why?),
and the area is times 2**2, (times 4 - why?)
So ...
New perimeter:  20*x + 16
New area:       4*(6*x**2 + 11*x + 3) = 24*x**2 + 44*x +12


What is another way we write: (x**n)**m = ?
where x is any non-zero real number and n and m are any integer numbers ...


Answer:  (x**n)**m  =  x**(n * m)


Also, what is another way we write: (x**n)/(x**m) = ?

Answer:  (x**n)/(x**m)  =  x**(n - m)


Re-express adding and multiplying these two decimal numbers, a and b if

a =  32.1 and b = 12.3 using powers of 10 notation,

i.e. for example a =
3*10**1 + 2*10**0 + 1*10**(-1)

and thus show that we have been using many properties of numbers,
like the commutative law of adding and multiplying ...
the distributive law, and the associative law also ...

Answer:

a + b = b + a =
32.1 + 12.3 =
44.4

i.e.

3*10**1 + 2*10**0 + 1*10**(-1)

+

1*10**1 + 2*10**0 + 3*10**(-1)

=

4*10**1 + 4*10**0 + 4*10**(-1)

= 44.4


Also ...

a * b = b * a = 32.1 * 12.3
=
     9.63 +
    64.2 +
   321
=
   394.83

i.e.

( 3*10**1 + 2*10**0 + 1*10**(-1) )

*

( 1*10**1 + 2*10**0 + 3*10**(-1) )

=

9*10**0 + 6*10**(-1) + 3*10**(-2)

+

6*10**1 + 4*10**0 + 2*10**(-1)

+

3*10**2 + 2*10**1 + 1*10**0

=

394.83

=

3*10**2 +
9*10**1 +
4*10**0 +
8*10**(-1) +
3*10**(-2)




Did you notice ...
that in the multiplication above, we had this partial result ?

9 + 4 + 1 = 14

And that 14 is also:  1 * 10**1 + 4

Thus, when we 'carry' ...
what we are really doing is 'rewriting as a sum of powers of 10'

For example 14, is here rewritten as:  1*10**1 + 4*10**0

then we can collect (sum up) all the terms with powers of 10**0
and collect all the terms with powers of 10**1,
etc ... re-writing any sum > 9 as a sum of its parts.




Were you able to understand ok the above little review of algebra and exponents?




Review of ...

Shifting a graph so many units to the right (or to the left left) ...
(below ... see demo of graph shifted right 3 units):


for:  y = m*x + b
if:   y = 0 then ... x = -b/m

If x is replaced by w-3, then ...
y = m*w - 3*m + b
And if then y = 0, we get ... w = 3 - b/m

Thus this line has same slope (m)
but intersects the w-axis 3 units to the right of w = -b/m



Now consider this quadratic relation:

y = a*x**2 + b*x + c

If x replaced by w-3

Lot's of algebra here ... to show the effect of replacing x with (w - 3) ...


y = a*x**2 + b*x + c

if y = 0, then the roots/zeros are ...

x = (-b +- sqrt(b**2 - 4*a*c))/(2*a)


BUT  ... if x is replaced by w - 3

then ...

y = a*(w-3)**2 + b(w-3) + c
  = a*(w**2 -6*w + 9) + b*w - 3*b + c
  = a*w**2 + (b - 6*a)*w  + 9*a - 3*b + c

if y = 0;
x = ( -(b-6*a) +- sqrt( (b-6*a)**2 - 4*a*(9*a -3*b + c) ) )/(2*a)
  = ( -(b-6*a) +- sqrt( b**2 - 12a*b + 36*a**2 - 36*a**2 + 12*a*b -4*a*c ) )/(2*a)
  = ( -(b-6*a) +- sqrt( b**2 - 4*a*c) ) / (2*a)
  = ( -b +-sqrt( b**2 - 4*a*c) ) / (2*a) + 6*a/(2*a)
  = ( -b +-sqrt( b**2 - 4*a*c) ) / (2*a) + 3

So ... roots are the same values... each shifted 3 units to the right ...
and extreme values of y occur at:
x = -b/(2*a) 
and w at:
w =  -b/(2*a) + 3
and are:

a*(b**2/(4*a**2) - b**2/(2*a) + c
=
-b**2/(4*a) + c

and ...

a*( -b/(2*a) + 3 )**2 + (b - 6*a)*(-b/(2*a) + 3) + 9*a - 3*b + c
=
a*( b**2/(4*a**2) - 3*b/a + 9) + (-b**2/(2*a) + 3*b + 3*b - 18*a + 9*a - 3*b + c
=
b**2/(4*a) - 3*b + 9*a - b**2/(2*a) + 3*b -9*a + c
=
-b**2/(4*a) + c

the same y value ...
with graph on the 'w-axis' shifted 3 units to the right wrt graph on the x-axis

So ... curves are same (since each have same 3 points shifted the same.)

THUS ...
2nd parabola is same as 1st,
except each point is shifted 3 units to the right with respect to (wrt) the 1st parabola.

q.e.d
« Last Edit: May 21, 2016, 07:51:54 AM by David »

Offline David

  • Hero Member
  • *****
  • Posts: 644
    • View Profile
Re: High School type Math questions solved using Python 3.x ...
« Reply #16 on: May 16, 2016, 04:06:58 PM »
Looking ahead ...

when finished with quadratics to start trigonometry with its:

sine (sin),
cosine (cos),
tangent (tan) functions and their recipricals ...

cosecant (csc),
secant (sec),
cotangent (cot) ?


http://www.watchknowlearn.org/Video.aspx?VideoID=37485&CategoryID=11359

If theta = a, is the angle measured cc (counter clockwise) from the x-axis,
then  for points (x,y) on a circle with radius r,

sin(theta) = y/r
cos(theta) = x/r

tan(theta) = y/x = sin(theta)/cos(theta)

Note that tan(theta) is also rise/run

and that is the slope of the line that passes through the origin and point (x,y)
on the circle with radius r

The reciprocal relationships are:
csc(theta) = r/y = 1/sin(theta)

sec(theta) = r/x = 1/cos(theta)

cot(theta) = x/y = 1/tan(theta) = csc(theta)/sec(theta)

wrt this next right angled triangle ... with acute angle a ...
and sides: x, y and r ...

            (x,y)
            /|
           / |
        r /  |
         /   | y
        /    |
       /a   |
       ===
(0,0)  x    (x,0)

sin(a) = opposite / hypotenuse = y/r

cos(a) = adjacent / hypotenuse = x/r

tan(a) = opposite / adjacent   = y/x  (i.e. same as the slope, i.e. the rise/run)




Finding roots/(zeros) by ...

Completing the square method ...


Recall:  (a + b)**2 = a**2 + 2*a*b + b**2


         (x + a)**2 = x**2 + 2*a*x + a**2


So going backwards, if you start with only:

x**2 + k*x ...  ?

And then ... you want to eventually have:

(x + k/2)**2 + ?

So what do you need to add and then subtract to preserve equality ?

Recall that here you are starting with only:
x**2 + k*x + d



For example:
x**2 + 3*x - 5


1st step:

(x + 3/2)**2

Need to subtract what?  ( Hint: (3/2)**2 = ? )



9/4


Yes ... 9/4 ... and recall:  x**2 means x raised to exponent 2

1st step:

(x + 3/2)**2

need to subtract what?
9/4

Why ?

Because (3/2)**2 is 9/4

So to keep equality we need to now then subtract 9/4

Recall that here you are starting with only:  x**2 + k*x + d

For example:  x**2 + 3*x - 5  =  (x+3/2)**2 - 9/4 - 5

What is the next / last step?


Last step is ...

Recall that we are finding zero's / roots here by completing the square method,
so we had to set the left hand side to zero (0) ...

So ... here we start with:  0 = x**2 + k*x + d

For example:  0 = x**2 + 3*x - 5
                = (x+3/2)**2 - 9/4 -5

Thus ...

(x+3/2)**2  = 9/4 + 5 = 29/4

So taking square root of each side we have ...

(x+3/2) = +- sqrt(29)/2


So x = ?


x = -3/2 + sqrt(29)/2

and, the 2nd root/zero is at:

x = -3/2 - sqrt(29)/2


To plot these two roots you could use your calculator to firstly find: (29)**(1/2)

Or guesstimate the root as between 5 and 6, and then ...
keep getting closer guesses of a number that squared is 29



sqrt(29) is about 5.4

Recall computer jargon for square root function is sqrt( some_number )
i.e Same as Python: (some_number)**(1/2)

So now find estimate to 1 decimal place for  both roots (zeros)


x = -3/2 + 5.4/2 =  2.4/2 = 1.2

and 2nd root/zero is at:

x = -3/2 - 5.4/2 =  -8.4/2 = -4.2


Now, for extra marks, sub these back into the original, 
y = f(x) = x**2 + 3*x - 5

and see if y is zero for these x's



Here is where a few lines of Python code could come in handy:


# file name: find_func_value_at_x.py #

def f( x ):
   return x**2+3*x-5

# then put in values for x #

x = 1.2

print( f(x) )

x = -4.2

print( f(x) )



I get 0.039999...
for each which is close enough to to zero here since we only carried 1 decimal place
« Last Edit: May 17, 2016, 10:11:21 PM by David »

Offline David

  • Hero Member
  • *****
  • Posts: 644
    • View Profile
Re: High School type Math questions solved using Python 3.x ...
« Reply #17 on: May 16, 2016, 04:11:13 PM »
Ok... try this also ...

Find roots, by completing the square method, for ...

y = x**2 - 3*x - 1

First step is ?



If ...
0 = x**2 - 3*x - 1

then ...
(x-3/2)**2  - 9/4 -1 = 0

So ...
(x-3/2)**2  =  13/4

and thus ...
(x-3/2) = +- sqrt(13)/2
or ...
x = 3/2 +- sqrt(13)/2

Note that (3.61)**2 is about 13

so ...
x = -.61/2 = - 0.305

and 2nd root is:
x = 6.61/2 = 3.305





Let's try a 3rd ...

By completing the square method ...

find roots for:  y = 4*x**2 - 3*x - 1


But firstly notice that this can be factored into:

y = (4*x + 1)*(x - 1)

so we can esily see here, that the roots (the values of x that make y = 0) are ?


Look at each factor ... what value of x will make a factor evaluate to 0 ?


Hint:  If x is 1, x - 1 is zero

Can you solve this also?

(4*x + 1) = 0
x = ?



-1/4


Can you see now that the roots are:  -1/4 and 1

Thus for:  y = (4*x + 1)*(x - 1)

the roots (the values of x that make y = 0) are: x = -1/4 and x = 1

So we easily know here what the roots are ...


Now ... back to completing the square method.

By completing the square method ... find roots for: y = 4*x**2 - 3*x - 1


First step is ?

Let ... y = 0, then ... (factoring out the 4, and putting it out-front) ...
0 = 4*(x**2 - 3/4*x) - 1

Next step ?


Notice that:  (x**2 - 3/4*x) = (x - 3/8)**2 - 9/64

So 4 times ALL that is:

4*(x - 3/8)**2 - 4*9/64 = 4*(x - 3/8)**2 - 9/16

So next step ?


We need to deal with the - 1


So ... for 0 = 4*(x - 3/8)**2 - 9/16  - 1

Then ?


4*(x - 3/8)**2 = 9/16 + 1  = 25/16

Then dividing both sides by 4 ... we get:

(x - 3/8)**2 = 25/64


Then ...
(x - 3/8) = +- 5/8


Recall I am using +- to plus or minus to mean:  'plus or minus'

So roots are:

3/8 + 5/8 = 8/8 = 1
and ...
3/8 - 5/8 = -2/8 = -1/4



Recall that both -a and +a ...
when each are squared are both a positive value equal to a**2


Can you see now that ...
the goal of our completing the square steps was to led us to this:

(x - 3/8)**2 = 25/64

Then, taking square roots of both sides of that equation gave us:

(x - 3/8) = +- 5/8

and thus we have two cases to solve,

the case of RHS  (right hand side) being equal to + 5/8

And case of RHS being - 5/8

Does that help?


I chose the above example with an a = 4 coefficient, (not equal to 1),
in the quadratic ...

and also example was chosen so that ...
we knew the correct roots in advance by seeing it had 2 easy factors.




As you can see, keeping signs correct in all algebra manipulations is very important.
Note!!!

The goal of our completing the square steps was to get us to this:


(x - 3/8)**2 = 25/64

Then we can take square roots of both sides of that equation to solve and find both roots.



Note that we get the general formula for the roots of any quadratic:

y = f(x) = a*x**2 + b*x + c

by using the 'Completing the Square' method ...

the roots are:  (-b +- sqrt(b**2 - 4*a*c)) / (2*a)

Note the +- above means 'plus or minus' ...
so we have two cases to solve to find each of the 2 roots.



The value inside the sqrt function is called the 'discriminant'

(b**2 - 4*a*c)


if the discriminant evaluates to zero we say ...
we have 'two equal roots both equal to the same value'...

and also note that this implies that the graph of the quadratic
just ***touches*** the x-axis (not crossing it)

If the discriminant is positive,
we have 2 *real* roots

If the discriminant is negative,
we have 2 *imaginary* roots (i.e. NO real roots)

+- means ... we ***have*** two cases to solve to find the roots.


Recall ...
Solving to find roots means ...

'Find values of x for which y becomes zero'

Recall also that ...

y = 0

is also the equation of the x-axis line.



For derivation of ...

'finding roots by completing the square method' ...

see this next link:

http://developers-heaven.net/forum/index.php/topic,2624.msg3189.html#msg3189



This is a good example of careful algebraic manipulations.

See if you can follow this 'general case' where we are given just a, b, c parameters
in y = f(x)

y = a*x**2 + b*x + c

We need to find the general formula for the two roots.



Also ... it's a good idea to make up some cases with KNOWN roots ...

to (ease your) practice in finding the roots by 'completing the square method.'


For example:        y = (2*x - 1)*(x + 1)
which expands to:   y = 2*x**2 + x - 1
and you there can easily see that the roots are: -1 and 1/2


and then ...

using the completing the square method to find the roots in the expanded form,

since you already know what they should be,

this will help you to know if your algebraic manipulations were all ok :)


For example:       y = (2*x - 1)*(x + 1)
which expands to:  y = 2*x**2 + x - 1

and you can easily see that the roots are: -1 and 1/2

since if (x + 1) = 0, then x = -1
and if (2*x - 1) = 0, then x = 1/2




Can you do all the steps to complete the square to yield these two values of the roots?


Finding roots by 'completing the square' method of: y = 2*x**2 + x - 1

1st step we factor out the 2 from the 1st two terms ... so:

2*x**2 + x - 1 = 2*(x**2 + 1/2*x) - 1 = 2*(x**2 + 1/2*x + 1/16) - 2*(1/16) - 1


Then ... if y is 0:
2*(x**2 + 1/2*x + 1/16)  = 2*(1/16) + 1

Simplifying we get:
2*(x + 1/4)**2  = 2*(1/16) + 1 = 9/8

Then dividing both sides by 2 and we get:

(x + 1/4)**2  = 2*(1/16) + 1 = 9/16

Then taking square roots of both sides we can find that the roots are ?


1st root is: -1/4 - 3/4 = -1
2nd root is: -1/4 + 3/4 = 1/2

q.e.d.
« Last Edit: May 19, 2016, 03:53:11 AM by David »

Offline David

  • Hero Member
  • *****
  • Posts: 644
    • View Profile
Re: High School type Math questions solved using Python 3.x ...
« Reply #18 on: May 16, 2016, 04:13:43 PM »
Try this ...
Expand firstly, then (re-)find both roots by the completing the square method:

y = (1 - x)*(2 + 3*x)

Firstly, and so that we can see if we are keeping on the right track, by easy inspection,
the two roots are: 1 and -2/3
since factor (1 - x) is zero if x = 1
and factor (2 + 3*x) = 0 if x = -2/3


Then expanding we get: y = (1 - x)*(2 + 3*x)
                         = 2 + x - 3*x**2
                         = -3*(x**2 - 1/3*x) + 2
                         = -3*((x - 1/6)**2 - 1/36) +2
                         = -3*(x-1/6)**2 + 1/12 + 2

So if y = 0, then we have: 3*(x-1/6)**2 = 2 + 1/12 = - 25/12

And dividing both sides by 3 implies: (x-1/6)**2 = 25/36

So taking square root of both sides we get: (x-1/6) = +- (5/6)

Recall that by this +- ... I mean to say 'plus or minus'

Thus roots are:
1/6 + 5/6 = 1
and:
1/6 - 5/6 = -4/6 = -2/3



Looking back...

Can you also see here that 1/6 is the mid point of these roots?

Note:  (-2/3 + 3/3)/2 = 1/6

(Also, If you add them together, the +- parts add to zero, and 1/2 of 2*(1/6) is just 1/6, the mid-point.)


So recalling that the graph of a parabola is symmetric,
the extreme value for y is reached when we sub in x = 1/6,
the midpoint of the roots.


So, wrt the form, y = a*(x - h)**2 + k,
we already here know that a = -3 and that h = 1/6, so what is k, the extreme value?


Going back to original expression and subbing in for x the value x = 1/6,
the mid-point of the roots, we find that:

y = (1-1/6)*(2+3*(1/6))
  = (5/6)*(2+1/2)
  = (5/6)*5/2
  = 25/12 the same thing as
    (2 + 1/12) or about 2.1, if we need to plot an estimated value, to one decimal place.

Thus, since a = -3, and this is negative, the parabola opens down ...
and so the extreme value, k = 25/12 is a maximum.




Looking forward to the general formula for roots (zeros,
i.e. values of x that make y = 0) of a quadratic ...

If you start with general form: y = a*x**2 + b*x + c

and there, (very carefully), apply the 'completing the square' method ...

(see web link, linked above) ...

you will find that the roots are:

(-b +- sqrt(b**2 - 4*a*c))/(2*a)

where again I am using the +- notation above to indicate 'plus or minus',
(i.e to find both roots we need both cases),

and sqrt(...) means ... take the square root of the value inside the brackets.



Recall ... the value:

b*b - 4*a*c,

is called the 'discriminant' (D).

Can you see here that the mid point of the roots is just:

-b/(2*a)

and that this is the value of x where y reaches an 'extreme value'?

(Recall that the +- parts add to zero.)


Note also that if D = 0, the roots are 'both equal'
(i.e. only one value for roots and that the graph just touches the x-axis at x = -b/(2*a)

Note also the case where D < 0, i.e. D is negative.

What does this imply?


This is the case where a, b, c are such that the graph of the parabola

does NOT touch or cross the x-axis,

and so is the case where there are NO *real* roots,

i.e. we say, in this case where D < 0
that the roots are paired and both 'imaginary',
i.e, the roots involve the use of an (imagined) value ... the imagined value of the sqrt(-1)


Offline David

  • Hero Member
  • *****
  • Posts: 644
    • View Profile
Re: High School type Math questions solved using Python 3.x ...
« Reply #19 on: May 16, 2016, 05:28:49 PM »
How are you progressing in math these days?

Are you seeing the 'big picture' re. quadratic relations?


wrt the general form: y = f(x) = a*x*x + b*x + c


1) the graph is a parabola ... And the graph is symmetric about about the line:

   x = -b/(2*a)

2) it opens up with a min extreme value if a > 0, i.e. if a is pos.

3) it opens down with a max extreme value if a < 0, i.e. if a is neg.

(Recall that here, a != 0, i.e. a is NOT zero, since if a is zero, we no longer have an x**2 term.)

4) it has a pair of roots (zeros) about the axis of sym-metry, the line:

   x = -b/(2*a)

   And the two roots here are given by:   (-b +- sqrt(b*b - 4*a*c))/(2*a)

   Or ... re. the discriminant, D = (b*b - 4*a*c),

   in case 1, we take the pos. sqrt(D), so y = 0 at x = (-b + sqrt(D))/(2*a)

   in case 2, we use the neg. sqrt(D), so also y = 0 at x = (-b - sqrt(D))/(2*a)

   Note! If D = 0, then we say that we have just one ... (or 'two equal roots') ...
i.e. the graph of the quadratic just 'touches' the x-axis.
   If D > 0, then we have two *real* roots,
   If D < 0, we say that roots are 'imaginary',
   i.e. the roots in the case where D is neg. involve the use of the 'imagined number': sqrt(-1)


Note that we obtained this general formula for the roots of:   y = a*x*x + b*c + c

by using the 'completing the square' method.


So now, via this general formula, and understanding the significance of D, the discriminant,
we can quickly just sub into the formula and find the roots,
and do not need to use factoring method, or completing the square method,
which were steps on the way to understanding the quadratic's (paired) roots
and how we derive the general formula for the roots.


Note in particular, that if D evaluates to zero,
then that is the case of there being only one root, (and the graph just touches the x-axis),
i.e., the case where y = 0 ONLY at this one value of x = ?

Hint: what is equation for axis of symmetry?
x = ?

Answer:
x = -b/(2*a) is equation of axis of symmetry for all parabolas and
so this x, is also the one value of x if a parabola's a, b, c's are such that
the graph only touches the line.

You can also see this easily from setting D = 0 in the general formula.

Then roots are:  (-b +- sqrt(0))/(2*a) = -b/(2*a)

Can you now see that this all makes sense, since the parabola is symmetric about:  x = -b/(2*a)

So if the (a,b,c's of a) parabola (are such that it) just touches the x-axis at only one place,
then it must be there, at x = -b/(2*a)



Ok ... let's now ...

Start back at the simplest example of a quadratic relation:

What is graph of:

y = x*x

Then ask:

What changes if we graph:

y = a*x*x where a is pos or neg and the absolute value of a gets bigger than one ... or ... gets smaller than one ?


How does the graph change if we graph:

y = a*x*x + k

?


Then, finally, how does the graph change if we graph:

y = a*(x - h)**2 + k

?


Note that the final form above is the ... 'Vertex form' of a quadratic with the vertex point being:  (h, k)

i.e. the extreme value of y = k occurs here at x = h

and is a max if a < 0

or is a min value if a > 0


Note that if a < 0, then for values of x different from h, we are always subtracting a value from k ... So k is the max

And if a > 0, then for values of x different from h, we are always adding a value to k ... So k is the min value.

Note that the 'extreme' value of:       y = k
in this vertex form, always occurs at:  x = h

The only other form you were given was the root form, where the roots are r1 and r2:  y = a*(x - r1)*(x - r2)

And you can expand this now and find ...

y = a(x*x -(r1+r2)*x + r1*r2)
  = a*x*x - a*(r1+r2)*x + a*r1*r2

And comparing the relevant coefficients here with the general equation that uses
parameters of a, b, c for a quadratic, we can see that:

a is same ...
and ...

b = -a*(r1+r2)

i.e.
(r1+r2)/2 = -b/(2*a)

which we knew already from symmetry, that the extreme value for y occurs at x = mid point of roots,

and finally ... (comparing coefficients)

c = ?
here c = a*r1*r2

Or alternately:
r1*r2 = c/a

and ...
(r1+r2) = -b/a



So ... back now to practicing completing the square method.

Try this:

y = 3*(2-x)*(1+5*x)

We know here (in advance by inspection) that the roots are: 2 and -1/5 since a factor becomes zero with x taking either one of these values.

Firstly, expand ...

then see what you can do?  Can you expand it?

Recall that:  3*(a + b) = 3*a + 3*b (distributive law)

And so also we get:
(a + b) * (c + d) =
a*c + a*d + b*c + b*d

Hint: when you expand it,

3*(2-x)*(1+5*x)

in your first step ...
leave the times 3 factor out front the brackets, where, inside the brackets,
you show the expansion of the other two factors.

So 1st step:                y = 3*(2-x)*(1+5*x)

Firstly, expanding we get:  y = 3*(2 + 9*x - 5*x*x)


Note: we were probably here starting with:  y = 6 + 27*x - 15*x*x

and then our 1st step might be,
(after dividing each term by -3 and rearranging with -3 factor out front all):

y = -3*(5*x*x -9*x -2)
  = -3*(5*x*x -9*x) + 6


Now starting with :  y = -3*(5*x*x -9*x) + 6

we might next divide the 5 and 9 by 5 and put the 5 factor out front,
so ...

y = -15*(x*x - 9/5*x) + 6


Now what is (1/2 of (-9/5)) squared?

thus:  y = -15*(x*x - 9/5*x + 81/100 - 81/100) + 6

         = -15*(x - 9/10)**2 + 15*81/100 + 6

And if y is 0, then dviding both sides by -15 gives ...

0 = (x - 9/10)**2 - 81/100 - 6/15

Or ...

(x - 9/10)**2 = 81/100 + 6/15

              = (243 + 120)/300
              = 363/300
              = 121/100

So taking square roots of both sides we get:

x - 9/10 = +- 11/10

Thus ...

y is zero if ...
x = 9/10 + 11/10 = 2
or ...
x =9/10 -11/10= -1/5

And that is probably the hardest completing the square example you are ever likely to get on a test ...

The trick here, on a test, if you need to show steps to completing square method,
would be to firstly use the general formula to quickly find the roots ...

and then, knowing what your final values should be,
that can help you see if all your algebraic manipulating is on track :)


But can you see now ... why it is a good idea to do all this grunt work, (once),
to develop the general formula for the roots of a quadratic,
by the 'completing the square method' ...

then ...

all we ever need to do after ... is to sub the values of a, b, c into the formula, to find the roots?



What do we mean when we say a number is itself squared?

Recall that for a square room, with sides 4 ft by 4 ft ... the area is 16 sq. ft.

Or the other way around ...
if a perfectly square room had area 16 square feet, what is the length of each side?

Answer:  Each side is 4 ft. long.

Recall I am using Python exponent notation of **  ... so ... by using ... 2**3
I mean to indicate:  3 factors of 2

So 4**4 = ?
Four factors of 4 = ?
4*4*4*4 = ?
Same as : 16 * 16
Same as : 2**8 = 256

Recall 4 = 2**2
and so 4**4 = (2**2)**4 = 2**(2*4) = 2**8 = 256


We maybe need to do more practice with exponents ?

What is 3**2 ?
What is 4**2 ?

What is 5**2 ?

What is sqrt(81) ?

What is sqrt(144) ?

What is sqrt(49) ?


Recall ...
I am NOT using 'x' to indicate times ...
since we are using 'x' as an independent variable in all our functions here like y = f(x)

And the Python language ... and all standard computer programming languages ...
they pretty much all use calculator notation to indicate multiplication by using the star. *, i.e. the asterisk symbol.


Note also ... that in all computer programs (and calculators) you can NOT code:  x = 3(4+5)
you must instead, always code like this:  x = 3*(4+5)


So now memorize the general formula to find the roots of any quadratic ...

For:  y = f(x) = a*x**2 + b*x + c
Roots are:  (-b +- sqrt(b*b-4*a*c))/(2*a)


Note: we need to take both + and - cases to find both roots if discriminate D = (b**2 - 4*a*c) is not zero.



NOW ... practice more on completing the square method on some easier equations that you can make yourself by using root form:

y = a*(x-r1)*(x-r2)

and sub in easy values for roots r1, r2 and also for a.

Then expand and practice completing the square method of finding the roots from that starting point ... already knowing what the roots each are :)

If you get stuck ...I'm only a quick e-mail away :)

The Lord knows all about perfect squares since He created it all perfect.

Bless the Lord oh my soul, and all that is in me, bless His Holy Name!!!

Baruch HaShem!!!
(Bless His Name)

Praise the Lord!!! ... He has promised to never leave or forsake those who place their trust in Him..

Recall also His encouraging words to these ones,  that He speaks at the end of Matthew's Gospel ...

ALL power/authority is given to me in heaven and in earth ... go ... I am with you alway, (even) unto the end of the world.

(Matthew 28:16-20)

16 Then the eleven disciples went away into Galilee, into a mountain where Jesus had appointed them.

17 And when they saw him, they worshipped him: but some doubted.

18 And Jesus came and spake unto them, saying, All power is given unto me in heaven and in earth.

19 Go ye therefore, and teach all nations, baptizing them in the name of the Father, and of the Son, and of the Holy Ghost:

20 Teaching them to observe all things whatsoever I have commanded you: and, lo, I am with you always, even unto the end of the world. Amen.


And recall:

But of him are ye in Christ Jesus, who of God is made unto us wisdom, and righteousness, and sanctification, and redemption. (1 Cor. 1:30)

And ...

For he (God) hath made him (Jesus to be) sin for us, who knew no sin; that we might be made the righteousness of God in him (in Jesus.) (2 Cor. 5:21)
« Last Edit: May 19, 2016, 04:20:00 AM by David »

Offline David

  • Hero Member
  • *****
  • Posts: 644
    • View Profile
Re: High School type Math questions solved using Python 3.x ...
« Reply #20 on: May 16, 2016, 05:30:52 PM »
Another grade 9 type problem concerns ...

what happens to the graph of the linear relation y = m *x if you replace it by the graph of,

in case 1),
y = m*x + b

or in case 2,
y  = m*(x - h)


How is the line moved in each case wrt
(with respect to) the base case of the graph of the linear relationship: y = m*x

?

If you need help to see what happens,
plot ALL the simple cases where you take the value of m as 1
and the value of  b as, say 2, or -2, and then the value of h as, say 3, or -3

?


We need to 'see' what happens to the 'line' here firstly ...


Then we can more easily see what happens to the graph of the quadratic relationship:

y = a*x*x

in case 1), we replace by graph of:
y = a*x*x + k

and in case 2, we replace by graph of:
y = a*(x - h)*(x - h)


How is the parabola moved, in each case, wrt to the base case of the graph of the parabola:

y = a*x**2

?



Please be specific ...

You need to fill in all the ? mark places with an answer:


If ?  > 0,
then ? is moved ? units to  ?

Or if ? < 0,
then ? is moved ? units to ?



Filling in all the (?) places with an answer:

With respect to base cases (where h = 0 and b = k and both here are 0):

If (h) > 0,
then (each point on the line) is moved (h) units to (right) and the same for the parabola.

If (h) < 0,
then (each point on the line) is moved (h) units to (left) and the same for the parabola.


If (b) > 0,
then (each point on the line) is moved (b) units (up) and the same for the parabola if (b=k) > 0

If (b) < 0,
then (each point on the line) is moved (b) units (down) and the same for the parabola if (b=k) < 0


Questions (grade 9 review) re. point(s) of intersection (if any):

Line 1:
2*x + 3*y + 4 = 0

Line 2:
3*x - 2*y - 1 = 0

Question 1: Are the lines the same? Prove your answer.
(Note: if there exists even one point on one line that is not on the other line, are they the same lines?)

Question 2: Are the lines parallel? (Again prove your answer.)

Question 3: Do they have any common points, if so how many?
(How might you prove your answer? If you'd like a hint ... see below.)
What other relationship might you mention regarding/comparing these 'lines'?

Finally, sketch a graph of the above lines that helps to illustrate your answers above, using the x-y rectangular co-ordinate system.



Answers to...

Questions re. point(s) of intersection (if any):

Line 1:
2*x + 3*y + 4 = 0

Line 2:
3*x - 2*y - 1 = 0

Question 1 (answered): The lines are NOT the same ...
since when y = 0, for the first line, x = -4/2 = -2, but on the second line, x = 1/3. 
And since even one point is different, the lines are NOT the same.



Question 2 (answered): The lines are not parallel since they have different slopes. 
Line 1 has slope -2/3 while line 2 has slope 3/2

Question 3:
Since the lines are different (see 1st answer above) and have different slopes
(see the 2nd answer above)
and they are both 'straight lines'
i.e. the slope is at every point on each line the same continuous slope that it had at any
'previous' point on that respective line, therefore the 2 different lines must intersect
at one (and ONLY at one) point of intersection.


If we multiple both sides of linear relation 1 by 3 ...
and also multiply both sides of relation 2 by 2, we get:

Line 1:
6*x + 9*y + 12 = 0

Line 2:
6*x - 4*y - 2 = 0

Then subtracting, (since 6*x - 6*x = 0)

13*y + 14 = 0
Thus, y = -14/13
And for this y subbed into line 1:

2*x + 3*(-14/13) + 4 = 0

Thus ...
2*x = 3*(14/13) - 4
And ...
 x = 3*7/13 - 2
    = 21/13 - 26/13
    = -5/13

And subbed into line 2:

3*x - 2*(-14/13) - 1 = 0
Thus ...
3*x = -28/13 +13/13
       = -15/13
    x = -5/13

Thus the 2 different lines intersect at, and only at, point (-5/13, -4/13)

Since slope_1 was -2/3 and slope_2 was 3/2 =
- 1/(slope_1),

Thus the lines are perpendicular to each other.

q.e.d.


Recall that if two lines have slopes m1 and m2 such that:

m1 * m2 = -1

i.e. m1 = -1/m2

then the lines are perpendicular to each other, i.e. (wrt the extended lines), they form a 'right angle',
i.e. a 90 degree angle, i.e. an angle of pi/2 to each other at their point of intersection.
Review also

 'times table':

*  0 1 2 3 4 5 6 7 8 9 10 11 12
0  0 ... (Fill in to 12)
1   0 1 ...
2  0 2 4
3  0 3 6 9
4  0 4 8 12 16
5  0 5 10 15 20 25...
6
8
9
10
11
12

Fill in whole table ...

(Note the symmetry of entries around the 'diagonal' line is but a reflection of the commutative law of multiplication, i.e. that a*b = b*a for all integer values a, b (and also for all rationals and reals ... and even complex numbers, the commutative law applies for both addition and multiplication, but NOT for subtraction or division.)

Note that the diagonal in the table is a 'line' of perfect squares:

0*0 = ?
1*1 = ?
2*2 = ?
.
.
8*8 = 64
9*9 = 81
10*10 = 100
11*11 = 121
12*12 = 144 (also called 'a gross')

What is sqrt(49) ?
What is sqrt(25) ?
What is sqrt(36) ?
What is sqrt(9) ?
What is sqrt(16) ?

Recall the 'perfect squares' like:
49 = 7 * 7
Yes?
Thus we can easily find that: sqrt(49) = 7
Try to make, all your math statements, logically true statements.

49  != 7
(49 does not equal 7)

but ...
sqrt(49) is 7
Good :)
The next ones ?
sqrt(49) = 7
sqrt(25) =
sqrt(36) =
sqrt(9) =
sqrt(16) =

No calculator here please ...
sqrt(121) =
sqrt(81) =
sqrt(100) =
sqrt(4) =
sqrt(144) =
sqrt(64) =
sqrt(1) =
sqrt(0) =
sqrt(1/4) =
sqrt(9/16) =
sqrt(81/121) =

Review question(s):

Below, whenever I write the symbol s, replace it with the symbol sqrt(2)

1)
if y = s*(x-s)*(x+s)
What are the roots?
What is extreme value?
Is this a max or min?
What happens to all the above if s is replaced by -s ?
Hint re. finding extreme value:

recall that the extreme y value is reached,

when x is the value of the mid-point of the roots.
2)
if y = s*(s-x)**2

answer for this y, all of the same questions as in question 1) above
Answer for ...

2)
if y = s*(s-x)**2

answer for this y, all of the same questions as in question 1) above

Answers:
There is one and only one root and it occurs at x = s = sqrt(2), and there y = 0, a min extreme value,
since  here the parabola opens up, because the coefficient in front of the x**2 term is pos.

Now if s were to be: -sqrt(2), then single root is at:
x = s = -sqrt(2)
And here, y is 0, the max value, because the parabola graph of the quadratic opens down,
since here the coefficient in front of the x**2 term is negative.
If you now sketch in all these 4 parabolas ... that is good practice ...
and is often a good way to start to see what is going on.

To sketch the parabolas, recall that 2**(1/2) is about 1.4


sqrt(49) = 7
sqrt(25) = 5
sqrt(36) = 6
sqrt(9) = 3
sqrt(16) = 4

No calculator needed here either ... if one knows the 'times table' ...

sqrt(121) = 11
sqrt(81) = 9
sqrt(100) = 10
sqrt(4) = 2
sqrt(144) = 12
sqrt(64) = 8
sqrt(1) = 1
sqrt(0) = 0
sqrt(1/4) = 1/2
sqrt(9/16) = sqrt(9)/sqrt(16) = 3/4
sqrt(81/121) = 9/11

Now practice factoring all numbers ... (show all factors of each number, excluding 1 and itself)...

for all numbers from 4 to 144:

A start:

4:   2
5:   is prime number
6:   2,3
7:   is prime
8:   2,4
9:   3
10: 2,5
11:  prime
12:  2,3,4,6
13:  prime
14:  2,7
15:  3,5
16:  2,4,8
17:  prime
18:  2,3,6,9
19:  prime
20:  2,4,5,10
21:  3,7
22:  2,11
23:  prime
24:  2,3,4,6,8,12
25:  5
26:  2,13
27:  3,9
28:  2,19
29:  prime
30:  2,3,5,6,10,15
31:  prime
32:  2,4,8,16
33:  3,11 (and Jesus was in Israel about 33.5 years when he ascended ...
           back into heaven in a glorified body ...
           like we will soon be given.)



Can you prove this ?

... that if two lines have slopes m1 and m2 such that:

m1 * m2 = -1

i.e. m1 = -1/m2

then the lines are perpendicular to each other,
i.e. (wrt the extended lines), they form a 'right angle',
i.e. a 90 degree angle, i.e. an angle of pi/2 to each other at their point of intersection.


Hint:

take values a and b as positive, (with b > a),

then plot:      point1 ( a, b)
and also plot:  point2 (-b, a)

then what is length of r, the distance from the origin to each point ...

(what theorem is applicable? ... HINT: The Pythagorean Theorem)

then what is length of line from point2 to point1

... and is this squared ... the same as sum of squares of r ?  i.e. =? 2*r**2

If so ... what does that imply about the angle opposite this longest side of that triangle?



Also ... practice these:

2*2 = 4, sqrt(4) = ?
3*3 = 9, sqrt(9) = ?
.
.
.
12*12 = 144, sqrt(144) = ?


and ...

sqrt(121/81) = ?
sqrt(36/49) = ?
sqrt(64/25) = ?
sqrt(9/100) = ?


A start  ...

Each answer is a nice simple fraction because for each ...
the numerator and the denominator are each 'perfect squares'

sqrt(121/81) = sqrt(121)/sqrt(81) = 11/9

Note that:  11/9 * (11/9) = 121/81

sqrt(36/49) = ?
sqrt(64/25) = ?
sqrt(9/100) = ?
sqrt(64/25) = ?
sqrt(9/100) = ?
« Last Edit: May 18, 2016, 12:41:47 PM by David »

Offline David

  • Hero Member
  • *****
  • Posts: 644
    • View Profile
Re: High School type Math questions solved using Python 3.x ...
« Reply #21 on: May 16, 2016, 05:43:51 PM »
Also see these ...


Simple Proofs of Pythagorean Theorem

http://jwilson.coe.uga.edu/EMT668/EMT668.Student.Folders/HeadAngela/essay1/Pythagorean.html


Also see ...

http://www.analyzemath.com/Geometry/pythagora_theorem.html

http://math.stackexchange.com/questions/803/what-is-the-most-elegant-proof-of-the-pythagorean-theorem

https://www.khanacademy.org/math/basic-geo/basic-geo-pythagorean-topic/basic-geo-pythagorean-proofs/v/garfield-s-proof-of-the-pythagorean-theorem

http://www.mathsisfun.com/geometry/pythagorean-theorem-proof.html

http://jwilson.coe.uga.edu/emt668/EMAT6680.Folders/Brooks/6690stuff/Righttriangle/Pythagconv.html


Proof of the Converse of the Pythagorean Theorem

Note: below I am using The Python Computer Programming Language convention
to indicate raising a value to an exponent,
i.e. 2**3 means 3 facters of 2,
i.e. 2**3 = 2*2*2


The Pythagorean Theorem states that if ABC is a triangle (with) right angled at C, then:

a**2 + b**2 = c**2

The converse of the Pythagorean Theorem states that if:

a**2 + b**2 = c**2 holds,

then:

triangle ABC is a right triangle (with) right angled at C

http://proofsfromthebook.com/2015/02/16/proof-converse-pythagorean-theorem/


Do you know and can you prove: the Sine Law?

In a triangle with angles A,B,C
and opposite sides a,b,c
we have: sin(A)/a = sin(B)/b = sin(C)/c

Do you know and can you prove: the Cosine Law?

In a triangle with angles A,B,C
and opposite sides a,b,c
we have:
c**2 = a**2 + b**2 - a*b*cos(C)

b**2  = a**2 + c**2 - a*c*cos(B)

a**2  = b**2 + c**2 - b*c*cos(A)

http://www.mathsisfun.com/algebra/trig-cosine-law.html

« Last Edit: May 21, 2016, 08:21:41 AM by David »