math

Math equations on the web

What is the best way for me to render math equations on the web? I am familiar with LaTeX's math mode. ...

Compute numerical values from a space separated text file, within a range of lines

I have a file with the following values: for 3 threads: Average time taken for API1 is: 19097.7 nanoseconds. Average time taken for API2 is: 19173.1 nanoseconds. Average time taken for API2 is: 19777.7 nanoseconds. Average time taken for API2 is: 19243.1 nanoseconds. Average time taken for API1 is: 19737.7 nanoseconds. Average time take...

We know log_add, but how to do log_subtract?

Multiplying two numbers in log space means adding them: log_multiply(x, y) = log( exp(x) * exp(y) ) = x + y Adding two numbers in log space means you do a special log-add operation: log_add(x, y) = log( exp(x) + exp(y) ) which is implemented in the following code, in a way that doesn't require us to take the two ...

IEEE floating point representation issue

Suppose a hypothetical 6-bit floating point representation, with the fraction occupying 2 bits, and the exponent occupying 3 bits. What is the biggest (except for ) number this 6-bit floating point representation can support? I read this from the book "Computer System: A programmer's perspective" on page P71. I guess this to be 28, but ...

Reverse that Math function

Hello, I need to reverse a function with hard Math operations, I'm asking here to check if it's even possible, eventually for help. public static UInt32 Func_4(UInt32 P, UInt32 X, UInt32 G) { UInt64 result = 1; UInt64 mult = G; if (X == 0) return 1; while (X != 0) { ...

How do I implement a Bézier curve in C++?

I'd like to implement a Bézier curve. I've done this in C# before, but I'm totally unfamiliar with the C++ libraries. How should I go about creating a quadratic curve? void printQuadCurve(float delta, Vector2f p0, Vector2f p1, Vector2f p2); Clearly we'd need to use linear interpolation, but does this exist in the standard math library...

Fast Fourier Transform using a Vandermonde Matrix - Evaluation of Co-efficients?

Say i'm trying to evaluate the Polynomial: x^2 + 1 Using the Fast Fourier transform method for evaluating co-efficients. Now i can change this into matrix/vector form using the co-effcient as inputs for the fast fourier transform: so: x^2 + 1 = <1, 0, 1, 0> This is done by using the coefficient value e.g 1 = 1, 0x^1 = 0, X^2 = 1 a...

Rotate a point by an angle

I want to know how to work out the new co-ordinates for a point when rotated by an angle relative to another point. I have a block arrow and want to rotate it by an angle theta relative to a point in the middle of the base of the arrow. This is required to allow me to draw a polygon between 2 onscreen controls. I can't use and rotate a...

Is a kd-tree suitable for 4D space-time data (x,y,z,time)?

I want to use a data structure for sorting space-time data (x,y,z,time). Currently a processing algorithm searches a set of 4D (x,y,z,time) points, given a spherical (3d) spacial radius and a linear (1d) time radius, marking for each point, which other points are within those radii. The reason is that after processing, I can ask any 4D ...

How can I calculate pi (π) in VB

Does any one how can I calculate pi (π) in VB?? example: how can I calculate 2π in VB?? ...

Statistical estimation algorithm

I'm not sure if this question is appropriate for Stack Overflow but I'll give it a try anyway. I have some data as follows: I also have another set of data that I believe follows a similar distribution but I only know the total percent (e.g. 30% rather than 17%.) Can anyone suggest an algorithm to estimate the %s for each individual t...

round number to nearest 0.2 with PHP

I'm creating this rating system using 5-edged stars. And I want the heading to include the average rating. So I've created stars showing 1/5ths. Using "1.2" I'll get a full star and one point on the next star and so on... But I haven't found a good way to round up to the closest .2... I figured I could multiply by 10, then round of, and...

What's the best way to write Mathematical Equations on the Web?

I am working on a Math related web page and am looking for a solution to writing Mathematical equations easily onto a web page. There are several solutions readily available to me at the moment: Use LaTeX and publish them on my web page as images. Use MathML Both of these solutions aren't ideal and seem somewhat dated. Replacing what...

Partial, or wrapped multiplication - can anyone identify this function ?

I am hoping for insight into what looks like a partial multiplication. #define LOW(x) ((x)&0xffffffff) #define HIGH(x) ((x)>>32) unsigned long long NotMultiply(unsigned long long x, unsigned long long y) { return HIGH(x)*HIGH(y) + LOW(x)*LOW(y); } This function is iterated multiple times, as follows: unsigned long long DoBusy...

how to get numbers to have precision of .05 ?

The following will ensure that any large numbers will only be precise to the hundredths place (related to this answer): public function round( sc:Number ):Number { sc = sc * 100; sc = Math.floor( sc ); sc = sc / 100; return sc; } What is the optimal way to round my numbers to the precision of .05? Is there something ...

Masters: Math-based or Engineering-based gruaduate school more useful for web-focussed developer?

Hi all, This is in follow-up to a previous question: http://stackoverflow.com/questions/189321/whats-important-for-a-computer-science-masters-program-application I've been lucky in that I've been admitted to two programs I really like, but now I'm stuck in deciding between them as I don't know what's better for me in the long-term. I'...

Moving particles in C

I want to be able to move a particle in a straight line within a 3D environment but I can't think how to work out the next location based on two points within a 3D space? I have created a struct which represents a particle which has a location and a next location? Would this be suitable to work out the next location to move too? I know ...

Getting a specific digit from a ratio expansion in any base (nth digit of x/y)

Is there an algorithm that can calculate the digits of a repeating-decimal ratio without starting at the beginning? I'm looking for a solution that doesn't use arbitrarily sized integers, since this should work for cases where the decimal expansion may be arbitrarily long. For example, 33/59 expands to a repeating decimal with 58 dig...

How do I access math constants (eg. M_PI) in Visual C++ 2008?

I want to use the math constants, such as M_PI and M_E, in Visual C++ 2008. I assumed they were defined in the cmath header. ...

Should I use an expression parser in my Math game?

I'm writing some children's Math Education software for a class. I'm going to try and present problems to students of varying skill level with randomly generated math problems of different types in fun ways. One of the frustrations of using computer based math software is its rigidity. If anyone has taken an online Math class, you'll ...