algebra

Subsequent weighted algorithm for comparison

I have two rows of numbers ... 1) 2 2 1 0 0 1 2) 1.5 1 0 .5 1 2 Each column is compared to each other. Lower values are better. For example Column 1, row 2's value (1.5) is more accurate than row 1 (2) In normal comparison I would take to the sum of each row and compare to the other row to find the lowest sum (most...

Formula for a curve (algebra in javascript)

I need an exponential equation with the following parameters: When x = 0, y = 153. When x = 500, y = 53. Y should increase exponentially as X approaches 0 and should decrease exponentially when X approaches 500. For some reason I can't remember how to do this. I'm sure once I see the equation (or one similar) I can figure out the rest....

Solving Algebraic Equations Programatically

I have six parametric equations using 18 (not actually 26) different variables, 6 of which are unknown. I could sit down with a couple of pads of paper and work out what the equations for each of the unknowns are, but is there a simple programatic solution (I'm thinking in Matlab) that will spit out the six equations I'm looking for? ...

Solving second degree simultaneous equation

What would be the solution to the following two equations ? A1uv + B1u + C1v + D1 = 0 A2uv + B2u + C2v + D2 = 0 u, v in [0, 1] The solution needs to be blazing fast because it needs to be solved for each pixel, hopefully a direct rather than iterative solution. This is basically trying to find the inverse of a coons patch where the ...

Multiplying out negated terms in boolean algebra?

I'm just learning boolean algebra at the moment. I read that for XOR we can rearrange the expression (A + B) . ¬(A + B) = A.¬A + A.¬B + B.¬A + B.¬B = A.¬B + B.¬A I can understand this but I'm unsure how I would proceed multiplying out an expression like (A + B) . (¬A + ¬B). If I just try and naively multiply out all the terms tha...

How could one implement multiplication in finite fields?

If F := GF(p^n) is the finite field with p^n elements, where p is a prime number and n a natural number, is there any efficient algorithm to work out the product of two elements in F? Here are my thoughts so far: I know that the standard construction of F is to take an irreducible polynomial f of degree n in GF(p) and then view elemen...

How to set up quadratic equation for a ray/sphere intersection?

I'm researching the math for a ray tracer, but I'm not following a transition that is made in just about every article I've read on the subject. This is what I have: Formula for a sphere: (X - Cx)^2 + (Y - Cy)^2 + (Z - Cz)^2 - R^2 = 0 Where R is the radius, C is the center, and X, Y, Z are all the points in the sphere. Formula for a ...

Relational algebra - what is the proper way to represent a 'having' clause?

Yes, this is a homework question but the names have been changed to protect the innocent. Meaning, I am not asking the homework question itself, but rather a small part of it so I can understand the whole. Let's say you have a SQL query like this: --The query would list car prices that occur more than once. select car_price from cars ...

Best way to calculate accuracy and display meaningful results

My current method allows me to determine the most accurate array but I cannot figure out a good way to display informative results. Here’s my situation … I compare X amount of integer arrays to a static integer array. For each position in the array I calculate the position’s accuracy result by comparing to the equivalent position in th...

How can one check for "safe" conversions between value types in .NET?

Back to the basics... For reference types, one can do this: SomeType someObject = firstObject as SomeType; if (someObject == null) { // Handle the situation gracefully } else { // Do stuff } For value types, my understanding is that we have implicit conve...

Help rearranging /solving an Equation

I have the following C formula bucket = (hash - _min) * ((_capacity-1) / range()); What I need to to rearrange the equation to return the _capacity instead of bucket (I have all other variables apart from _capacity). e.g. 96 = (926234929-805306368) * (( x -1) /1249540730) 836 = (1852139639-805306368) * ((x -1) /1249540730) As you c...

How can I remove a column from a sparse matrix efficiently?

The title pretty much says it all: If I am using the sparse.lil_matrix format, how can I remove a column from the matrix easily and efficiently? Thanks! ...

How would I find the highest/largest of something with relation algebra, domain relational calculus and tuple relational calculus

This is part of a homework assignment. I've got several questions asking find the eid of the employee with the highest salary, or 2nd highest salary. Find the pilot that is certified for the most aircrafts. I don't have any idea on how to do it. There aren't any examples in the chapter, and google is proving less that helpful. If someone...

Distance from a point to a polyhedron or to a polygon

I have a surface which is a polyhedron and I want to find the minimal distance between it and a given point P. Since the polyhedron is defined by many polygons in a 3d space, one way that occurs to me is to compare the distance to each polygon and choose the shortest distance. Still I am not sure about it. ...

Help to translate SQL query to Relational Algebra

Hi everyone, I'm having some difficulties with translating some queries to Relational Algebra. I've a great book about Database Design and here is a chapter about Relational Algebra but I still seem to have some trouble creating the right one: Thoes queries I've most difficuelt with is these: SELECT COUNT( cs.student_id ) AS counter F...

How do you calculate the reflex angle given to vectors in 3D space?

I want to calculate the angle between two vectors a and b. Lets assume these are at the origin. This can be done with theta = arccos(a . b / |a| * |b|) However arccos gives you the angle in [0, pi], i.e. it will never give you an angle greater than 180 degrees, which is what I want. So how do you find out when the vectors have gone pa...

Is there any Mathematical Model or Theory behind Programming Languages?

RDBMS are based on Relational Algebra as well as Codd's Model. Do we have something similar to that for Programming languages or OOP? ...

Unexpected result in C algebra for search algorithm.

Hi, I've implemented this search algorithm for an ordered array of integers. It works fine for the first data set I feed it (500 integers), but fails on longer searches. However, all of the sets work perfectly with the other four search algorithms I've implemented for the assignment. This is the function that returns a seg fault on lin...

Boolean algebra simplification

I need to reduce this boolean expression to its simplest form. Its given that the simplest form contains 3 terms and 7 literals. The expression is: x'yz + w'x'z + x'y + wxy + w'y'z We tried this in class, and even out recitation teacher could not figure it out. Any help would be appreciated. ...

O'Reilly book clarification on 2d linear system

The Oreilly book "Learning openCV" states at page 356 : Quote Before we get totally lost, let’s consider a particular realistic situation of taking measurements on a car driving in a parking lot. We might imagine that the state of the car could be summarized by two position variables, x and y, and two velocities, vx and vy. These four...