Jump to content

Math in PHP??


jeremic

Recommended Posts

Yes I have but what I'm trying to find out if a function can be created to raise arbitrary variables such as X and Y to powers as stated above. I know that you can raise a number to a power but can you raise a letter? and get a letter as an out put??

(x + y)^3 = x^3 + 3x^2y + 3xy^2 + y^3
Link to comment
Share on other sites

NO you can't "raise a [b]letter[/b]".  But a raise a [b]variable[/b]--YES.

$x = 2;
$y = 4;

$a = $y + $x;  //$a will equal 6
$a = $y * $x;  //$a will equal 8

$a = pow($x, 2); //$a will equal 4  ->  (2 squared)
$a = pow($y, -2); //$a will equal 2 -> (square root of 4)
Link to comment
Share on other sites

Basially, he wants a function that can do his Algebra homework.

He's not asking us to do any calcuating that will output a numeric value - just factoring Algebric expression.

Like, inputting "(x-y)^2" in the textbox will output "x^2 -xy -xy + y^2" or "x^2 -2xy + y^2" (simpfiled).

Inputting "(x + y)^3" will output "x^3 + 3x^2y + 3xy^2 + y^3"

If that's the case, seems complicated...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.