Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2006-12-09 07:22:04

Stas B.
Guest

Somebody Please Help Me!!!

I need have to finish a programming task quick but I got stuck with the math again... sad
This thing is killing me...
s = (sqrt(g) * x) / (sqrt(2 * (x * tan(a) - y)) * cos(a))
How do I use that to write a formula to calculate the minimal value of 's' given 'x' and 'y'?
Please help!!!

#2 2006-12-09 07:25:25

Stas B.
Guest

Re: Somebody Please Help Me!!!

Almost forgot:
g >= 0, a != 90, a > arctan(y / x)

#3 2006-12-09 08:36:15

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: Somebody Please Help Me!!!

Are you trying to write an algorithm to calculate this?

The proper way:

You could use multivariable calculus to find the derivative with respect to g and a, then find the solutions to the equation after setting it to 0 through a brute force algorithm, and then finally evaluating all these points to find the local minimums, then comparing these to find the absolute minimum.

This of course all assumes your function is continuous everywhere and doesn't do any "weird" things, such as have a large drop in value over short distances.

The CS way:

Every number on a computer is stored by a finite number of bits, and this includes decimals.  We (computer scientists) have asked engineers to make a finite sized chip with an infinite amount of transistors, but they have yet to do so.

The result of this is that there is a minimum discrete distance between any two decimal numbers.  In math speak, this means that there exists a d > 0, such that there is no other number a where 0 < a < d.  In plain english it just means that there is a smallest positive number.  Note that this is only true for computers

The result of this is that between any two real numbers, there is a finite amount of numbers which computers can represent.  There are of course ways around this, but this is the default way decimal numbers work on a computer.  This means that you can try "all" the decimal numbers in finite amount of time.  But remember that finite could be very long.

So simply set up a function called evaluate:

double result = evaluate(double a, double g, double x, double y);

Then just set up a for loop:

//x and y are already defined
double g,a;
double result;
double min_result = evaluate(a_min, g_min, x, y);

for (g = g_min; g <= g_max; g += SMALLEST_DOUBLE_VALUE) {
   for(a = a_min; a <= a_max; a += SMALLEST_DOUBLE_VALUE) {
     result = evaluate(a, g, x, y);
     if (result < min_result) {
       min_result = result;
       //you may save any min values you need here
     }
   }
}


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#4 2006-12-10 01:56:21

Stas B.
Guest

Re: Somebody Please Help Me!!!

Never mind.
I did some reading and solved it on my own.

#5 2006-12-10 04:17:16

Toast
Real Member
Registered: 2006-10-08
Posts: 1,321

Re: Somebody Please Help Me!!!

lol

Offline

#6 2006-12-10 06:14:39

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: Somebody Please Help Me!!!

I'm quite curious as to how.  Care to explain?


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

Board footer

Powered by FluxBB