Program to easily create fourier series on TI calculators ============================================================================ Author: Philipp Burch Mail: philipp_burch@bluemail.ch Date: 03.02.2010 Introduction ------------ Taylor series can easily be calculated on TI calculators using the taylor() command. However, there is no such thing for fourier series. Here are functions to provide an equivalently easy creation of fourier series using only a single function call. Installation ------------ The functions are written in TI-BASIC and should therefore work with all current models of TI calculators. The installation procedure differs significantly between the 68k models (TI-89 (T), V200, TI-92+) and the new TI-nspire. 68k: A link cable (DirectLink or SilverLink for example), as well as a linking software, such as TILP II (http://lpg.ticalc.org/prj_tilp/) or TI-Connect (http://education.ti.com) is required. The only thing needed to "install" the functions is then to copy the files "fourier.89f" and "fcoeff.89f" to the calculator. nspire: Installation on the TI-nspire is a bit more complicated, since there are "libraries" and not only single variables to be copied. Required is a USB link cable and the software "TI-Nspireā„¢ Computer Link Software" by Texas Instruments (http://education.ti.com). The first thing to do is to copy the file "fourier.tns" into the "MyLib" folder on the calculator. Afterwards, the calculator needs to be notified about the newly installed library using [ctrl]+[HOME] -> Refresh libraries The library should now show up in the [catalog] on the last register file. Inside the library, the variables "fourier" and "fcoeff" should exist. To use the functions, it is now necessary to write fourier\fourier(...) and fourier\fcoeff(...). That is not very convenient, so it is a good idea to create a library shortcut ([menu] -> "Actions" -> "Library" -> "Create Library Shortcut") with the arguments "fourier" and "ff". So the command line looks like libShortcut("fourier","ff") [enter] should then produce "{ff.fcoeff,ff.fourier}". It is now possible to access the functions using "ff.fourier(...)" or "ff.fcoeff(...)". Usage ----- The files contain two functions: 1. fcoeff(...) to calculate the fourier coefficients 2. fourier(...) to calculate the fourier series fcoeff(fcts,var,lower,uppers) fourier(fcts,var,lower,uppers,order) fcts: A list of functions which describe the curve. var: The independent variable, for example 'x'. lower: The lower bound of the first describing function. uppers: The upper limits of their respective describing functions as a list. order: The order of the resulting fourier series. Return value: fcoeff(...) returns a0, an, bn, and w0 (omega 0). This function is called internally by fourier(...), so it is usually not explicitly necessary. fourier(...) calculates the resulting fourier series up to the given order. Examples -------- 1. Given is the saw-tooth curve with the function y=x from 0 to 1 and the period T=1. Calculate the fourier series up to the fifth order. Function call: fourier(x,x,0,1,5) 2. Given is the symmetrical triangle curve with the slope 1 and -1 and the inflection points x=1 and x=2. Calculate the fourier series up to the eighth order. Function call: fourier({x,2-x},x,0,{1,2},8) 3. Given is the triangle curve from example 2. Calculate the fourier coefficients a0, an, bn and the circular frequency w0. Function call: fcoeff({x,2-x},x,0,{1,2}) Result: a0=1 an=(2*(-1)^n)/(n^2*pi^2)-2/(n^2*pi^2) bn=0 w0=pi Hints ----- 1. The program internally uses integrals to calculate the coefficients. So the results are only correct if the calculator uses radians (RAD) as angular format. 2. On the 68k calculators, computations can easily take 10 to 20 seconds. If for any reason the calculator should hang in an infinite loop, the computation can always be cancelled using [ON]. 3. 68k: To have a look at the code, the program editor can be used. However, to update it, the variable has first to be unarchived (VAR-LINK). nspire: To get the code of the functions, the library "fourier" needs to be opened. The code can then be looked at with the "Program Editor" ([menu] "Functions & Programs" -> "Program Editor" -> "Open"). To do any changes, the variables need to be unlocked first: [menu] -> "Actions" -> "Lock" -> "Unlock Variable". 4. The functions have been tested with some examples. However, it can not be guaranteed that there are no bugs in them. A good way to confirm the output is to plot the function. This action can take much time if the order is too high, say, above 10. 5. If the curve is described using only a single function (as in example 1), the function can also be passed directly, without the need of a list. But it is important that the format of "fcts" is the same as the format of "uppers"!