Skip to content

Latest commit

 

History

History
153 lines (112 loc) · 6.91 KB

Functions.rst

File metadata and controls

153 lines (112 loc) · 6.91 KB

Functions, Operators & Constants

The Following Functions, Operators and Constants are defined and useable in Expression Strings.

Note

All names are case-senitive

Constants

Constants are basicaly unchanging global variabes, an used to define special values

Name Version Added Value
pi 1.0 Pi (π)
e 1.0 Euler's number (e)
Inf 1.0 Infinity ()
NaN 1.0 Not a Number
h 1.1 Plancks Constant (h)1
hbar 1.1 Reduced Plancks Constant ()2
m_e 1.1 Electron Mass ($m_{\rm e}$)3
m_p 1.1 Proton Mass ($m_{\rm p}$)4
m_n 1.1 Neturon Mass ($m_{\rm n}$)5
c 1.1 Speed of Light (c)6
N_A 1.1 Avogardo's Number ($N_{\rm A}$)7
mu_0 1.1 Magnetic Constant (μ0)8
eps_0 1.1 Electric Constant (ε0)9
k 1.1 Boltzmann Constant (kb)10
G 1.1 Gravitational Constant (G)11
g 1.1 Standard Accleration due to gravity (g)12
q 1.1 Elementary Charge (e)13
R 1.1 Ideal Gas Constant (R)14
sigma 1.1 Stefan-Boltzmann Constant (σ)15
Rb 1.1 Rydberg Constant (R)16

Operators

Operators are special function maped to a symbol, that will appear between the operands rather than as a name folloed by a comma seperated list of operands.

Operators have a Precedence this indicate the Priotiy with which they are applied i.e. low Precedence valued operators will be evaluated before higher valued ones.

Note

Values of the same Precedence are evaluated left to right

Symbol Operation Syntax Precedence Display
+ Added A to B A + B 3 (A+B)
- Subtract B from A A - B 3 (AB)
* Mutlipy A by B A * B 2 (A×B)
/ Divide A by B A / B 2 $\frac{A}{B}$
% Reminder of A Divided by B A % B 2 (AmodB)
^ Raise A to the B'th power A ^ B 1 AB
& Logical AND of A and B A & B 4 (AB)
| Logical OR of A and B A | B 4 (AB)
<\> Logical XOR of A and B A <\> B 4 (AB)
! Logical NOT of A !A UNARY ¬A
== Test if A is equal to B A == B 5 (A=B)
~ Test if A is similar to B A ~ B 5 (AB)17
!= Test if A isn't equal to B A != B 5 (AB)
!~ Test if A isn't similar to B A !~ B 5 (AB)18
< Test if A is less than to B A < B 5 (A<B)
> Test if A is more than to B A > B 5 (A>B)
<= Test if A is less than or equal to B A < B 5 (AB)
>= Test if A is more than or equal to B A > B 5 (AB)
<~ Test if A is less than or similar to B A < B 5 (AB)19
>~ Test if A is more than or similar to B A > B 5 (AB)20

Functions

These as normal functions a name followed by a list of parameters

Name Operation Syntax Display
abs Absolute value of A abs(A) |A|
sin Sine value of A sin(A) sin (A)
cos Cosine value of A cos(A) cos (A)
tan Tangent value of A tan(A) tan (A)
re Real Compoent of A re(A) ℜ(A)
im Imagery Compoent of A im(A) ℑ(A)
sqrt Square root of A sqrt(A) $\sqrt{A}$
log Logarithm of A log(A) log A

Examples

The Following are some example expressions demonstrating the Precedence order and display formating

sin(x*(y+z))
sin((x * (y + z)))


sin ((x×(y+z)))

(a+b)/(c+d)
((a + b) / (c + d))

$$\frac{\left(a + b\right)}{\left(c + d\right)}$$

a+b/c+d*e^f
((a + (b / c)) + (d * (e ^ f)))

$$\left(\left(a + \frac{b}{c}\right) + \left(d \times e^{f}\right)\right)$$

a^b/c^d
((a ^ b) / (c ^ d))

$$\frac{a^{b}}{c^{d}}$$

a*b/c*d
(((a * b) / c) * d)

$$\left(\frac{\left(a \times b\right)}{c} \times d\right)$$

a*b/(c*d)
((a * b) / (c * d))

$$\frac{\left(a \times b\right)}{\left(c \times d\right)}$$


  1. Requires scipy to use these constants

  2. Requires scipy to use these constants

  3. Requires scipy to use these constants

  4. Requires scipy to use these constants

  5. Requires scipy to use these constants

  6. Requires scipy to use these constants

  7. Requires scipy to use these constants

  8. Requires scipy to use these constants

  9. Requires scipy to use these constants

  10. Requires scipy to use these constants

  11. Requires scipy to use these constants

  12. Requires scipy to use these constants

  13. Requires scipy to use these constants

  14. Requires scipy to use these constants

  15. Requires scipy to use these constants

  16. Requires scipy to use these constants

  17. Check it values are very close rather then just equal, i.e. 1 is similar to 1.000001 but not equal (see similar-module)

  18. Check it values are very close rather then just equal, i.e. 1 is similar to 1.000001 but not equal (see similar-module)

  19. Check it values are very close rather then just equal, i.e. 1 is similar to 1.000001 but not equal (see similar-module)

  20. Check it values are very close rather then just equal, i.e. 1 is similar to 1.000001 but not equal (see similar-module)