math

GSL/BLAS: Multiply a matrix with an inverse matrix

Hi! I'm using the GNU GSL to do some matrix calculations. I'm trying to multiply a matrix B with the inverse of a matrix A. Now I've noticed that the BLAS-part of GSL has a function to do this, but only if A is triangular. Is there a specific reason to this? Also, what would be the fastest way to do this computation? Should I invert A u...

What Math Do You Need To Read The Art Of Computer Programming?

I came to a career in software development with a degree in English, rather than Computer Science or another science/engineering background. I have gone a long way on my self-taught basis, but after 10+ years of doing this, I want to go back and fill in the gaps, particularly with the math. The obvious place to give myself a Comp-Sci ed...

Using errorbar() with semilogy() in MATLAB?

I'd like to plot data x & y with errorbars, ebar, and its fit, yfitted, on a semilog plot. This doesn't seem to work: figure; hold on; errorbar(x,y,ebar); semilogy(x,yfitted); Instead of semilog plot I get a linear plot. What should I be doing differently? ...

How to check collision in a drawn curve, instead of the Sprite's bound box

There are two Sprite's hit tests, one check the object (and have no precision on the curves) and the other check a specified (x, y) point. But, having curves drawn using Graphics.curveTo(), how do I check if 2 drawn curves are colliding? I'm not sure if this is an actionscript or a math problem... I want to check all (x,y) of a curve to...

Given grid coordinates, how can I determine the center point of a cell which they fall within?

I'm working on a simple board game using Appcelerator Titanium for iPhone (javascript - not that it matters for this question really). My problem isn't really language-specific, it's more of a general programming and math question. I have a grid of "cells" that is 10 columns by 10 rows (100 cells). It's a board game, like checkers/drau...

Practical uses of trig functions

What are some practical applications of sine, cosine, arc sine, etc. Can you distort images, calculate special values, or other stuff? Any opinions of the most used/important? ...

Rotate a circle around another circle

Short question: Given a point P and a line segment L, how do I find the point (or points) on L that are exactly X distance from P, if it guaranteed that there is such a point? The longer way to ask this question is with an image. Given two circles, one static and one dynamic, if you move the dynamic one towards the static one in a str...

PHP: Help with creating algorithim for File system structure for auto-incrememted images

I have nearly 1 million photos auto-incrememted starting at "1". So, I have the following: 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg .... 1000000.jpg Currently, I have all of these files in a single Ext4 linux directory. As you can imagine, the filesystem is crazy slow. Using PHP, how can I create an algorithm that divides up my images into a ...

FLEX Video player - play count

I have a video player in flex which constantly plays a movie. Is there a way to see how many times it has played? So each time the movie is played, text filled populates with +1. Thanks, Yan ...

Javascript Math Error: Inexact Floats

Possible Duplicates: Is JavaScripts Math broken? How is floating point stored? When does it matter? Code: var tax= 14900*(0.108); alert(tax); The above gives an answer of 1609.2 var tax1= 14900*(10.8/100); alert(tax1); The above gives an answer of 1609.200000000003 why? i guess i can round up the values, but why is t...

formulae / algorithm to select centre cells in a grid?

If I have a grid say consisting of 15 x 15 cells (but variable), what formulae or algorithm would I use to randomly select 20 cells clustered around the centre cell? I guess I would ideally like to be able to set the centre point, cluster radius, density etc... any pointers would be really appreciated! cheers. ...

Drawing the curve y = 1 - x ^ 4 in Processing/Java

I understand that y = x ^ n would be float y = (x, n) but what if i wanted to draw the curves y = 1 - x ^ 4 y = (1-x) ^ 4 y = 1-(1-x) ^ 4 Here's the code i wrote but it doesn't draw the curve mathematically correct for y = 1 - x ^ 4 for (int x = 0; x < 100; x++) { float n = norm(x, 0.0, 100.0); float y = pow(1-n, 4); y *= 100;...

Calculating e with high precision with python?

Is it possible to calculate the number e with high precision (2000+ decimal places) with Python? (I was thinking with Numpy or SciPy) ...

Mathematics and programming

I read a lot of blogs and forum posts about mathematics in programming and made a conclusion for myself that basic mathematics is needed in programming. I'm not a good mathematician. But is it somehow possible to improve my logical and algorithmical thinking without going deep into math science? Are there any excercises or some books tha...

Calculating Nth permutation step?

I have a char[26] of the letters a-z and via nested for statements I'm producing a list of sequences like: aaa, aaz... aba, abb, abz, ... zzy, zzz. Currently, the software is written to generate the list of all possible values from aaa-zzz and then maintains an index, and goes through each of them performing an operation on them. The...

using jquery, how would i find the closest match in an array, to a specified number

using jquery, how would i find the closest match in an array, to a specified number For example, you've got an array like this: 1, 3, 8, 10, 13, ... What number is closest to 4? 4 would return 3 2 would return 3 5 would return 3 6 would return 8 ive seen this done in many different languages, but not in jquery, is this possible to d...

Determine whether two sectors of a given circle intersect?

Anybody know how to determine whether two sectors of the same circle intersect? Let's say I have a sector A, expressed by starting and ending angles A1 and A2, and a sector B, expressed by starting angle B1 and ending angle B2. All angles ranges from 0..2*PI radians (or 0..360 degrees). How to determine whether angle A intersects wit...

Colour scale based on custom range? in HEX?

How do I create a custom colour scale ideally in Hex? say from yellow to red, depending on the height of an object? is this a correct way to achieve this or is there a better way without having to convert it at the end?: var r:int = 255; var b:int = 0; var maxHeight:int = 52; var minHeight:int = 21; var scale:int = 255 / (maxHeight-min...

How can I perform 64-bit division with a 32-bit divide instruction?

This is (AFAIK) a specific question within this general topic. Here's the situation: I have an embedded system (a video game console) based on a 32-bit RISC microcontroller (a variant of NEC's V810). I want to write a fixed-point math library. I read this article, but the accompanying source code is written in 386 assembly, so it's nei...

Algorithm to balance variably-sized items into roughly-balanced sets

I'm seeking an algorithm to split a list of items of varying sizes into "N" number of similarly-sized groups. Specifically, I'm working on an ASP.NET site in C# where I have a (database-retrieved) list of strings. The strings are of varying lengths. I have a set of columns which need to display the strings. I need an algorithm that will...