Sometimes you may be interested in selecting a different functions depending on the value of the arguments or variables.
You can specify a condition by add semicolon (;) to the end of the function followed by the condition expression. For example, you could type:
f(x)=x-5; x<0
Function f will only be called if its argument is less than zero.
Here are some more examples of defining functions:
The program will decide which function to call depending on the value of x:
The following demonstrates how the Taylor Polynomial series Tn(x) consists of n fractions:
The higher n, the more terms (fractions) the Taylor Polynomial consists of, and therefore the better is the accuracy of the approximation.
The value of variable n between 0 and 5 will decide how many terms are calculated:
n=2 Tn(x)=1; n=0 Tn(x)=1+x; n=1 Tn(x)=1+x+x^2/2!; n=2 Tn(x)=1+x+x^2/2!+x^3/3!; n=3 Tn(x)=1+x+x^2/2!+x^3/3!+x^4/4!; n=4 Tn(x)=1+x+x^2/2!+x^3/3!+x^4/4!+x^5/5!; n=5 value=Tn(n)
A more clever way of define tylor series involves using recursive functions.