Monday, August 20, 2012

The relation the cosine angle between vectors and their inner product
















This shows the plane triangle with vectors x, y, and y-x where the coordinate axis are defined in terms of the plane of vector x, or in three dimensions, the vector x on the relative plane of such coordinate axis can be thought as having x1 = relative x component, x2 = relative y component. Noticing that the direction y3 a relative z component is perpendicular to component plane of x1 and x2.

First, I'll address why the inner product must be zero for two perpendicular vectors.

For two given vectors x = (x1,x2, …, xn) and y = (y1, y2, …, yn), it should be noted that two vectors are perpendicular if







This results from the Pythagorean formula where the magnitude (distances) of each side length of the vectors on the left side of the equation squared and summed equal the magnitude (distance) of of the vector x-y on the right side of the equation.  One would note the relation of vectors above with application to the Pythagorean formula, while the figure above demonstrates relations here in three dimensions, this application extends to n dimensions likewise.


Expanding the right side of the equation (1) we have







we'd note that expansion of the left side of equation (1) leads to cancellations of the terms


  





Thus we are left with the requirement for the given equality that the central group of terms in equation (2) are equal to zero, or the “dot product” (or inner product) of vectors x and y are orthogonal if








Now getting to the relation of the cosine angle between two vectors x and y.



















We'll demonstrate the relation of the inner product using the figure above which is shown in two dimensions. Note this could be extended to n dimensions but for now we'll focus on two dimensions in deriving the relation between the cosine angle of two given vectors and an inner product.

From the figure above one can note the following relations,




  






Now using the relation θ = β - α and using the known trigonometric sum/difference identity and substituting the relations above we have









This can be generalized to any vectors of n dimensions such that









Sources compiled from Linear Algebra and Applications, Strang, 1988.


Friday, August 17, 2012

Prime natural as evidenced in biological life

Watching 'Through the Wormhole with Morgan Freeman' which discussed alien communication through prime numbers which discussed the possibility through genomics.  Interestingly enough I would suggest the gestation cycle of the Magicicada which is found to be in prime number cycles 13 and 17 years.  It were theorized natural selection produced such variation on the basis of survival advantages relative to predators whose gestation maximums were non prime variants.  Interestingly enough while this sort of gestation cycle I would guess is extremely rare, it does give natural advantages in terms of evolution.

Building simple mathematical diagrams with free software on the quick

Some methods in constructing formulas and diagrams on the quick here.   There may be some decent software out there for free which does much the same, or otherwise pay for software that can construct the same.  Aside from free math plotters which abound on the internet, and especially free software for python (if you program in this language) like scipy, matlibplot, gnuplot, and the like.  If you were wanting to set up diagrams really fast, you could use programs like Trimble Sketchup (used to be Google sketchup) which I've found to be the quickest and easiest in setting up plot points and setting up perpendicular angles on arbitrary axis.  Generally with graph construction, I make sure the camera is set to a top view, and then plot any number of given points.  Sketchup is nice in providing a fill for a given set of inter connected points, like lines, squares, arcs, and so forth which makes for much more graphical aid constructions in math modeling in some respects, albeit for more complex curvatures and shapes, you'd probably resort to other methods, or learn, if the interface is still available, using Ruby interface which is sort of python like but different. Once having constructed your graph and having appropriated your view perspective to the appropriate level from such perspective you can obtain a 2d rendering by simply hitting the print screen.  If you are running on windows, keep in mind you'd have to open up a graphics program (like Microsoft Paint which is provided for free) and then click the paste button in Windows 7 to paste the bit map photo into your program from Window's clipboard, or alternately if you are running SketchUp from wine on a linux distro, the print screen method (in Linux Mint and Ubuntu) are the same, the output print screen goes to your home folders Pictures folder generally speaking.  Here, generally you can do some simple photo cropping and the graph is ready for import into any desired text editor or alternate drawing program.  In this case if I want to add formulation into the graph, I've used the LibreOffice Drawing application.  This is nice since you can provide graphical formulation overlays to a given imported photo, and customization in terms of the typesetting of formulation text relative the photo (or in this case the graph) can be situated generally as desired although I haven't figured out how to rotate formula object text overlays in this case.  Once the given graphics are as desired you can either export to a desired imaging format, or as I've done I simply snapshot the perspective view again, and crop the photo in a given free image editing software (Gimp in Linux, or Shotwell does the trick).  Keep in mind if you hadn't like the standard gray imaging fill textures native to drawn mesh objects in SketchUp you could import any desired texture for filling the surface if you hadn't like the graphical diagrams object textures.  Just need to add this in Sketchup before rendering your snapshot, and then follow the steps as desired for adding formula objects to the given text.  Generally speaking this works well for simple mathematical diagrams especially when dealing with those requiring models designed with orthogonal (perpendicular) lines and simple curvatures.  

Exploration of the Bézier curve


Special case of the Bézier curve is as follows.

As pre requisite recommend reading about the Bézier curve and De_Casteljau's algorithm which provides geometric interpretation to curve construction here.

Where a curvature in a local coordinate system has no inflection points and can be described by one local maximum where this is defined in terms of a local y position where a relative coordinate system defined by the plane between points P0 and P3), and given two points P1 and P2 such that the relative positions y1r and y2r on such plane are equidistant from the tangent of the line P0 and P3. A local y_r maximum is given by








where and θP0,P3 represents the angle of the tangent between the segment (P0,P3)


Proof:
We can rotate and translate the given coordinate axis such that such that the P1 represents a given origin 0,0 on a relative coordinate system, and furthermore we can ensure that rotation of the coordinate plane also matches the tangent line of line P0, P3, so that y0, and y3 are zero while x0 and x3 are not equal. By assumptions above
y1 and y2 are equal and remain so under coordinate changes so that are Bézier equation becomes for the y relative in the parametric form  








where yr(t) is the parametric form of the Bézier equation in our rotated and translated coordinate plane. Keep in mind that the parametric form on the rotated plane preserve the magnitude and the relative positions of P0, P1, P2, and P3.

taking the derivative with respect to t we have








as long as xr(t) is not simultaneously 0 at t, the derivative dyr/ dxr takes the form dyr / dt / dxr / dt
setting this equal to zero means that we are concerned with the zero in the numerator,

so we solve for yr '(t) = 0

In this case a maximum slope on the relative coordinate system is found at

t = 1/2

Substituting t = 1/2 into the equation yr (t) means







or








we need rotate our coordinate P1 to relative coordinate along side providing a translation of such coordinates as this provides a sense of scale in the rotated coordinate system on the relative coordinate system relative to original coordinate positions, or this is to say, expressing the local y in terms of control point P1.

A translation can be defined with an affine transformation.


In order to express P0 as a point of origin on our given transformed coordinate system.

or in the case of our coordinate P0 this is written  










while a rotation in coordinates is defined by


  








Thus we can see that P0 is zero under the series of transforms with




  






where this resultant vector (0,0,1) time the rotation matrix is also zero.

We can see that P3 is zero on the transformed y relative under the series of transforms with the affine translation.


rt*tr*P3  

for the affine transform










and for rotation











Here examining the y relative component of the transformed P3 position we should notice that y relative coordinate component is









geometrically one can see this from the following graph showing the rotation axis and original axis

The graph will demonstrates points are already affine translated




















Here where θ in the graph equals the given rotation angle defined above we can see the y' components cancel when subtracted which results from the rotation matrix transform and the point P3 - P0 lay on the zero axis of the new rotated coordinate system.



Similarly under transformation y1r can be expressed in terms of P1 as





Thus for any coordinate point we have a transform which is



  

  




substituting eq. (2) into (1) we have


  





We can check that the t = 1/2 doesn't simultaneously equal to zero here, for xr'(t).

If we wanted to find the original positions x(t), y(t) for t = 1/2 we can either re transform coordinates
using the inverse of the transform matrix above, or we could compute the Bézier curve for t = 1/2
which should remain relatively invariant in so far as the arrangement of points overall for the given
curvature. In other words, rotation and translation only changes the position of all points equally not the relative arrangement of points for such curvature. Why is this?

The Bézier curve geometrically computes on the basis of the relative arrangement of points in determining the shape of the curve, the relative arrangement of control points control the shape of the curvature, but this remains invariant (unchanged) under rotation and translation.

In other words, if the relative angles remain the same between control points alongside preservation of magnitude, these will determine the points on the curve which should be relatively the same irrespective of choice in coordinate plane. Geometrically speaking the points of the polygon formed initially by the control points are the same relatively speaking in so far as distance magnitudes, and the t parameterization on the relative coordinate systems trace the same relative distance when constructing a solution on the basis of relative spatial subdivisions. In the case of the cubic, a triangle is formed irrespective axis at point t0 on any axis consisting of the same side lengths, and this in turn leads to a line subdivision of the same magnitude line in length irrespective of axis at t0 which determines the point on the Bézier curve. The points themselves are variant under rotation and translation but not the shape of the curve.
It would be worth noting that in the original coordinate system the relative maximum computed t = 1/2 may not the maximum of the curve, or a given slope = 0 at such point, but the relative coordinate

Monday, August 13, 2012

Gauss' Quadrature (Integration) – Formal


Covered chapter 19.3 from Numerical Methods for Scientists and Engineers, Hamming.


If having followed the previous post, which introduced the formulation by way of sample points as parameters technique, one will now have some understanding with respect to the ideas presented on this next topic. The ideas are really the same except generalized a bit more. Prerequisites here are also the same. There will be use of series summations included in this topic. As a refresher to series summation, I'd present the following series here and define a sequence alongside this.

Firstly, let's consider a simple sequence like  

a = {1, 2, 3, 4 , 5, 6, 7}

Here the series of a is written









or we can also express sequence of a as









where the sequence {ai}is written







Now introducing Gauss quadrature integration. Let N points exist such that



  





where both the weights and the sample points are regarded as parameters.


For all wk and xk we have a total of N wk xk terms which means there are N+N = 2N parameters in total.

The defining equations in this case like the previous example posting are generalized with 2N defining equations:














 As in the previous posting we use a polynomial only it is composed of N factors as opposed to 2 meaning this is a polynomial of Nth degree








Remember before when we had a polynomial of 2nd degree, we had 2 coefficients c0 and c1, in this case we have N coefficients c0, c1, …, cN-1. Notice the sequence case pattern here?

Procedurally we'd do much the same as we did in the previous postings which were to multiply each of the N coefficients c0, c1, …, cN-1 respectively times each of the defining equations above, or in the generalized form, we multiply the j th equations by cj and sum these equations which takes the form









noting here that xk is a factor (or zero) in the polynomial π (x) and zeros the polynomial.

In the previous posting it were more or less demonstrated that the added cj multiplied mjth equations plus mN th equations would lead to grouping of terms leading to a given wk π(xk) series. See the previous posting example for the case N = 2. As it turns out the same as generally true for all cases of N.

Procedurally like the previous posting, we shift the multipliers cj down one line and repeat the process to get











Thus we have 2 equations of this form so far. We need a total of N equations of this form so we repeat the process of shifting our multipliers down to the k th case so that which results in N total equations of this form. Where the final equation in such equation generating sequence is


  







At the moment, will for go providing an example here, but it suffices to say we can use the same methods found solving the set of N linear equations for all coefficients c0, c1, …, cN-1. You could apply solution techniques found in linear algebra to accomplish this.  Once having coefficients for the given N the degree polynomial one would have to determine factorization here.  Fortunately, there are methods for doing this, but this extends beyond typical high school and college algebra.  Here is a link to some factorization techniques however.  Probably wise to have a computer or computational aids to do much of this since much of this may require number crunching and extends beyond what one might want to do by hand in this case of higher degree polynomials.  Having this, we then reapply the same techniques to solve the the N generated equations for our given weights w0, w1, …, wN-1.

Also we can apply this form of integration with respect to any function f(x).  Here we did so where f(x) = 1.












Saturday, August 11, 2012

Formulas using sample points as parameters.


Providing some added information to the examples chapter of the book Numerical Methods for Scientists and Engineers (19.2)

The problem is estimating the following integral from two samples:








The parameters here are w_1, w_2, x_1, and x_2. Just as in the previous posting we use four defining equations. Why four and why not three or less? As it turns our for each parameter we need to construct a set of unique linear equations to solve all of the given parameters...this follows from Linear algebra regarding a problem of 4 unknowns, so we'd need for four sets of unique linearly independent equations to solve each such parameter.

Thus we start using exact equations for f(x) in successive powers of xn where n = 0, 1, 2, and 3 in this case.

So the defining equations are :












Keep in mind the book actually evaluates these integrals, and I'll provide some brief explanation on evaluation techniques here.

For equation (1), we'd need to evaluate the definite integral on the left side of the equation. This could otherwise be rewritten as








Remember that while ex approaches a infinitely large number the inverse of this approaches zero. Also remember e0 = 1, from basic natural logarithmic identities (college level algebra).

I'll cover integration techniques given by integration by parts for equation (2), and then we'll rely on a handy integration tables formula which is








this formula can be seen more clearly in our given methods found in evaluating the integral from the left side of equation (2). Namely integration by parts in successive application occur here.

Also I'd mention at this point, we can also use another handy rule known as L'Hopital's rule which goes as follows:











Thus, for instance,









is in indeterminate form, so we can apply L'hopitals rule. Noting e-x = 1 / ex.

Thus we take the first derivatives of f(x) = x and g(x) = ex which yields









We can apply successive nth derivative applications of L'Hopital's Rule in the case of a nth power of x for the indeterminate case successively occurring so noting the factorial in the numerator after successive derivatives is a constant in the evaluation of such limit and thus is fixed 










By the way a factorial if you had forgotten is n! = n*(n-1)*...(2)*1
Thus, 3! = 3*2*1 for instance.
Let's go ahead and evaluate the integral of equation (2) on the left side

Using integration by parts, we have

















For the integral in eq.(3) on the left side, we'll use our handy integration formula eq.(5a) to evaluate (which is basically an integration by parts formula) here. We'll use the results of eq.(7) to further evaluate this integral.











Finally we'll evaluate the integral in eq.(4) on the left side, we'll use our handy integration formula eq.(5a) , and we'll use the results of eq.(8) to further evaluate this integral.











The defining equations (1), (2), (3), and (4) can now be rewritten using equations (6), (7), (8), and (9) as













To the right of the defining equations are coefficients c0, c1, and 1.
These are to applied to a polynomial that will be used for defining our sample points.

The polynomial we use is a second degree 








multiply eq. (10) by c0, eq. (11) by c1, and eq. (12) by 1, and the add these equations together so










Using the second multiplier column to the right of the first column on eq. (10), (11), (12), and (13),
we reapply the same process again as in (14) to get









We then have from eq. (14) and (15) two pairs of linear equations 









The solution to this is c1 = -4, and c0 = 2

These are the coefficients of eq. (13a), so we have






The quadratic equation solves this providing samples points 









Applying these sample points to the defining equations (10), and (11) gives


 




 
Again we solve these linear equations for w1 and w2
which yields










Our formula above becomes









indicated “exact for cubics using only two samples of the integrand”.

“How did we know that the weights we found from the first two defining equations would satisfy the last two equations? The answer is simple; we choose the xi so that the last two equations were linear combinations (with coefficients c0, c1, and 1) of the first two equations; hence the wi automatically satisfied the last two equations.”

Numerical Methods for Scientists and Engineers, Dover, pg.319.







Oblivion

 Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...