Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Maximise function in PHP

    Hi

    In my script i am trying to maximise a function, is it possible to do this with php? can you differentiate a function using php is what i am essentially asking?

    Thanks

  • #2
    Regular Coder funnymoney's Avatar
    Join Date
    Aug 2007
    Posts
    364
    Thanks
    17
    Thanked 24 Times in 24 Posts
    umm..

    this maybe?

    PHP Code:
    function Integer($integer) {
     return 
    $integer;
    }

    print 
    Integer(5) - Integer(3);
    //prints 2 

  • #3
    New Coder
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts
    how would i use that?

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    I think funnymoney has confused elementary subtraction with calculus.

    Short answer: yes, you can do differentiation and loads more in PHP. There's not a built-in function, AFAIK. Here's a page that may help you get started building your own.
    Are you a Help Vampire?

  • #5
    New Coder
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thanks, i've worked it out thouigh, becuase it is just a quadratic i can just imput the a b and c values directly into a difernetiated version of the equation.

  • #6
    New Coder
    Join Date
    Feb 2008
    Posts
    74
    Thanks
    5
    Thanked 0 Times in 0 Posts
    ok so thought this was solved but just realised this solution won't work, as i am forming the equation from two simultaneous equations:
    u=S*(1+((x/P)-1)*-E)
    m=(u*(x-C))-F

    S, P, E, C and F are provided by the user hence i can use the following equation

    m=S*(1+((x/P)-1)*-E)(x-C)-F

    I want to find the maximum value for M given all the variables in the equation above are given apart from x

    this with those values should simplify to a quadratic which you could find a derivative for and optimize.

    Does anyone know how to do this with php?

  • #7
    Regular Coder funnymoney's Avatar
    Join Date
    Aug 2007
    Posts
    364
    Thanks
    17
    Thanked 24 Times in 24 Posts
    i forgot how to handle those kind of math issues. was long time ago. i have a book near here i can look into, but i really don't want to remove the dust from the covering.

    if you can remind me how to find maximum in a function. i remeber it had something to do with derivations... dunno how you call it. later i learned about integrals, also dunno how you say it right, but i'm pretty sure they were used to calculate surface under some curve or function something thingy...

    maybe you can even write it on paper and then post it here to "program" the function


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •