Writing Math Expressions and Functions
Formulating and writing a symbolic expression for a related operation is a fundamental skill for learning math. An expression usually consists of operators, numbers, and names of functions and variables. Operating with an expression is just as using a calculator.
Operators The operators +, -, *, /, ** (or ^) represent addition, subtraction, multiplication, division, and exponent, respectively, and the characters "( ), >, >=, <, <=, =" are also used in an expression for order of operations, equations and inequalities.
Function names Algebraic functions such as polynomials, rational, power and root functions do not have a three-letter function name, but the exponential, logarithmic, trigonometric, and hyperbolic functions have a name of three or four letters such as exp(x), log(x), sin(x), cos(x), sinh(x), cosh(x) and so on. The inverse trigonometric and hyperbolic functions are represented by asin(x), acos(x), atan(x), acosh(x), atanh(x), etc. These names must be in lower case, followed by a parenthesis for their variables or arguments, for example, "log(x)", "exp(a)", "atan(x+y)", "sin(πx)".
Symbols and variables Math expressions may involve one or more variables, which are usually represented by symbols or characters. Our program requires that each variable is represented by a single alphabet letter (and is case sensitive). For instance, the expression "2*x + log(y/2)" has two single-letter variables "x" and "y". However, the variable "x1" in "2*(x1 + y)" is not allowed, because "x1" is not a single letter. Replacing "x1" by "x", "a", "b", B", or any other letters will make the expression valid for the program.
Expressions in Display and Computing Forms You may have already noticed that displaying a math expression is different from entering the expression into a computer program (computing form) for computing. The multiplication operator "*" is omitted by convention in printing materials and textbooks, but omitting any operator in a computing form would result in an error. For example, the expression "2x + 3(y - 1) + cos z" is known for display purpose, but it is not recognized by most computer algebra system. The valid computing form should be "2*x + 3*(y - 1) + cos(z)". To start computing and graphing an expression, you need to write a valid expression in computing form for your intended math operations.
Expressions for Complicated Math Operations
More elements are required for complicated math operations. These elements form a short array, appear in a certain order, and are separated by a semicolon (;). They typically include operation or function names, numbers and variables, optional keywords and related values.
Operation Names and Elements First you need to tell the computing program what math operation you want to perform, and what necessary elements are needed for the operation. If you want to simplify or compare two expressions, just enter such expressions as "2*(x-3) + 5", "8**(2/3)", "sin(2) > cos(2)" (one at a time), and you can see the corresponding results "2x-1", "4", and "True". However, for a complicated operation, you need to enter a three-character name for the operation along with other necessary elements.
Table Main Operation and Function Names lists the major operation and function names implemented in the program. These operations represent functions that are similar to typical elementary functions like exp(x + y) and log(3x - 2), but they involve more elements. For example, finding the limit of \(\frac{\sin x}{x}\) as \(x\) approaches 0 requires an array of four elements “lim; sin(x)/x; x; 0”, which include the operation name "lim" and other three necessary items. To solve the equation \(x^3+3x^2-4x-12=0\), you need to enter "slv; x**3+3*x**2-4*x-12; x", which include the operation name "slv", the equation expression "x**3+3*x**2-4*x-12", and the variable "x" to be solved for.
Function calls You can think of the array "slv; f(x); x" as a function call "slv(f(x), x)" for solving f(x) = 0 for x. It has two arguments in order, and the expressions "slv(f(x), x)" and "slv; f(x); x" return the same solution for x.
Operation combination A useful combination of "slv(dif(f(x), x), x)" can be used to find critical numbers of f(x). Click the subject Differentiation for more details on such operations. Just as regular compositions of elementary functions, you can combine proper operations (limit, derivative, integral, and series expansion) to carry out more complicated math operations.
Code | Description | Code | Description |
---|---|---|---|
slv | solve equations and inequalities | eqs | solve system of linear and nonlinear equations |
lim | find limits | dif, idf | find derivatives and partial/implicit derivatives |
itg | find antiderivatives and evaluate definite integrals | nit | approximate definite integrals |
plt | graph explicit functions | pol | graph explicit polar functions |
pc2 | plot 2D curves for parametric equations | pc3 | plot 3D curves for parametric equations |
sf3 | plot 3D surfaces for explicit functions of two variables | ps3 | plot parametric surfaces of two parameters |
ism | find infinite sum and determine convergence | ses | series expansion and approximation |
vec, mat | operate with vectors/matrices | ode | solve ordinary differential equations |
prj, ang | find projection/angle between two vectors | ods, pde | solve systems of ODEs and partial differential equations |
cul, dvg | find curl and divergence for vector fields | grd, tnv | find gradient/tangent vectors |
lit, sit | evaluate line/surface integrals | inv | find matrix inverse |
det, rank, norm, chp | determinant, rank, norm and characteristic polynomials | rref, elf | reduce a matrix to (reduced) echelon form |
eig, tsp | find eigenvalues and eigenvectors/transpose | grs, dgl | Gram-Schmidt orthogonalization/diagonalization |
qrd, lud, chl | matrix decomposition: QR, LU, and Cholesky | svd, ldl, rkd | matrix decomposition: sigular value, LDL, rank |
Examples of Computing Math Expressions
Computing | Display | Computing | Display |
---|---|---|---|
2**(1/2) | \(\sqrt{2}\) | (-15)**(2/3) | \(\sqrt[3]{(-15)^2}\) |
log(2/3) | \(\ln\frac{2}{3}\) | log(3)/log(5) | \(\log_5(3)\) |
x**2-2*x >= 3 | \(x^2-2x≥3\) | x**2+y**2-9 | \(x^2+y^2-9\) or \(x^2-y^2=9\) [equation] |
sin(x)**2+cos(x)**2 | \(\sin^2x + \cos^2x\) | 2*asin(-1/3)-b*acos(1/4)**2 | \(2\sin^{-1}(-\frac{1}{3})-b(\cos^{-1}\frac{1}{4})^2\) |
y**0.3*z**-3+abs(x+3) | \(\frac{y^{0.3}}{z^3}+|x+3|\) | 3**(-5)+a**x+exp(-x**2) | \(3^{-5}+a^x+e^{-x^2}\) |
sinh(acosh(x^2)) | \(\sinh(\text{cosh}^{-1}(x^2))\) | -1/(Abs(x)*(x^2-1)^(1/2)) | \(\frac{-1}{|x|\sqrt{x^2-1}}\) |
a+b*I | \(a+bi\) | gamma(31)/(23*gamma(25)) | \(\frac{30!}{23(24!)}\) |
cot(2*pi/3) | \(\cot\frac{2π}{3}\) | oo | \(∞\) |