I have a dynamic number of equally proportioned and sized rectangular objects that I want to optimally display on the screen. I can resize the objects but need to maintain proportion.
I know what the screen dimensions are.
How can I calculate the optimal number of rows and columns that I will need to divide the screen in to and what si...
I'm having trouble calculating roots of rather large numbers using bc_math, example:
- pow(2, 2) // 4, power correct
- pow(4, 0.5) // 2, square root correct
- bcpow(2, 2) // 4, power correct
- bcpow(4, 0.5) // 1, square root INCORRECT
Does anybody knows how I can circumvent this? gmp_pow() also doesn't work.
...
I'm working with graphing accelerometer data here, and I'm trying to correct for gravity. To do this, I get the acceleration vector in spherical coordinates, decrease the radius by 1g, and convert back to cartesian. This method is called on a timer every 0.03 seconds:
//poll accleration
ThreeAxisAcceleration current = self.accelerationD...
I'm writing a utility to calculate π to a million digits after the decimal. On a 32- or 64-bit consumer desktop system, what is the most efficient way to store and work with such a large number accurate to the millionth digit?
clarification: The language would be C.
...
My question has to do with the physical meaning of the results of doing the spectral analysis of a signal, or, put another way, of interpreting what comes out of throwing a signal into an FFT of a math package.
Specifically:
(i) take a signal, a time-varying voltage v(t)
(ii) throw it into an FFT -- you get back a sequence of re...
How to calculate obtuse angle between two vectors if both vectors and x axis is given.
First vector can be taken as x axis. we can get acute by dot product and acos.
...
Further to: http://stackoverflow.com/questions/326679/choosing-an-attractive-linear-scale-for-a-graphs-y-axis
And what to do when some of the points
are negative?
I believe this part of the question was not answered but it seems I can't comment or extend that question so I've created a new one
Values -100, 0, 100 with 5 ticks:
...
Is there any algorithm to compute the nth fibonacci number in sub linear time?
...
How to calculate the monthly fee on a loan?
Given is:
a: an amount to loan.
b: the loan period (number of months).
c: the interest rate p.a. (interests is calculated and added every month, 1/12 of the interest is added. So if the interest is on 12%, 1% interest is added every month).
d: the amount of money owed after the end of the pe...
I'm doing some trigonometry calculations in C/C++ and am running into problems with rounding errors. For example, on my Linux system:
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[]) {
printf("%e\n", sin(M_PI));
return 0;
}
This program gives the following output:
1.224647e-16
when the correct answer ...
I'd like something that converts a simple calculator like ascii math syntax to mathML.
I found this: http://www1.chapman.edu/~jipsen/mathml/asciimath.html
But I don't understand how to use it.. I'd like to make it work from the command line for example, so that I feed it some math formula and get back the mathMl version.
How could I do...
Ever since I needed to work with PI (3.1415...) in C# I have used Math.PI to get the value. Usually I would just use values like Math.PI/2.0 or 2.0*Math.PI, but now I have just noticed that XNA provides a MathHelper class. The nice thing about this is I can call MathHelper.PiOver2 and MathHelper.TwoPi, thus making an extremely trivial ...
Hi All,
I wrote some code that looks like this:
def get(x, y)
@cachedResults.set(x,y, Math.hypot(x, y)) if @cachedResults.get(x,y).nil?
@cachedResults.get(x,y)
end
Where @cachedResults contained a 2D Array class i wrote (in a few minutes) and the purpose of this function is to make sure that I never have to call Math.hypot twic...
I have a point at 0,0,0
I rotate the point 30 deg around the Y axis, then 30 deg around the X axis.
I then want to move the point 10 units forward.
I know how to work out the new X and Y position
MovementX = cos(angle) * MoveDistance;
MovementY = sin(angle) * MoveDistance;
But then I realised that these values will change because of ...
I'm currently working on replicating some of the functionality of Matlab's regionprops function in Octave. However, I have a bit of a hangup on a subset of the functionality. The 'Eccentricity', 'MajorAxisLength', 'MinorAxisLength' and 'Orientation' properties are my sticking point. In the documentation, they all derive from "...the e...
i have a mysql table for uk people that includes:
postcode beginning (i.e. BB2)
latitude (int)
longitude (int)
range (int, in miles, 1-20)
http://www.easypeasy.com/guides/article.php?article=64 - theres the article for the sql file i based my table on
now it says i can use Pythagoras theorem to calculate distances based on longitude...
I have two
double a, b;
I know that the following is true
-1 <= a/b <= 1
however b can be arbitrarily small. When I do this naively and just compute the value
a/b
the condition specified above does not hold in some cases and I get values like much greater than 1 in absolute value (like 13 or 14.)
How can I ensure that when ...
Can anyone suggest any mathematical or programming books that have helped you progress in your learning whilst completing the project Euler problems? Even some suggestions for study areas or appropriate websites would be much appreciated.
Background
So far I've done a fair few of the Project Euler problems (I'm close to level 3). For t...
Hi,
What is problem with follwoing code?
I am getting very strange results. Do I missing something?
proc Dot {vec1 vec2} {
set ret [expr ([lindex $vec1 0]*[lindex $vec2 0])+([lindex $vec1 1]*[lindex $vec2 1])+([lindex $vec1 2]*[lindex $vec2 2])]
}
proc FindInterSectPoint_LineAndPlane {normalVectorPlane basePoint refPoint topoint} {
fo...
I'm trying to reduce a high-dimension dataset to 2-D. However, I don't have access to the whole dataset upfront. So, I'd like to generate a function that takes an N-dimensional vector and returns a 2-dimensional vector, such that if I give it to vectors that are close in N-dimensional space, the results are close in 2-dimensional space...