Jump to content

How do you solve this with php??


Vivid Lust

Recommended Posts

Can you explain how this works ???

 

I could, but you'll learn more by looking at my response and my code.

 

And this would be able to find out what a and b is as unknowns?

If BOTH a and b are unknown, there is an infinite number of solutions (try my code with a larger loop).

 

If a or b is known, calcluating the other is a simple matter of, er calculating it. See my code for how.

Link to comment
Share on other sites

Like AndyB said, if you know one of the variables, it's pretty straightforward.

 

a^2+2b=0 where b = -2

 

a^2 = -2b

a^2 = -(-2b)

a^2 = 2(2)

a^2 = 4

a = sqrt(4)

a = 2

 

And if you don't:

 

a^2 = -2b

 

That's about as far as you can get.... lol

 

If you wanted to you could even graph this to see the infinite solutions....

 

x = (a^2)/-2

or

y = sqrt(-2b)

 

 

Or you could think of it like, for every expression a^2 + 2b = 0, what ever a is chosen to be, 2b has to cancel it out....

 

Example:

 

/*
please note:
Due to the precision of math in PHP (well in computer langs in general), some of these answers may be wrong by a little bit
*/

for($a = -100; $a < 100; $a++) {
$a2 = $a*$a;
$b = -$a2/2;
$e = $a2 + 2*$b;
echo "a = {$a}, b = {$b}, a^2 + 2b = {$e}\r\n";
echo "\t{$a}^2 + 2({$b}) = {$e}\r\n";
echo "\t\t" . ($a * $a) . ' + ' . (2*$b) . ' = ' . $e . "\r\n";
}

 

This does basically the same thing as AndyB's code, except it works it a little differently.  This would be the handwritten equivalent of:

 

a^2 + 2b = 0

*pretend a is 4*

4^2 + 2b = 0

16 + 2b = 0

16 = -2b

b = -8

 

It's basically just c + d = 0 where c = a^2 and d = 2b, so once you have a, you can know that since c = a^2 and c + d = 0, then d = -(a^2).....  Since d = 2b, you would have to throw the 2 back into the solution for d and make it d = (-(a^2))/2.

 

This would make b always negative, since a^2 will always be positive, and to get to 0 from a positive you would need a negative.  (That assumes real numbers, and it assumes a <> 0.)

 

 

Anyway, I've just repeated what AndyB said.... But it was a little different ;p.

 

 

 

Sample output:

a = 28, b = -392, a^2 + 2b = 0
        28^2 + 2(-392) = 0
                784 + -784 = 0
a = 29, b = -420.5, a^2 + 2b = 0
        29^2 + 2(-420.5) = 0
                841 + -841 = 0
a = 30, b = -450, a^2 + 2b = 0
        30^2 + 2(-450) = 0
                900 + -900 = 0
a = 31, b = -480.5, a^2 + 2b = 0
        31^2 + 2(-480.5) = 0
                961 + -961 = 0
a = 32, b = -512, a^2 + 2b = 0
        32^2 + 2(-512) = 0
                1024 + -1024 = 0
a = 33, b = -544.5, a^2 + 2b = 0
        33^2 + 2(-544.5) = 0
                1089 + -1089 = 0
a = 34, b = -578, a^2 + 2b = 0
        34^2 + 2(-578) = 0
                1156 + -1156 = 0
a = 35, b = -612.5, a^2 + 2b = 0
        35^2 + 2(-612.5) = 0
                1225 + -1225 = 0
a = 36, b = -648, a^2 + 2b = 0
        36^2 + 2(-648) = 0
                1296 + -1296 = 0

Link to comment
Share on other sites

How would you solve:

 

a² + 2b = 0

 

Thanks

 

well lets say A is an aribtary constant dependent on b so

a = sqrt(-2b)

so we can factor out that negative part and say

a = i*sqrt(2b)

 

and then a is any value b can have which is any number real or imaginary if you don't' define it so that is the best you gonna get, however php can't work on an imaginary range without  modifications

Link to comment
Share on other sites

Hey....  This is kinda a nooby question, but i would be the square root of -1 there right?

 

sqrt(-2b) is the same as sqrt(-1*2b)..... and I know that with... hmmm sqrt(32) for example, you could make that sqrt(16*2).  Then, you could make it sqrt(16)*sqrt(2).  (That would be 4sqrt(2).)

 

Anyway, it would work the same way right?  Just i would be an imaginary number?

 

Algebra II woot woot!

 

(Hmm now that I think about it, I bet we learn that later in class.)

 

Now to go Google....

Link to comment
Share on other sites

i is defined a lot of ways, most commonly the sqrt of -1, but in a better sense

e^ix = cos( x ) + i sin( x )  as euler found out, which turns out to be a great help when solving auxliary equations that net complex results.  for m that is when you use the substitution of

y = e^mx

y' = m*e^mx

y'' = m^2*e^mx

etc.

 

Link to comment
Share on other sites

It's weird because complex multiplication acts quite differently from real multiplication.  And because the square root is the number (or numbers) such that multiplying it with itself gives x, the behaviour of square root depends on the behaviour of multiplication.

 

And the weirdness of complex multiplication comes from i*i=-1.  That means that a number on the imaginary axis multiplied by another number on the imaginary axis takes you to the negative real axis.  And that IS weird.

Link to comment
Share on other sites

Can you provide some evidence to back up that claim that complex mathematics models strictly more than cartesian mathematics?

 

I'm not going to let you define additional operations other than the native multiplication and so on, because if that is allowed, both systems become equivalent.  Put another way, both have the same domain but have different native operations.  That is why they model different problems.

Link to comment
Share on other sites

I was talking about a 2 dimensional plane using either cartesian mathematics or complex mathematics.  Or put another way, the choice of a single complex number or a vector of 2 real numbers.

 

What you're talking about appears to be vectors of complex numbers vs vectors of real numbers.

 

I get your point that vectors of complex numbers can express more than a vector of real numbers of the same size.  What I claim is that a single complex number cannot model the same things that a vector of 2 real numbers can model, using the standard operations.

Link to comment
Share on other sites

well you are trying to disprove something with some real strange logic

 

Take a vector call it -> V

it consist of the following components

Capital letters represent the directions i,j,k

v = 3I - 2iI +1J +2iJ +k +iK

 

now if we look at that same vector only in the real plane it is only defined as

 

v = 3I +1J  +k

 

if you are saying that is wrong then your wrong its that simple the imaginary plane exist its isn't really imaginary its just a name sorta like anti-bonding orbits, quarks, anti-matter black holes anything else in that sorta aspect.  You can't visually see it, but its affects are  there.

Link to comment
Share on other sites

Dude, I'm not trying to disprove anything :)  I am talking about something different to what you are talking about.  Both of us are correct.  End of story.

 

How you interpreted what I said was not the way I meant it.

 

Do you get what I was saying?  Imagine a 2-dimensional plane.  You can view a 2 dimensional plane as a 2-vector with corresponding operations, or as a single complex value with corresponding operations.  The corresponding operations are different in each case.

 

That's a different thing from what you are talking about.  You are talking about a 2-vector of reals vs a 2-vector of complex values, which gives 4 dimensions in total.

 

We are talking about different things.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.