math

Explain the quantile() function in R

I've been mystified by the R quantile function all day. I have an intuitive notion of how quantiles work, and an M.S. in stats, but boy oh boy, the documentation for it is confusing to me. From the docs: Q[i](p) = (1 - gamma) x[j] + gamma x[j+1], I'm with it so far. For a type i quantile, it's an interpolation between x[j]...

programmatically find number of hosts in a Netmask

How do you programmatically find the number of hosts that a netmask supports. Eg, If you have a /30 , how do you find how many IP's are in it without using a lookup table? Preferably would be able to work with the "/" notation, rather than 255.xxx.xxx.xxx notation. ...

Point-Triangle Collision Detection in 3D

How do I correct for floating point error in the following physical simulation: Original point (x, y, z), Desired point (x', y', z') after forces are applied. Two triangles (A, B, C) and (B, C, D), who share edge BC I am using this method for collision detection: For each Triangle If the original point is in front of the current...

Book(s) on the algorithims needed for calculating trancendental functions?

For example, how are exponential, logarithm, and trigonometric functions done within the chip on a hand-held calculator? Where is a good starting place to learn about this? EDIT: specifically, how could I recreate these functions in software? With the purpose of understanding both the mathematics and the trade-offs in time and complexi...

The most efficient way to implement an integer based power function pow(int, int)

What is the most efficient way given to raise an integer to the power of another integer in C? // 2^3 pow(2,3) == 8 // 5^5 pow(5,5) == 3125 ...

Why Am I Getting Link Errors When Calling Function in Math.h?

When attempting to call functions in math.h, I'm getting link errors like the following undefined reference to sqrt But I'm doing a #include <math.h> I'm using gcc and compiling as follows: gcc -Wall -D_GNU_SOURCE blah.c -o blah Why can't the linker find the definition for sqrt? ...

Pascal's Theorem for non-unique sets?

Pascal's rule on counting the subset's of a set works great, when the set contains unique entities. Is there a modification to this rule for when the set contains duplicate items? For instance, when I try to find the count of the combinations of the letters A,B,C,D, it's easy to see that it's 1 + 4 + 6 + 4 + 1 (from Pascal's Triangle) ...

How much mathematics and physics should a programmer know?

I am currently learning mathematics and physics along with programming. Some of it is definitely useful for my programming related projects, especially the (hobby) games that I make, but not all. What are the most important topics which are necessary for a programmer? ...

Point Sequence Interpolation

Given an arbitrary sequence of points in space, how would you produce a smooth continuous interpolation between them? 2D and 3D solutions are welcome. Solutions that produce a list of points at arbitrary granularity and solutions that produce control points for bezier curves are also appreciated. Also, it would be cool to see an itera...

How helpful is knowing lambda calculus?

To all the people who know lambda calculus: What benefit has it bought you, regarding programming? Would you recommend that people learn it? ...

Smart design of a math parser?

What is the smartest way to design a math parser? what i mean is a function that takes a math string (like: "2 + 3 / 2 + (2 * 5)") and returns the calculated value? I did write one in VB6 ages ago but it ended up being way to bloated and not very portable (or smart for that matter...). General ideas, psuedo code or real code is appreciat...

Algorithm to detect intersection of two rectangles?

I'm looking for an algorithm to detect if two rectangles intersect (one at an arbitrary angle, the other with only vertical/horizontal lines). Testing if a corner of one is in the other ALMOST works. It fails if the rectangles form a cross-like shape. It seems like a good idea to avoid using slopes of the lines, which would require sp...

Online tool for generating mathematical equation image files

I'm looking for an online tool that will let me create a gif or png like this one: Some kind of LaTex online service, with friendly examples? ...

How do I get a decimal value when using the division operator in Python?

For example, the standard division symbol '/' rounds to zero: >>> 4 / 100 0 However, I want it to return 0.04. What do I use? ...

Where is a good place to brush up on some math?

Math skills are becoming more and more essential, I'm wonder where is a good place to brush up on some basics before moving on to some more CompSci specific stuff? A sight with lots of video's as well as practise exercises would be a double win but I cant seem to find one. ...

Are the values of pi and e available in the .Net framework?

Without calculating them, I mean? ...

Where can I learn about logarithms?

I hear logarithms mentioned quite a lot in the programming context. They seem to be the solution to many problems and yet I can't seem to find a real-world way of making use of them. I've read the Wikipedia entry and that, quite frankly, leaves me none the wiser. So, where can I learn about the real-world programming problems that logar...

How to check my byte flag?

I use a byte to store some flag like : 10101010 and I would like to know how to verify that a specific bit is at 1 or 0. ...

Code or formula for intersection of two parabolas in any rotation

I am working on a geometry problem that requires finding the intersection of two parabolic arcs in any rotation. I was able to intesect a line and a parabolic arc by rotating the plane to align the arc with an axis, but two parabolas cannot both align with an axis. I am working on deriving the formulas, but I would like to know if ther...

Decoding letters ('a' .. 'z') from a bit sequence without waste

I seek an algorithm that will let me represent an incoming sequence of bits as letters ('a' .. 'z' ), in a minimal matter such that the stream of bits can be regenerated from the letters, without ever holding the entire sequence in memory. That is, given an external bit source (each read returns a practically random bit), and user input...