Mathematical Limits in PHP

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
TheCandyMan
Forum Newbie
Posts: 1
Joined: Mon Apr 04, 2011 4:03 pm

Mathematical Limits in PHP

Post by TheCandyMan »

How would one go about doing this?

How would you handle limits that approach infinity?
e.g. The limit as x goes to 0 of (1/x)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Mathematical Limits in PHP

Post by Christopher »

Not sure exactly what your question is? Obviously you cannot divide by zero so you need to put an if() around the calculation and give an appropriate value if the denominator is zero. You can use the math functions to increase the precision, if that is what you need:

http://us.php.net/manual/en/refs.math.php
(#10850)
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Mathematical Limits in PHP

Post by kaisellgren »

If you need to check whether a value is finite, use this http://www.php.net/manual/en/function.is-finite.php
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Mathematical Limits in PHP

Post by Weirdan »

Computer Algebra Systems (CAS) (and it seems what original poster was asking about) are usually outside what people do in PHP... so your best bet is to find an application that can do what you want and invoke it via shell_exec() and friends.
Post Reply