IT Community - Software Programming, Web Development and Technical Support

Mathematical functions in PHP

This is a discussion on Mathematical functions in PHP within the PHP Programming forums, part of the Web Development category; The deg2rad() function converts a degree to its radian number. <?php echo deg2rad("30") . "<br /&...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #61 (permalink)  
Old 05-02-2008, 07:17 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 180
saravanan is on a distinguished road
Default Re: Mathematical functions in PHP

The deg2rad() function converts a degree to its radian number.

<?php
echo deg2rad("30") . "<br />";
echo deg2rad("10") . "<br />";
echo deg2rad("1587") . "<br />";
echo deg2rad("70");
?>

The output of the code above will be:

0.523598775598
0.174532925199
27.6983752292
1.2217304764
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #62 (permalink)  
Old 05-02-2008, 10:18 PM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,158
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Mathematical functions in PHP

Quote:
Originally Posted by senraj View Post
Hi,

In this example we will seed the random number generator:

PHP Code:
mt_srand(mktime());
echo(
mt_rand()); 
The output of the code above could be:

1132656473
Hi,
What is the exact difference between mt_srand() and rand()?
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #63 (permalink)  
Old 05-09-2008, 05:58 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 180
saravanan is on a distinguished road
Default Re: Mathematical functions in PHP

what is do mt_rand() function in php?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #64 (permalink)  
Old 05-09-2008, 06:01 AM
jegan jegan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 160
jegan is on a distinguished road
Default Re: Mathematical functions in PHP

The mt_rand() function returns a random integer using the Mersenne Twister algorithm.

If this function is called without parameters, it returns a pseudo-random value between 0 and RAND_MAX.

If you want a random number between 10 and 100 (inclusive), use mt_rand (10,100).


<?php
echo(mt_rand() . "<br />");
echo(mt_rand() . "<br />");
echo(mt_rand(10,100))
?>

The output of the code above could be:

1150905288
613289478
21
__________________
Thanks & Regards,
Jegan CBK
"We will either find a way, or make one!”
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #65 (permalink)  
Old 05-09-2008, 06:03 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 180
saravanan is on a distinguished road
Default Re: Mathematical functions in PHP

what is tanh function in php?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #66 (permalink)  
Old 05-09-2008, 06:05 AM
jegan jegan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 160
jegan is on a distinguished road
Default Re: Mathematical functions in PHP

The tanh() function returns the hyperbolic tangent of an angle (equivalent to sinh(x) / cosh(x)).



<?php
echo(tanh(M_PI_4) . "<br />");
echo(tanh(0.50) . "<br />");
echo(tanh(-0.50) . "<br />");
echo(tanh(5) . "<br />");
echo(tanh(10) . "<br />");
echo(tanh(-5) . "<br />");
echo(tanh(-10))
?>

The output of the code above will be:

0.655794202633
0.46211715726
-0.46211715726
0.999909204263
0.999999995878
-0.999909204263
-0.999999995878
__________________
Thanks & Regards,
Jegan CBK
"We will either find a way, or make one!”
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #67 (permalink)  
Old 05-09-2008, 06:08 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 180
saravanan is on a distinguished road
Default Re: Mathematical functions in PHP

what is log1p() function in php?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #68 (permalink)  
Old 05-09-2008, 06:10 AM
jegan jegan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 160
jegan is on a distinguished road
Default Re: Mathematical functions in PHP

The log1p() function returns log(1+x), computed in a way that is accurate even when the value of x is close to zero.
__________________
Thanks & Regards,
Jegan CBK
"We will either find a way, or make one!”
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #69 (permalink)  
Old 05-29-2008, 02:27 AM
naina naina is offline
D-Web Trainee
 
Join Date: May 2008
Posts: 8
naina is on a distinguished road
Default Re: Mathematical functions in PHP

first of all thanks tell about lodp() function . please give the example of log1p() function.
__________________
Web Templetes
Web site Design
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #70 (permalink)  
Old 06-17-2008, 03:25 AM
Falcon Falcon is offline
D-Web Analyst
 
Join Date: Nov 2007
Location: Chennai
Posts: 288
Falcon is on a distinguished road
Default Re: Mathematical functions in PHP

Hi Buddies

Thanks for all of your post. i have learn a lot in Mathematical functions in PHP

Thanks
Falcon

Last edited by Falcon : 07-02-2008 at 12:48 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #71 (permalink)  
Old 07-02-2008, 12:21 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,158
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Mathematical functions in PHP

The math functions can handle values within the range of integer and float types. I hope without these functions, we can't do the calculation
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #72 (permalink)  
Old 07-02-2008, 12:41 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,158
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Mathematical functions in PHP

I wondered if the switch condition would overall be less efficient if there were a large number of switch statements within a script, instead of a single switch construct with many cases.
The thinking was that the switch condition was possibly more expensive to setup than an if-else. However, in this case, many switch statements still performed faster (around 25% more) than when using many if-else or if,if conditionals instead.
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COM functions in php Kamalakannan PHP Programming 24 07-12-2008 03:20 AM
PHP FTP Functions Kamalakannan PHP Programming 54 04-14-2008 04:42 AM
erroneous results for certain mathematical calculations aramesh Flash Actionscript Programming 1 04-03-2008 02:00 AM
Sql functions itbarota Database Support 11 02-29-2008 01:08 AM
What are Virtual Functions? How to implement virtual functions in "C"? Sabari C and C++ Programming 4 09-10-2007 10:35 PM


All times are GMT -7. The time now is 11:53 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0