ASP common mathematical Functions Abs Atn Cos etc detailed details

Source: Internet
Author: User
Tags abs expression functions natural logarithm numeric value sin square root valid


Name



Abs



Category



Mathematical functions



Prototype



Abs (number)



Parameters



Must be selected. The number argument is a valid numeric expression of any type



"Return value"



Type of same number



"Exception/Error"



No



Description



Returns the absolute value of the parameter number. The absolute value of a number is to remove the positive sign from the future. For example, ABS (-1) and ABS (1) both return 1. Abs (5.2) =5.2,abs (-5) =5



Example



Dim MyNumber



MyNumber = Abs (50.3) ' returns 50.3.



MyNumber = Abs (-50.3) ' returns 50.3.



Notes



Returns NULL if number contains NULL, or 0 if number is an uninitialized variable.



Name



Atn



Category



Mathematical functions



Prototype



ATN (number)



Parameters



Required, the number argument is a double or any valid numeric expression.



"Return value"



Double type



"Exception/Error"



No



Description



Returns the tangent value of the parameter number.



Example



Dim Pi



PI = 4 * ATN (1) ' Calculates pi.



Notes



The ATN function's parameter value (number) is the ratio of the sides of the right-angled triangle and returns the angle in radians. This ratio is the angle of the side length divided by the angle of the adjacent side length of the quotient. The range of values is between-PI/2 and PI/2 radians. To convert the angle to radians, multiply the angle by pi/180. To convert radians to angles, multiply radians by 180/pi.



Note: Atn is the inverse trigonometric functions of tan, and the value of tan is the angle, which returns the ratio of two sides of the right-angled triangle. Instead of confusing the Atn with the cotangent function, the cotangent function value is the reciprocal of the tangent value, cotangent = (1/tangent).



Name



Cos



Category



Mathematical functions



Prototype



Cos (number)



Parameters



Required, the number argument is Double or any valid numeric expression that represents an angle in radians.



"Return value"



Double type



"Exception/Error"



No



Description



Returns the cosine of a specified angle.



Example



Dim MyAngle, Mysecant



MyAngle = 1.3 ' defines the angle (in radians).



Mysecant = 1/cos (myangle) ' uses cosine to compute secant (sec ()).



Notes



The Cos function's argument is a corner and returns the ratio on both sides of the right-angled triangle. The ratio is the angle of the adjacent side length divided by the length of the hypotenuse. The values of the results range from 1 to 1.



To convert the angle to radians, multiply the angle by pi/180. To convert radians to angles, multiply radians by 180/pi.



Name



Exp



Category



Mathematical functions



Prototype



EXP (number)



Parameters



Required, the number argument is a Double or any valid numeric expression



"Return value"



Double type



"Exception/Error"



No



Description



Returns a specified E (the bottom of the natural logarithm, the value of E is 2.71828).



Example



' This example uses the EXP function to compute one of the sides of E.



Dim MyAngle, Myhsin



' Defines the angle (in radians).



MyAngle = 1.3



' Computes the hyperbolic sine function value (sin ()).



Myhsin = (exp (myangle)-exp ( -1 * myangle))/2



Notes



If the value of number is more than 709.782712893, it can cause an error to occur. The value of constant e is about 2.718282. Note: The function of the EXP function is complementary to the function of Log, so it is sometimes called the objection number.



Name



Fix



Category



Mathematical functions



Prototype



Fix (number)



Parameters



Required, the number argument is a Double or any valid numeric expression



"Return value"



Integer type



"Exception/Error"



No



Description



Truncate the decimal part of number to find the integer part, for example: Fix (3.8) =3,fix (-3.8) =-3.



Example



Dim MyNumber



MyNumber = Fix (99.2) ' returns 99.



MyNumber = Fix (-99.8) ' returns-99.



MyNumber = Fix (-99.2) ' returns-99.



Notes



If number contains null, NULL is returned.



Name



Int



Category



Mathematical functions



Prototype



Int (number)



Parameters



Required, the number argument is a Double or any valid numeric expression



"Return value"



Integer type



"Exception/Error"



No



Description



The largest integer that is not greater than number, INT (3. 8) =3,int (-3.8) =-4.



Example



Dim MyNumber



MyNumber = Int (99.8) ' returns 99.



MyNumber = Int (-99.8) ' returns-100.



MyNumber = Int (-99.2) ' returns-100.



Notes



If number contains null, NULL is returned. Int and Fix will delete the decimal part of number and return the remaining integers. The difference between int and fix is that if number is negative, INT returns the first negative integer less than or equal to number, and fix returns the first negative integer greater than or equal to number. For example, Int converts-8.4 to 9, and Fix converts-8.4 to 8.



Name



Log



Category



Mathematical functions



Prototype



Log (number)



Parameters



Required, the number argument is a Double or any valid numeric expression greater than 0



"Return value"



Double type



"Exception/Error"



No



Description




Returns the natural pair value of the specified number parameter.



Example



This example uses the Log function to get a natural numeric value for a number.



Dim MyAngle, MyLog



' Defines the angle (in radians).



MyAngle = 1.3



' Computes the inverse hyperbolic sine function value (inverse sinh ()).



MyLog = Log (MyAngle + SQR (MyAngle * myangle + 1))



Notes



The natural logarithm is the logarithm of the base e. The value of constant e is about 2.718282.



As shown below, by dividing the natural value of x by the natural pair value of n, you can calculate the numeric x's pair value for any bottom n:



Logn (x) = log (x)/log (n)



The following example shows how to write a function that asks for a value of 10:



Static Function Log10 (X)



LOG10 = log (X)/log (10#)



End Function



Name



Rnd



Category



Mathematical functions



Prototype



rnd[(number)]



Parameters



Required, the number argument is single or any valid numeric expression.



"Return value"



If the value of number is



Rnd generation



Less than 0



Each time, number is used as the same result as the random seed.



Greater than 0



The next random number in the sequence.



equals 0



The number of recent builds.



Omitted



The next random number in the sequence.



"Exception/Error"



No



Description



Returns a single that contains a random value. The RND function returns a value less than 1 but greater than or equal to 0. The value of number determines how the Rnd generates random numbers.



The same sequence is generated for the seed given initially, because each call to the RND function uses the first number in the sequence as the seed of the next number.



Before calling Rnd, the random number generator is initialized with a Randomize statement without parameters, which has seeds based on the system timer.



To generate a random integer in a range, you use the following formula:



Int ((upperbound-lowerbound + 1) * Rnd + lowerbound)



Here, the upperbound is the upper limit of the range of random numbers, and the lowerbound is the lower bound of the range of random numbers.



Note If you want to get a duplicate sequence of random numbers, call a Rnd with a negative parameter value directly before using a Randomize with a numeric parameter. Using a Randomize with the same number value does not get a duplicate sequence of random numbers.



Example



This example uses the RND function to randomly generate a random integer from 1 to 6.



Dim myvalue



MyValue = Int ((6 * Rnd) + 1) ' generates a random number from 1 to 6.



Notes



No



Name



Sgn



Category



Mathematical functions



Prototype



SGN (number)



Parameters



Required, the number argument is a valid numeric expression of any type



"Return value"



If number is



SGN return



Greater than 0



1



equals 0



0



Less than 0



-1



"Exception/Error"



No



Description



Returns a Variant (Integer) that indicates the positive or negative number of the parameter. The symbol for the number parameter determines the return value of the SGN function.



Example



This example uses the SGN function to determine the positive sign of a number.



Dim MyVar1, MyVar2, MyVar3, mysign



MyVar1 = 12:myvar2 = -2.4:MYVAR3 = 0



MySign = SGN (MYVAR1) ' returns 1.



MySign = SGN (MYVAR2) ' returns-1.



MySign = SGN (MyVar3) ' returns 0.



Notes



No



Name



Sin



Category



Mathematical functions



Prototype



Sin (number)



Parameters



Required, the number argument is a Double or any valid numeric expression that represents an angle in radians.



"Return value"



Returns a Double specifying the sine (sine) value of the parameter.



"Exception/Error"



No



Description



The Sin function takes an angle as a parameter value and returns the ratio of the angle to the length divided by the length of the hypotenuse.



The values of the results range from 1 to 1.



To convert the angle to radians, multiply the angle by pi/180. To convert radians to angles, multiply radians by 180/pi.



Example



This example uses the SIN function to find the sine value (sin ()) of one corner.



Dim MyAngle, Mycosecant



MyAngle = 1.3 ' defines the angle (in radians).






Notes



No



Name



Sqr



Category



Mathematical functions



Prototype



SQR (number)



Parameters



Required, the number argument is a double or any valid numeric expression that is greater than or equal to 0.



"Return value"



Returns a Double.



"Exception/Error"



No



Description



Returns the square root of the specified argument number



Example



This example uses the SQR function to compute the square root of a number.



Dim MYSQR



MYSQR = SQR (4) ' returns 2.



MYSQR = SQR (23) ' returns 4.79583152331272.



MYSQR = SQR (0) ' returns 0.



MYSQR = SQR (-4) ' generates a run-time error (negative numbers cannot open the square root of this function).



Notes



No



Name



Tan



Category



Mathematical functions



Prototype



Tan (number)



Parameters



Required, the number argument is a double or any valid numeric expression that represents an angle in radians.



"Return value"



Returns a Double.



"Exception/Error"



No



Description



Returns the tangent value of the specified argument number. Tan takes one angle as the parameter value and returns the ratio of two adjacent sides of the right angle. The ratio is the angle of the side length divided by the angle of the adjacent side length of the quotient.



To convert the angle to radians, multiply the angle by pi/180/180. To convert radians to angles, multiply radians by 180/pi.



Example



This example uses the TAN function to find the tangent of a corner (tan ()).



Dim MyAngle, MyCotangent



MyAngle = 1.3 ' defines the angle (in radians).



MyCotangent = 1/tan (myangle) ' uses tangent to compute cotangent (cot ()).



Notes



The following is a list of non-basic mathematical functions that can be derived from basic mathematical functions:



Function



The formula derived from the basic function





The following are the referenced contents:
Secant (secant)
SEC (x) = 1/cos (x)
Cosecant (more cut)
Cosec (x) = 1/sin (x)
Cotangent (cotangent)
Cotan (x) = 1/tan (x)
Inverse Sine (anyway chord)
Arcsin (x) = Atn (X/SQR (-X * x + 1))
Inverse cosine (anti-cosine)
Arccos (x) = Atn (-X/SQR (-X * x + 1)) + 2 * ATN (1)
Inverse secant (anyway cut)
ARCSEC (x) = Atn (X/SQR (x * X-1)) + SGN ((x)-1) * (2 * ATN (1))
Inverse cosecant (anti-surplus cut)
Arccosec (x) = Atn (X/SQR (x * X-1)) + (SGN (x)-1) * (2 * ATN (1))
Inverse cotangent (anti-cotangent)
Arccotan (x) = Atn (x) + 2 * ATN (1)
Hyperbolic Sine (hyperbolic sine)
HSin (x) = (exp (x)-exp (-X))/2
Hyperbolic cosine (hyperbolic cosine)
Hcos (x) = (exp (x) + EXP (-X))/2
Hyperbolic Tangent (hyperbolic tangent)
Htan (x) = (exp (x)-exp (-X))/(EXP (X) + exp (-X))
Hyperbolic secant (hyperbolic secant)
Hsec (x) = 2/(exp (x) + exp (-X)
Hyperbolic cosecant (double curved Cut)
Hcosec (x) = 2/(exp (x)-exp (-X)
Hyperbolic cotangent (hyperbolic cotangent)
Hcotan (x) = (exp (x) + exp (-X))/(exp (x)-exp (-X))
Inverse hyperbolic Sine (inverse hyperbolic sine)
Harcsin (x) = Log (x + SQR (x * x + 1))
Inverse hyperbolic cosine (inverse hyperbolic cosine)
Harccos (x) = Log (x + SQR (x * X-1))
Inverse hyperbolic Tangent (inverse hyperbolic tangent)
Harctan (x) = Log ((1 + x)/(1-x))/2
Inverse hyperbolic secant (anti-hyperbolic secant)
Harcsec (x) = Log ((SQR * x + 1) + 1)/x)
Inverse hyperbolic cosecant
Harccosec (x) = Log ((SGN (x) * SQR (x * x + 1) + 1)/x)
Inverse hyperbolic cotangent (anti-hyperbolic cotangent)
Harccotan (x) = Log ((x + 1)/(X-1))/2
Logarithm with N as the base
Logn (x) = log (x)/log (N)









Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.