Enjoy an ad free experience by logging in. Not a member yet? Register.


Results 1 to 7 of 7
Thread: Maximise function in PHP

09212009, 05:48 PM #1
 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
09212009, 05:59 PM
#2
umm..
this maybe?
PHP Code:
function Integer($integer) {
return $integer;
}
print Integer(5)  Integer(3);
//prints 2
09212009, 07:21 PM
#3
 Join Date
 Feb 2008
 Posts
 74
 Thanks
 5
 Thanked 0 Times in 0 Posts
how would i use that?
09212009, 08:12 PM
#4
 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 builtin function, AFAIK. Here's a page that may help you get started building your own.
Are you a Help Vampire?
09212009, 08:29 PM
#5
 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.
09222009, 05:13 PM
#6
 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*(xC))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)(xC)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?
09222009, 11:42 PM
#7
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