(* That's how you write comments *) (* To execute a command, type it, then press the SHIFT key, and, while holding it down, press RETURN - below I typed aa = Cos[1.4] and pressed RETURN to get the value of cos(1.4) *) aa = Cos[1.4] (* To define the function f(x) = ln(cos(x)), type the following: f[x_] = Log[Cos[x]] and, while holding SHIFT down, press RETURN; the underscore after x tels Mathematica that x is just a dummy variable *) f[x_] = Log[Cos[x]] (* Now you can compute the derivative of f(x) defined above by executing the command D[f[x],x] - try below *) D[f[x],x] (* Let us see whether the computer knows elementary functions *) Exp[f[x]] (* Evaluate the value of f(1.4) and assign its value to the variable p *) p = f[1.4] (* Now let us see the first 30 term of the Taylor series of f(x) around 0 - how long will it take you to do this by hand? *) Series[f[x],{x,0,30}] (* Below you see a fixed point iteration of the function g(x) = cos(x) with initial value 1 - that's an example of a control of the execution using "For"; note that the command p=N[1,3000] tells Mathematica that the variable p is equal to 1 with precision of 3000 digits; - the iterates converge to a fixed point of cos(x), approximately equal to 0.739085...; - as you can see, the convergence is not very vast *) p=N[1,3000]; g[x_] :=Cos[x]; For[i=1, i<=40, i++, {p=g[p], Print[i], Print[N[p,20]], Print[ ], } ] (* Below is the Newton method for finding the root of the equation cos(x)=x; we first write it as an equation of the form f(x) = cos(x) - x = 0 , and then apply Newton's method with initial value 1 - note that after only 6 steps we know more than 70 correct digits of the answer!!! *) p=N[1,3000]; g[x_] :=Cos[x]-x; For[i=1, i<=8, i++, {p=p - g[p]/g'[p], Print[i], Print[N[p,70]], Print[ ], } ]