Friday, August 17, 2012

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.







Direct Method for Finding Formulas


Direct method for finding formulas

Pre requisites: Calculus, College level Algebra, Linear Algebra, and Analytic Geometry, or at least some basic Trigonometry.

This next technique similarly demonstrates yet another derivation of the Simpson formula, but also goes beyond classical interpolation in that one can find through defining equations substituted into a given formula, solutions to a given function.

So this goes as follows. Let an a formula be written as







You may notice this being similar to the Simpson formula except having undetermined coefficients a, b, and c. What we do next is set up a series of linear equations by substituting three different defining equations and solving both sides with the given values, x = -1, 0, 1 as indicated above.

The defining equations are:










If we solve for the coefficients through substitution here we end up with the Simpson's formula yet again.

Demonstrating this in application.

Finding the formula for












Where the undefined coefficients are w-1, w0, and w1.

We construct the defining equations similarly as in above, but the results are different.











So If you'd forgotten your integration techniques here, I'll provide a brief refresher here in terms of techniques. In this case we'll us a well known integration by parts method.


For Equation (4) we have using substitutions 


 







For equation (5) to evaluate the left hand side of the equation we use, integration by parts with substitutions.
















 
For equation (6) we use integration by parts as we did before above,
























Substituting eq.s (8) into (4), (10) into (5), and (13) into (6), the defining equations can be written.












 
Now we have a set of linear equations that can be solved via substitution (Gaussian elimination) or other preferred method.

Using substitutions, we find














Thus the given formula looks as follows:






This will eventually lead into the another technique which is doing much the same, except using sample points as parameters.   Basically, rather then using x = -1, 0, and 1 as above, we define different sample points in determining the formula for such function.   I might also mention alongside this Gauss Quadrature Integration which is merely an abstraction of the method of determining formulas from sample points as parameters method...just applied in the nth case.


In case you are wondering where all the readings were taken from I'd cite credit here to Numerical methods for Scientists and Engineers, R.W. Hamming, Dover

Just recent past post is also a credit to topics considered here.  Much of this could be considered supplementary to his writings.

A long time

    The years have passed.  Life presents all the new challenges and stresses.   I am thinking of the Ship of Theseus and re-examining this ...