Friday 14 February 2014

Verifying correctness of vector solution for linear equation in three variables with the determinant form of the solution

Verifying the correctness of the vector solution for linear equation in three variables

In one of the earlier blogs it was shown that the solution of linear equations could be written entirely in vector form
In this blog I will verify the vector form of solution with the determinant form. Linear equation problem is given below

$$ a_1x+a_2y+a_3z=d_1\\ b_1x+b_2y+b_3z=d_2\\ c_1x+c_2y+c_3z=d_3\\ $$ Given below is the determinant form of solution. $$ x = \frac{\left| \begin{array}{ccc} d_1 & a_2 & a_3 \\ d_2 & b_2 & b_3 \\ d_3 & c_2 & c_3\end{array} \right|}{\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_2 & b_2 & b_3 \\ c_3 & c_2 & c_3\end{array} \right|} \space\space\space = \frac{d_1b_2c_3-d_1b_3c_2-d_2a_2c_3+d_2a_3c_2+d_3a_2b_3-b_3b_2a_3}{\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_2 & b_2 & b_3 \\ c_3 & c_2 & c_3\end{array} \right|}\\ \space\space\\ y = \frac{\left| \begin{array}{ccc} a_1 & d_1 & a_3 \\ b_2 & d_2 & b_3 \\ c_3 & d_3 & c_3\end{array} \right|}{\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_2 & b_2 & b_3 \\ c_3 & c_2 & c_3\end{array} \right|} \space\space\space = \frac{d_1b_3c_1-d_1b_1c_3+d_2a_1c_3-a_3c_1d_2+b_1a_3d_3-d_3a_1b_3}{\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_2 & b_2 & b_3 \\ c_3 & c_2 & c_3\end{array} \right|}\\ \space\space\\ z = \frac{\left| \begin{array}{ccc} a_1 & a_2 & d_1 \\ b_2 & b_2 & d_2 \\ c_3 & c_2 & d_3\end{array} \right|}{\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_2 & b_2 & b_3 \\ c_3 & c_2 & c_3\end{array} \right|} \space\space\space = \frac{d_1b_1c_2-d_1c_1b_2+d_2a_2c_1-d_2a_1c_2+d_3a_1b_2-d_3b_1a_2}{\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_2 & b_2 & b_3 \\ c_3 & c_2 & c_3\end{array} \right|}\\ $$ Solving the same using the vector formula provided in earlier blog. Vector form of the above linear equations is given below. $$\overrightarrow{A}.\overrightarrow{r} = d_1\\ \overrightarrow{B}.\overrightarrow{r} = d_2\\ \overrightarrow{C}.\overrightarrow{r} = d_3\\ $$
Where
$$ \overrightarrow{A} = a_1\mathbf{i}+a_2\mathbf{j}+a_3\mathbf{k}\\ \overrightarrow{B} = b_1\mathbf{i}+b_2\mathbf{j}+b_3\mathbf{k}\\ \overrightarrow{C} = c_1\mathbf{i}+c_2\mathbf{j}+c_3\mathbf{k}\\ \overrightarrow{r} = x\mathbf{i}+y\mathbf{j}+z\mathbf{k}\\ $$
$.$ is the usual dot product in vectors
$\mathbf{i},\mathbf{j},\mathbf{k}$ are unit vectors
$$ \overrightarrow{r} = \frac{(\overrightarrow{B}\times\overrightarrow{C}d_1+\overrightarrow{C}\times\overrightarrow{A}d_2+\overrightarrow{A}\times\overrightarrow{B}d_3)}{\overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C}} $$ The denominator in the above equation is the volume of the parallelopipe. Which can be written in determinant form as below. The cross and dot product also solves to the same expression. $$ D = {\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \\ c_1 & c_2 & c_3\end{array} \right|}\\ $$ All we need to do is show that the numerator is equal to the numerator of the determinant form. $$ \space\\ \overrightarrow{B}\times\overrightarrow{C}d_1 = {\left| \begin{array}{ccc} i & j & k \\ b_1 & b_2 & b_3 \\ c_1 & c_2 & c_3\end{array} \right|}d_1\space =\space i(b_2c_3-c_2b_3)d_1+j(c_1b_3-b_1c_3)d_1+k(b_1c_2-c_1b_2)d_1\\ \space\\ \overrightarrow{C}\times\overrightarrow{A}d_2 = {\left| \begin{array}{ccc} i & j & k \\ c_1 & c_2 & c_3 \\ a_1 & a_2 & a_3\end{array} \right|}d_2\space =\space i(c_2a_3-a_2c_3)d_2+j(a_1c_3-c_1a_3)d_2+k(c_1a_2-a_1c_2)d_2\\ \space\\ \overrightarrow{A}\times\overrightarrow{B}d_3 = {\left| \begin{array}{ccc} i & j & k \\ a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3\end{array} \right|}d_3\space =\space i(a_2b_3-b_2a_3)d_3+j(b_1a_3-a_1b_3)d_3+k(a_1b_2-a_2b_1)d_3\\ \space\\ \space\\ \space\\ \frac{\overrightarrow{B}\times\overrightarrow{C}d_1+\overrightarrow{C}\times\overrightarrow{A}d_2+\overrightarrow{A}\times\overrightarrow{B}d_3}{\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \\ c_1 & c_2 & c_3\end{array} \right|}\\\\\space\\ =\frac{i(b_2c_3d_1-c_2b_3d_1+c_2a_3d_2-a_2c_3d_2+a_2b_3d_3-b_2a_3d_3)+j(c_1b_3d_1-b_1c_3d_1+a_1c_3d_2-c_1a_3d_2+b_1a_3d_3-a_1b_3d_3)+k(b_1c_2d_1-c_1b_2d_1+c_1a_2d_2-a_1c_2d_2+a_1b_2d_3-a_2b_1d_3)}{\left| \begin{array}{ccc} a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \\ c_1 & c_2 & c_3\end{array} \right|}\\ $$ The components of the above vector are same as the solution of x,y,x arrived at by using the determinant method. Hence the two results are verified to be correct.
RP
info@softanalytics.net




Thursday 13 February 2014

Discussing orderless choice of two items from n items

Orderless choice of 2 objects from n objects

We know that the number of ways of choosing two items from n items is given by $^nC_2$
We can look at the choice problem as in the diagram below.
Each node in the tree is representative of a choice of two items. Therefore total number of choices is equal to the number of nodes in the above tree. Total number of nodes is
$1+2+3+4......(n-1)$ = $\frac{n(n-1)}{2}$ = $^nC_2$
Similar analysis and derivation could be done for $^nC_3$ and $^nC_r$



RP
info@softanalytics.net




Sunday 24 November 2013

Solution of Linear Eqns in three dimensions

The solution of the following set of equations has been well studied.

$$a_1x+a_2y+a_3z=d_1\\ b_1x+b_2y+b_3z=d_2\\ c_1x+c_2y+c_3z=d_3\\ $$
The most popular method of solving this is through determinants.

In todays article I am putting a different form and solution. for the above equations.
Changing the form of these equations to Vectors

We get
$$\overrightarrow{A}.\overrightarrow{r} = d_1\\ \overrightarrow{B}.\overrightarrow{r} = d_2\\ \overrightarrow{C}.\overrightarrow{r} = d_3\\ $$
Where
$$ \overrightarrow{A} = a_1\mathbf{i}+a_2\mathbf{j}+a_3\mathbf{k}\\ \overrightarrow{B} = b_1\mathbf{i}+b_2\mathbf{j}+b_3\mathbf{k}\\ \overrightarrow{C} = c_1\mathbf{i}+c_2\mathbf{j}+c_3\mathbf{k}\\ \overrightarrow{r} = x\mathbf{i}+y\mathbf{j}+z\mathbf{k}\\ $$
$.$ is the usual dot product in vectors
$\mathbf{i},\mathbf{j},\mathbf{k}$ are unit vectors
It occurs to me that the solution for the above could be
$$ \overrightarrow{r} = \frac{(\overrightarrow{B}\times\overrightarrow{C}d_1+\overrightarrow{C}\times\overrightarrow{A}d_2+\overrightarrow{A}\times\overrightarrow{B}d_3)}{\overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C}} $$
I have coarsely checked this for correctness by solving using determinants and have found
similar result.

The method of coming to the above solution is as below

$$ \overrightarrow{C}\times\overrightarrow{B}.\overrightarrow{A}.r = \overrightarrow{C}\times\overrightarrow{B}d_1\\ \overrightarrow{C}\times\overrightarrow{A}.\overrightarrow{B}.r = \overrightarrow{C}\times\overrightarrow{A}d_2\\ \overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C}.r = \overrightarrow{A}\times\overrightarrow{B}d_3\\ $$
An implicit associativity is assumed above which is not correct. The above three equations are added and we get

$$ [\overrightarrow{C}\times\overrightarrow{B}.\overrightarrow{A} + \overrightarrow{C}\times\overrightarrow{A}.\overrightarrow{B} + \overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C}].\overrightarrow{r} = \overrightarrow{C}\times\overrightarrow{B}d_1+\overrightarrow{C}\times\overrightarrow{A}d_2+\overrightarrow{A}\times\overrightarrow{B}d_3\\ $$
Hence from the above after rearranging we get $$ \overrightarrow{r} = \frac{\overrightarrow{C}\times\overrightarrow{B}d_1+\overrightarrow{C}\times\overrightarrow{A}d_2+\overrightarrow{A}\times\overrightarrow{B}d_3}{\overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C}+\overrightarrow{C}\times\overrightarrow{B}.\overrightarrow{A}+\overrightarrow{C}\times\overrightarrow{A}.\overrightarrow{B}}\\ \\ reduces \space to\\ \overrightarrow{r} = \frac{(\overrightarrow{B}\times\overrightarrow{C}d_1+\overrightarrow{C}\times\overrightarrow{A}d_2+\overrightarrow{A}\times\overrightarrow{B}d_3)}{\overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C}} $$ as the other two components are of opposite sign and cancle each other
The below is true since they represent the volume of the parallelopiped formed by vectors $\overrightarrow{A}, \overrightarrow{B}, \overrightarrow{C}$. Assuming the vectors are cyclic in order in 3D space. Then $$ \overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C} = \overrightarrow{B}\times\overrightarrow{C}.\overrightarrow{A} = \overrightarrow{C}\times\overrightarrow{A}.\overrightarrow{B}\\ \overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C} = -\overrightarrow{B}\times\overrightarrow{A}.\overrightarrow{C}\\ \overrightarrow{B}\times\overrightarrow{C}.\overrightarrow{A} = -\overrightarrow{C}\times\overrightarrow{B}.\overrightarrow{A}\\ \overrightarrow{C}\times\overrightarrow{A}.\overrightarrow{B} = -\overrightarrow{A}\times\overrightarrow{C}.\overrightarrow{B}\\ $$

The above solution could be extended for dimensions higher than three. In this I am not covering the same.

Alternate solution to arriving at the aboev formula

Assuming that the solution to the above equation is of the form without any loss of generality
$$ \overrightarrow{r} = t\overrightarrow{A}\times\overrightarrow{B}+u\overrightarrow{B}\times\overrightarrow{C}+v\overrightarrow{C}\times\overrightarrow{A}\\ $$ where $t,u,v$ are scalars coefficients.
$t,u,v$ can be solved as below

Substitute $\overrightarrow{r}$ into the original equations
  $$ \overrightarrow{A}(t\overrightarrow{A}\times\overrightarrow{B}+u\overrightarrow{B}\times\overrightarrow{C}+v\overrightarrow{C}\times\overrightarrow{A}) = d_1\\ \overrightarrow{A}.\overrightarrow{A}\times\overrightarrow{B}=0\\ \overrightarrow{A}.\overrightarrow{B}\times\overrightarrow{C} \space has \space some \space value\\ \overrightarrow{A}.\overrightarrow{C}\times\overrightarrow{A}=0\\ $$ Therefore we get $$ u = \frac{d_1}{\overrightarrow{A}.\overrightarrow{B}\times\overrightarrow{C}}\\ Similarly \space for \space t,v \space we \space get \space t = \frac{d_2}{\overrightarrow{C}.\overrightarrow{A}\times\overrightarrow{B}}\\ v = \frac{d_3}{\overrightarrow{B}.\overrightarrow{C}\times\overrightarrow{A}}\\ $$
Since the $\overrightarrow{A}.\overrightarrow{B}\times\overrightarrow{C} = \overrightarrow{C}.\overrightarrow{A}\times\overrightarrow{B} = \overrightarrow{B}.\overrightarrow{C}\times\overrightarrow{A} =$ volume of parallelopipe

Therefore the solution to the linear equation is
Substituting $u,t,v$ in the initial equation we get the following
$$ \overrightarrow{r} = \frac{\overrightarrow{B}\times\overrightarrow{C}d_1+\overrightarrow{C}\times\overrightarrow{A}d_2+\overrightarrow{A}\times\overrightarrow{B}d_3}{\overrightarrow{A}\times\overrightarrow{B}.\overrightarrow{C}}\\ $$ RP
info@softanalytics.net



Friday 6 September 2013

Area of triangle in 3D space

Once it occurred to me if there was a very quick way (split seconds) of computing the area of the triangle formed by the points of axis intercepts of the plane
$\frac{x}{a}+\frac{y}{b}+\frac{z}{c}=1$ Solution:
A half tetrahedron is formed by the planes $xy, yz, xz$ and $\frac{x}{a}+\frac{y}{b}+\frac{z}{c}=1$
Three of the sides of the tetrahedron have area $ab/2, bc/2, ac/2$. These sides are orthogonal
Hence the vector equivalent of the resultant is
$\frac{abi}{2} + \frac{bcj}{2} + \frac{ack}{2}$  (where $i,j,k$ are unit vectors)
Modulus of the resultant is (   $\sqrt{a^2b^2/4 + b^2c^2/4 + a^2c^2/4}$   )

Area of interest is

$$ \sqrt { a^2b^2/4 + b^2c^2/4 + a^2c^2/4 }
$$
This method could be applied to the generic case where we need to find the area of the
triangle formed by ($x1,y1,z1) (x2,y2,z2) (x3,y3,z3)$
Steps would be as below

Transform the coordinates in such a manner that the coordinates above turn into axes intercepts
$(0,0,a) (0,b,0) (c,0,0)$

Then apply the formula above

RP
info@softanalytics.net



Thursday 5 September 2013

Analyzing the differentiability of $\sqrt{x^2}$

Analyzing differentiability of $\sqrt{x^2}$

As we see a quick simplification of $\sqrt{x^2}$ yields $x$ which is a straight line.
Another simplification yields $|x|$

Clearly $|x|$ is not differentiable whereas $x$ is differentiable.

Some people might contest the $|x|$ simplification saying that is not true. I think both simplifications are correct and hence depending upon the simplification this may or may not be differentiable.

RP
info@softanalytics.net