SpeQ has functions for the numerical integration and differentiation of functions.
These are often used in the mathematics, physics, and engineering fields.
For example, when you integrate the speed of a car you get its position,
and when you differentiate a car's position you get its speed. |
| Function | Description |
|---|---|
| fnDiff(f(x), {x,} pos) | Calculates the differential of the function f(x) on position pos.
The differential is the slope of the function. Mathematical notation: |
| fnInt(f(x), {x,} start, end) | Calculates the integral of the function f(x) between start and end.
The integral is the area under the graph. Mathematical notation: |
| fnSolve(f(x) {,x } {, start}) | Calculates one value of x for which the function f(x) is zero. If the optional value start is provided, the function searches for a solution in the neighborhood of start. |
' First create a function
f(x) = 1/4 * x^3 + 3/4 * x^2 - 10 * x - 2
Function f(x) is defined
' Plot the function and study its shape.
' You can also trace the function to find the roots.
Plot(f(x))
Plot done
' From the plot we can see that the function
' is zero in the neighborhood of -8, 0 and 5.
' Now, you can calculate the different roots
' by specifying start points for the solver.
root1 = fnSolve(f(x), -8)
root1 = -7.921848227
root2 = fnSolve(f(x), 0)
root2 = -0.197273178
root3 = fnSolve(f(x), 5)
root3 = 5.119121405
'Examples of using the Analysis functions
fnInt(Sin(x),0, Pi)
Ans = 2
fnInt(Sin(t)+Cos(t), 0.25*Pi, 0.75*Pi)
Ans = 1.414213562
Ans^2
Ans = 2
fnDiff(2*Sqrt(pos), 9)
Ans = 0.333333333
'Analyze the function x^2 -3*x +2.5
plot(x^2 -3*x +2.5); 'Plot the function
'Calculate the area under the function
'between x=1 and x=3
fnInt(x^2 -3*x +2.5, 1, 3)
Ans = 1.666666667
Fraction(Ans)
Ans = 5/3
'Calculate the slope of the function at x=3.5
fnDiff(x^2 -3*x +2.5, 3.5)
Ans = 4
'So far we've entered the function 3 times
'It's more convenient to define the function once:
f(x) = x^2 -3*x +2.5
f(x) is defined
plot(f(x));
fnInt(f(x), 1, 3)
Ans = 1.666666667
fnDiff(f(x), 3.5)
Ans = 4
'Be sure the variable of the function
'you want to use isn't a previously-defined variable!
Time = 4.5
Time = 4.5
'In the next calculation, Time is the constant value 4.5
fnInt(Time^2, 0, 2*5)
Error: Unable to detect a variable in Function ...
'To correct this you can either use another variable
'or delete the variable that's causing the problem.
fnInt(Time2^2, Time2, 0, 2*5)
Ans = 333.333333333
Clear(Time);
fnInt(Time^2, Time, 0, 2*5)
Ans = 333.333333333
' Find a value of x for which the cosine is zero.
fnSolve(Cos(x))
Ans = 1.570796327
' Find another value of x for which the cosine is zero,
' in the neighborhood of 5.
fnSolve(Cos(x), 5)
Ans = 4.71238898