How to resolve the algorithm Vector products step by step in the Stata programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Vector products step by step in the Stata programming language

Table of Contents

Problem Statement

A vector is defined as having three dimensions as being represented by an ordered collection of three numbers:   (X, Y, Z). If you imagine a graph with the   x   and   y   axis being at right angles to each other and having a third,   z   axis coming out of the page, then a triplet of numbers,   (X, Y, Z)   would represent a point in the region,   and a vector from the origin to the point. Given the vectors: then the following common vector products are defined:

Given the three vectors:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Vector products step by step in the Stata programming language

Source code in the stata programming language

mata
real scalar sprod(real colvector u, real colvector v) {
	return(u[1]*v[1] + u[2]*v[2] + u[3]*v[3])
}

real colvector vprod(real colvector u, real colvector v) {
	return(u[2]*v[3]-u[3]*v[2]\u[3]*v[1]-u[1]*v[3]\u[1]*v[2]-u[2]*v[1])
}

real scalar striple(real colvector u, real colvector v, real colvector w) {
	return(sprod(u, vprod(v, w)))
}

real colvector vtriple(real colvector u, real colvector v, real colvector w) {
	return(vprod(u, vprod(v, w)))
}

a = 3\4\5
b = 4\3\5
c = -5\-12\-13

sprod(a, b)
  49

vprod(a, b)
        1
    +------+
  1 |   5  |
  2 |   5  |
  3 |  -7  |
    +------+

striple(a, b, c)
  6

vtriple(a, b, c)
          1
    +--------+
  1 |  -267  |
  2 |   204  |
  3 |    -3  |
    +--------+
end


  

You may also check:How to resolve the algorithm Hofstadter Q sequence step by step in the C# programming language
You may also check:How to resolve the algorithm Infinity step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Evaluate binomial coefficients step by step in the F# programming language
You may also check:How to resolve the algorithm Nested function step by step in the J programming language
You may also check:How to resolve the algorithm Parametric polymorphism step by step in the Kotlin programming language