Gnuplot Introductory Tutorials 3__ Math software

Source: Internet
Author: User
Tags bitwise cos natural logarithm rand sin square root

constants, operators, and functions Digital

Gnuplot that numbers can be divided into integers, real numbers and complex numbers:

Integer: Gnuplot is the same as the C language, with 4 byte stored integers. It can represent an integer between 2147483647 and +2147483647.

Real number: A significant number of digits representing about 6 or 7 digits, or numbers that are not greater than 308.

Plural: the plural is represented by {<real>,<imag>}. The real part of the complex number of <real> is,<imag>, and the two parts are represented by real numbers. such as 3 + 2i is indicated by {3,2}.

The principle of gnuplot is to store numbers in integers if they are stored in integers, otherwise stored in real numbers and then stored in complex numbers. For example, in gnuplot execution

Print 1/3*3
print 1./3*3

The results of 0 and 1.0 were obtained respectively. This is because the former uses an integer calculation, and the latter takes the result of a real number calculation. Perform

Print 1234.567
print 12345 + 0.56789
Print 1.23e300 * 2e6
print 1.23e300 * 2e8

The results of 1234.57, 12345.6, 2.46e+304 and undefined value are obtained respectively. These examples are limited by the number of significant digits and the maximum number of digits that can be represented by real numbers. This is what we should pay attention to. operator

The gnuplot operator is essentially the same as the C language. All operations can be done in integers, real numbers, or complex numbers.

Table 1 unary Operators

Symbol

Example

Explanation

-

-A

unary minus

~

~a

One ' s complement

!

!a

Logical negation

!

A!

Factorial

Table 2 Binary Operators

Symbol

Example

Explanation

**

A**b

exponentiation

*

A*b

Multiplication

/

A/b

Division

%

A%b

Modulo

+

A+b

Addition

-

A-b

Subtraction

==

A==b

Equality

!=

A!=b

Inequality

&

A&b

Bitwise AND

^

A^b

Bitwise EXCLUSIVE OR

|

A|b

Bitwise inclusive OR

&&

A&&b

Logical AND

||

a| | B

Logical OR

?:

A?b:c

Ternary operation

function

The parameters of a function in gnuplot can be integers, real numbers, or complex numbers. Table 3 is the function provided by Gnuplot.

Table 3 Gnuplot functions

Function

Auguments

Returns

ABS (x)

Any

Absolute value of x, |x|; Same type

ABS (x)

Complex

Length of x, sqrt (real (x) ^2 + imag (x) ^2)

ACOs (x)

Any

1/cos (x) (inverse cosine) in radians

Acosh (x)

Any

cosh−1 x (inverse hyperbolic cosine) in radians

ARG (x)

Complex

The phase of X in radians

ASIN (x)

Any

1/sin (x) (inverse sin) in radians

Asinh (x)

Any

sinh−1 x (inverse hyperbolic sin) in radians

Atan (x)

Any

1/tan (x) (inverse tangent) in radians

ATAN2 (y,x)

int or real

Tan−1 (y/x) (Inverse tangent)

Atanh (x)

Any

tanh−1 x (inverse hyperbolic tangent) in radians

Besj0 (x)

int or real

J0 Bessel function of X

BESJ1 (x)

int or real

J1 Bessel function of X

Besy0 (x)

int or real

Y0 Bessel function of X

Besy1 (x)

int or real

Y1 Bessel function of X

Ceil (x)

Any

Smallest integer not less than x (real part)

COS (x)

Radians

Cos x, cosine of X

Cosh (x)

Radians

cosh x, hyperbolic cosine of X

ERF (x)

Any

ERF (Real (x)), error function of the real (x)

ERFC (x)

Any

ERFC (Real (x)), 1.0-error function of real (x)

EXP (x)

Any

exponential function of X

Floor (x)

Any

Largest integer not greater than X (real part)

Gamma (x)

Any

Gamma (Real (x)), gamma function of the real (x)

Ibeta (p,q,x)

Any

Ibeta (p,q,x), Ibeta function of real (P,Q,X)

Inverf (x)

Any

Inverse error function of real (x)

Igamma (a,x)

Any

Igamma (a,x), Igamma function of real (A,X)

Imag (x)

Complex

Imaginary part of X as a real number

Invnorm (x)

Any

Inverse Normal distribution function of real (x)

int (x)

Real

Integer part of x, truncated toward zero

LAMBERTW (x)

Real

Lambert W function

Lgamma (x)

Any

Lgamma (Real (x)), Lgamma function of real (x)

Log (x)

Any

ln (x), natural logarithm (base e) of X

LOG10 (x)

Any

Log (x), logarithm (base) of X

Norm (x)

Any

Normal distribution (Gaussian) function of real (x)

RAND (x)

Any

Normal distribution (Gaussian) function of real (x)

Real (x)

Any

Rand (Real (x)), pseudo random number generator

SGN (x)

Any

Real part of X

Sin (x)

Any

1 if x>0,-1 if x<0, 0 if x=0. IMAG (x) ignored

Sinh (x)

Radians

Sin (x), sine of X

sqrt (x)

Radians

Sinh (x), hyperbolic sine x

Tan (x)

Any

sqrt (x), square root of X

Tanh (x)

Complex

Tan (x), tangent of X

Column (x)

Int

Column x during datafile manipulation.

Defined (X)

Variable name

Returns 1 if a variable X is defined, 0 otherwise.

TM Hour (x)

Int

The hour

TM Mday (x)

Int

The day of the month

TM min (x)

Int

The minute

TM Mon (x)

Int

The Month

TM sec (x)

Int

The second

TM Wday (x)

Int

The day of the week

TM Yday (x)

Int

The day of the year

TM year (x)

Int

The year

Valid (x)

Int

Test validity of column (x) during datafile Manip.


Here are some examples:

Plot [0.5:20] Besj0 (x), besj1 (x), Besy0 (x), besy1 (x)
plot [0:5] Erf (x), ERFC (x), Inverf (x)

user-defined functions and constants

In Gnuplot, the user can customize the function. A function can have 1 to 5 arguments. The syntax for its definition function is as follows:

<function-name> (<dummy1> {,<dummy2> {, ...}}) = <expression>

The syntax for user-defined constants is as follows:

<variable-name> = <constant-expression>

Here are some examples:

# constant W is 2.
w = 2                       
# constant q is an integer less than but closest to Tan (PI/2-0.1).
q = Floor (tan (PI/2-0.1))  
# function f (x) is sin (w*x), where w is constant.
f (x) = sin (w*x)             
# function sinc (x) is sin (pi*x)/(pi*x).
sinc (x) = sin (pi*x)/(pi*x)  
# function Delta (t) is a pulse function.
Delta (t) = (t = = 0) 
# function ramp (t) when it is less than 0 is zero, when its greater than 0 is a straight line with a slope equal to 1.
Ramp (t) = (T > 0) t:0 
# function min (a,b) takes the smaller number of both.
min (a,b) = (A < b)? a:b
Comb (n,k) = n!/(k!* (n-k)!)
Len3d (x,y,z) = sqrt (x*x+y*y+z*z)
plot f (x) = sin (x*a), a = 0.2, f (x), a = 0.4, f (x)

The

gnuplot  defined constants have only  pi  (pi = 3.14159).


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.