math

Finding the intersection of two vector equations.

I've been trying to solve this and I found an equation that gives the possibility of zero division errors. Not the best thing: v1 = (a,b) v2 = (c,d) d1 = (e,f) d2 = (h,i) l1: v1 + λd1 l2: v2 + µd2 Equation to find vector intersection of l1 and l2 programatically by re-arranging for lambda. (a,b) + λ(e,f) = (c,d) + µ(h,i) a + λe = c +...

Convert arbitrary length to a value between -1.0 a 1.0?

How can I convert a length into a value in the range -1.0 to 1.0? Example: my stage is 440px in length and accepts mouse events. I would like to click in the middle of the stage, and rather than an output of X = 220, I'd like it to be X = 0. Similarly, I'd like the real X = 0 to become X = -1.0 and the real X = 440 to become X = 1.0....

Is a point inside or outside a polygon which is on the surface of a globe

How do I determine if a point is inside or outside a polygon that lies on the the surface of the earth? The inside of the polygon can be determined via the right hand rule, ie. the inside of the polygon is on your right hand side when you walk around the polygon. The polygon may Circle either pole Cross the 180 longitude Cover more...

Draw Lines Over a Circle

There's a line A-B and C at the center between A and B. It forms a circle as in the figure. If we assume A-B line as a diameter of the circle and then C is it's center. My problem is I have no idea how to draw another three lines (in blue) each 45 degree away from AC or AB. No, this is not a homework, it's part of my complex geometry in ...

Which are the best LGPL Libraries for Numerical Methods, Optimization Techniques, DOE, Sensitivity Analysis?

I wish to perform some mathematical operations including Design of Experiments, Optimization Techniques, Sensitivity Analysis and Six-Sigma based Robust design for Aerospace Design project. I am developing applications for mechanical design engineers. I understand there are a few libraries like DAKOTA from sandia national labs that help...

area of intersection of two triangles, or a set of halfplanes, or area of a convex point set

I need to compute the area of the region of overlap between two triangles in the 2D plane. Oddly, I have written up code for the triangle-circle problem, and that works quite well and robustly, but I have trouble with the triangle-triangle problem. I already first check to see if one entirely contains the other, or if the other contains...

Poly1305AES MAC Authenticator generation problem

From page 5 of Bernstein's paper, it says to do a simple summation equation of c_q * r ^(q-x+1) from 1 to q and mod the entire thing by 2^130-5, add it to an AES output and mod it by 2^128. However, I cannot seem to get his test vectors. one of them is: c1 124bcb676f4f39395d883fb0f19ea3c66 c2 13...

Math Problem: Getting Coordinates From Position And Angle

let me begin by stating that's i'm dreadful at math. i'm attempting to reposition and rotate a rectangle. however, i need to rotate the rectangle from a point that is not 0,0 but according to how far its coordinates has shifted. i'm sure that doesn't make much sense, so i've made some sketches to help explain what i need. the image...

Non-sequential substitution in SymPy

I'm trying to use [SymPy][1] to substitute multiple terms in an expression at the same time. I tried the [subs function][2] with a dictionary as parameter, but found out that it substitutes sequentially. In : a.subs({a:b, b:c}) Out: c The problem is the first substitution resulted in a term that can be substituted by the second substi...

Books linking Problem Solving to Math Concepts (like discrete mathematics)?

Hi! I'm a few years into my Computer Science Education, and I had to transfer to a new school in the between years. The problem I'm having is that the "intro" classes at my first school focused first on Mostly professional programming skills, like problem design, and put the mathematics concepts in later courses, and when I transferred, ...

Detecting if an integer can be writen as a multiply of given integers

I have a set of given integers: A[] = { 2, 3, 4, 5, 6, 7, 8, 10, 15, 20, 25, 30, 40, 50, 100, 500 } I want to check if a given integer T can be written as a multiple of the numbers in A[]; EDIT CLARIFICATION: any number in A[] can be used.If used can be used only one time. EX 60 is a valid T.60=30*2. AlSO 90 is valid . 90=3*5*6 Check...

Condition for single bit code for a character in Huffman code?

This is a question I ran into in school settings, but it keeps bugging me so I decided to ask it here. In Huffman compression, fixed-length sequences (characters) are encoded with variable-length sequences. The code sequence length depends on the frequencies (or probabilities) of the source characters. My questions is: what is the mini...

While loop into 2 different divs?

Hey all, I've got an about page, and two HTML columns and I want to while loop the contents of my mysql query into BOTH columns, even though they are defined as two different divs. What I was thinking of doing is somehow dividing the amount of rows in the mysql database by 2, and then showing half and half, but I'm not sure how to do thi...

How to calculate the inverse factorial of a real number?

Is there some way to calculate the inverse factorials of real numbers? For example - 1.5 ! = 1.32934039 Is there some way to obtain 1.5 back if I have the value 1.32934039? I am trying http://www.wolframalpha.com/input/?i=Gamma^(-1)[1.32934039] but that is a fail. ...

Low pass filter using FFT instead of convolution implementation

Implementing a low pass FIR filter, when should one use FFT and IFFT instead of time-domain convolution? The goal is to achieve the lowest CPU time required for real-time calculations. As I know, FFT has about O(n log n) complexity, but convolution in the time domain is of O(n²) complexity. To implement a low pass filter in the frequen...

sine wave glissando from one pitch to another in Numpy

Hello! I have been working on a program where I need to slowly and smoothly change the pitch of a sine wave from one pitch to another. I am able to get an array of the frequency the pitch should be at any given moment (for instance, [440, 526.5, 634.2 794.8, 880], though much, much longer) but it seems I am unable to actually apply tha...

What will be returned when dividing integer with an integer and returning value in an integer.

I want to divide size of a control with a size of a form and want to gets its floor value. I was thinking what would be returned when I try to divide an integer with an integer and store its result again in an integer. I want only floor value. I tried to use Math.Floor, Math.Truncate but it shows me an error that call between following ...

Circle approximations using Bezier curves.

Hello. I have 2 questions about bezier curves, and using them to approximate portions of circles. Given the unit circle arc (1,0)->(cos(a),sin(a)) where 0 < a < pi/2, will it result in a good approximation of this arc to find the bezier curve's control points p1, p2 by solving the equations imposed by the requirements B(1/3) = (cos(a/3...

how to integrate / link R and Computer Algebra Systems (CAS)

I'm looking for a possibility to use different 'higher' math operations in combination with R. A link or integration between R and a CAS would be the perfect solution. Which integration of R and other (math & statistic related) systems or vice verse are out there? How well do they work? What would you suggest? How expansive (in time, mo...

Libraries for manipulating multivariate polynomials

Hi. I need to write some code that deals with generating and manipulating multivariable polynomials. I'll outline my task with a simplified example. Lets say I am given three expressions: 2x^2, 3y + 1, and 1z. I then need to multiply these together which would give me 6x^2yz + 2x^2z. Then I would like to find the partial derivatives of...