Preface
This is a tutorial made solely for the purpose of education and it was designed for students taking Applied Math 0330. It is primarily for students who have very little experience or have never used Mathematica before and would like to learn more of the basics for this computer algebra system. As a friendly reminder, don't forget to clear variables in use and/or the kernel.
Finally, the commands in this tutorial are all written in bold black font, while Mathematica output is in regular fonts. This means that you can copy and paste all comamnds into Mathematica, change the parameters and run them. You, as the user, are free to use the scripts to your needs for learning how to use the Mathematica program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately.
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the second course APMA0330
Return to Mathematica tutorial for the first course APMA0340
Return to the main page for the course APMA0340
Return to the main page for the course APMA0330
Return to Part V of the course APMA0330
Recurrences
We can define the Fibonacci recurrence (which is a second order difference equation \( F_{n+2} = F_{n+1} + F_n , \quad F_0 =1, \ F_1 =1 \) ) as
fibonacciList[10]
Module[{f},
f[1] = f[2] = 1; f[i_] := f[i] = f[i - 1] + f[i - 2];
f[n] ]
Module[{fPrev = 0, fNext = 1, i = 0},
While[i++ < n, {fPrev, fNext} = {fNext, fPrev + fNext}];
fNext]
Tail recursive Fibonacci sequence generator
fiboSequence[0, a_, b_] := Sow[a]
fiboSequence[n_] := Reap[fiboSequence[n, 0, 1]][[2, 1]]
fiboSequence[15]
Quiet@ReplaceRepeated[{0, 1}, {x___, a_, b_} :> {x, a, b, a + b}, MaxIterations -> n - 1]
fiboSequence2[15]
LinearRecurrence
:
Plotting Solutions to ODEs
Direction Fields
Separable Equations
Equations Reducible to the Separable Equations
Equations with Linear Fractions
Exact Equations
Integrating Factors
Linear Equations
RC circuits
Bernoulli Equations
Riccati Equations
Existence and Uniqueness
Qualitative Analysis
Bifurcations
Orthogonal Trajectories
Population Models
Applications
Return to Mathematica page
Return to the main page (APMA0330)
Return to the Part 1 (Plotting)
Return to the Part 2 (First Order ODEs)
Return to the Part 3 (Numerical Methods)
Return to the Part 4 (Second and Higher Order ODEs)
Return to the Part 5 (Series and Recurrences)
Return to the Part 6 (Laplace Transform)
Return to the Part 7 (Boundary Value Problems)