math

Need a formula: Extracting Years from Seconds Since January 1, 0001 12:00 AM

Input: # of seconds since January 1st, of Year 0001 Output: # of Full years during this time period I have developed an algorithm that I do not think is the optimal solution. I think there should be a solution that does not involve a loop. See Code Block 1 for the algorithm which A) Determines the quantity of days and B) Iteratively su...

Java: calculating area of a triangle

import java.lang.Math; import java.awt.* public class Triangle implements Shape { java.awt.Point a; java.awt.Point b; java.awt.Point c; public Triangle(java.awt.Point a, java.awt.Point b, java.awt.Point c) { this.a = a; this.b = b; this.c = c; } public double getArea( ) { do...

Choose a language to write technical engineering maths (can I use Java?)

I have to write a prototype app for an engineering company. Most of the work is calculating various engineering properties (I'm talking pipes and real things here, not software engineering). However, there will also have to be a GUI for: parameter entry displaying results some basic diagramming The calculation work at the moment does...

PROJECT EULER #29

Well, after solving this problem by naive STL set,I was reading the forum entries,there I find this entry : #include <iostream> #include <cmath> #define MAX 100 using namespace std; int main(){ int res=(MAX-1)*(MAX-1); for(int i=2;i<MAX;i++) for(int j=i*i;j<=MAX;j=j*i) res = res-int(MAX*(log(i)/log(...

Formally verifying the correctness of an algorithm

First of all, is this only possible on algorithms which have no side effects? Secondly, where could I learn about this process, any good books, articles, etc? ...

Finding Signed Angle Between Vectors

How would you find the signed angle theta from vector a to b? And yes, I know that theta = arccos((a.b)/(|a||b|)). However, this does not contain a sign (i.e. it doesn't distinguish between a clockwise or counterclockwise rotation). I need something that can tell me the minimum angle to rotate from a to b. A positive sign indicates a ...

Efficiently calculating all pythagorean triples knowing the hypoteneuse

Given a hypoteneuse (c in the typical equation a*a + b*b = c*c), what is an efficient way to calculate all possible integer values of a and b, such that a < b? Note: I've seen c be greater than 1e12, thus c*c is greater than long.MaxValue, from what I can tell, c*c does fit into a decimal, though. ...

Determining if a spherical triangle is obtuse

Given two points, A and B, defined by longitude and latitude I want to determine if another point C is ~between~ A and B. ~between~ is hard for me to define. I don't mean on the line - it almost certainly won't be. In this diagram, point C is ~between~ A and B because it is between the normals of points A and B and the line between th...

Computing different terms for a given pair of exponentiation having the same result

To understand the problem,let us consider these examples first:                                  46 = (22)6 = 212 = (23)4 = 84 = 163 = 4096. Thus,we can say that 46,212,84 and 163 are same.                                  273 = 39 = 19683 so, both 273 and 39 are identical. Now the problem is, for any given pair of ab how to comput...

multiplying polynomials in GF(2)

i want to multiply 2 polynomials in gf(2) in c#. please help. ...

Java library for simple numerical approximation

I need a Java library for numerical approximation. Nothing too complex. Just something that solves the following problem for example: epsilon = f(x) + y + z; find x such that epsilon gets close to zero. EDIT: f(x) is an arbitrarily complex function. It should accept parameters such as tolerance, etc. Aside from rolling it myself, j...

What statistics concepts are useful for profiling?

I've been meaning to do a little bit of brushing up on my knowledge of statistics. One area where it seems like statistics would be helpful is in profiling code. I say this because it seems like profiling almost always involves me trying to pull some information from a large amount of data. Are there any subjects in statistics that I ...

Java dependency

Hi All, I am looking for a small package in java that can extract all the class hierarchy and dependencies. I think I have to dig AST for this purpose but I am looking for a package that i can use for my application. ( don't want to re-invent the wheel ) Thanks ! ...

Representing code algebraically

Dear all; I have a number of small algorithms that I would like to write up in a paper. They are relatively short, and concise. However, instead of writing them in pseudo-code (à la Cormen or even Knuth), I would like to write an algebraic representation of them (more linear and better LaTeX rendering) . However, I cannot find resources...

PHP Maths Logic

I am trying to set a variable based on some maths logic (to wrap specific html around elements). I worked half the problem, to hit 0, 3, 6, 9, 12 if(($i % 3) == 0) { // blah } Now I need to hit the following numbers, 2, 5, 8, 11, 14, etc What possible maths operation could I do to hit this sequence? ...

What does Simpson's paradox imply in AB testing?

I am doing A/B testing and I am facing Simpson's paradox in my results (day vs month vs total duration of the test). Does it mean that my a/b testing is not correct/representative? (Some external factor impacted the testing?) If it is a sign of problem, what are the directions to follow? Thanks for your great help. Further reading: ...

Constraining the drawing of a line to 45 degree angles

I have the start point (x1,y1) and the desired length and angle of the line. If the angles were directions, 0 degrees is W, 90 is N, 180 is E and 270 is S. I can modify this if needed. How can I use the start point, length and angle to determine the end point(x2, y2)? ...

K-Dop collision between different K and Volumes

And now after some work, I finally understand how the KDop bounding volume are created and how the collisions are intersected and I maked a working implementation of them. Now the problem is another. :D How can I intersect (it has to be possible, or it would not make any sense) 2 K-Dop of different K values? (obviously we know beforehan...

java jama array problem

Hi All, I asked a question before but duffymo said it is not clear so i am going to post it again here. I am using Jama api for SVD calculation. I know very well about jama and SVD. Jama does not work if your column are more than rows. I have this situation. What should I do?? any help? I can't transpose the matrix too as it can produc...

Where to find algorithms for standard math functions?

I'm looking to submit a patch to the D programming language standard library that will allow much of std.math to be evaluated at compile time using the compile-time function evaluation facilities of the language. Compile-time function evaluation has several limitations, the most important ones being: You can't use assembly language. Y...