## Analysis FunctionsSpeQ 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.## FunctionvariableThe function you want to analyze must depend on one variable. This can bex, but you can use any variable you like.
SpeQ will find the functionvariable automatically if it's not explicitly defined, as in fnInt(Sin(x),0,1).
You can't choose a variable name that's identical to a previously-defined variable or function name.## (Dis)continuous functionsBecause of the numerical methods used, it's only possible to use these analytical functions for continuous functions. For example,fnInt(x>0, -1, 1) is a discontinuous function. The integral won't give an answer because there's no convergence.
(In this case the function is discontinuous at x=0).If you need to calculate the integral of a discontinuous function, first split it up into continuous parts. An example would be fnInt(x>0, -1, -1e-10) + fnInt(x>0, 1e-10, 1). Be sure to exclude the discontinuity itself.
## OverviewSpeQ has the following analysis functions.
' 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'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 ## See AlsoFunctions overview, Functionstree, Plot |