\documentclass[12pt]{article}
\usepackage[dvips]{graphicx}
\usepackage{enumerate}
\usepackage{ifthen}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{hyperref}

%\pagestyle{empty}
\topmargin -0.55in
\oddsidemargin -0.3in
\evensidemargin -0.3in
\textheight 9in
\textwidth 7.1in 

\newcommand{\ALPHA}{\checkmark} 
\newcommand{\SPACE}{0.025in} 

\begin{document}

\noindent {}%\hspace*{-0.2in}
\fbox{\fbox{\parbox{6.85in}{{\scshape{Math 1030 \hfill Introduction to Wolfram Alpha}} }}} \\

\vspace{-0.2in}

\begin{center} \Large
Using Wolfram Alpha: Tips \& Tricks
\end{center}

\href{https://www.wolframalpha.com/}{Wolfram Alpha} is a massive online mathematical toolbox. It can graph, solve, and do all kinds of interesting things. Alpha is built on Stephen Wolfram's Mathematica. Mathematica is a computer algebra system --- it will do algebraic manipulations, solve equations, plot graphs plus a whole lot more.

I recommend watching \underline{\href{https://www.wolframalpha.com/screencast/introducingwolframalpha.html}{Stephen Wolfram's Introduction}} to Alpha just to get an idea of what it can do. This handout is focused on tasks which come up in Math 1030.

\begin{description}
\item[Formulas] Alpha is set up to interpret ``plain English'' input. It won't do a perfect job every time, but it might surprise you how often it understands what you want to do. If Alpha doesn't interpret your input as you intended, just reword and try again. 

Formulas can be entered the same way we would enter them in Excel (or Maple) except Alpha is much less picky.
For example, $e^{-x^2}$ must be entered as ``\verb|=EXP(-(A1^2))|'' in Excel (watch out for the Excel error). In Maple
this would be ``\verb|exp(-x^2)|''. Alpha will accept ``\verb|exp(-x^2)|'' as well, but it will also accept ``\verb|e^(-x^2)|'' (which makes Excel and Maple very unhappy).  Alpha is also much more forgiving about leaving out ``*'' for multiplications. In Excel ``\verb|=3LN(A1)|'' will lead to an error, in Alpha ``\verb|3ln(x)|'' is just fine. Notice that Alpha uses Mathematica's {\bf nonstandard} notation for the natural logarithm. Instead of writing ``$\ln(x)$'' for the natural log, Alpha writes ``$\mathrm{log}(x)$'' (which more commonly refers to the base 10 logarithm). 

\item[Plots] If we enter a formula such as \verb|xe^(-x^2)| \href{https://www.wolframalpha.com/input/?i=xe^(-x^2)}{\ALPHA}, Alpha will automatically graph the function (and give a bunch of information about it). If we wish to view a certain portion of the graph, we need to tell Alpha what part of the $x$-axis to focus on. Say we wish to graph the function where $-1 \leq x \leq 3$.  Here are a few ways we could tell Alpha to create such a plot (they all produce the same output):

\vspace{\SPACE}

\verb|plot xe^(-x^2) when x is between -1 and 3| \href{https://www.wolframalpha.com/input/?i=plot+xe^(-x^2)+when+x+is+between+-1+and+3}{\ALPHA}

\vspace{\SPACE}

\verb|plot xe^(-x^2) where x=-1..3| \href{https://www.wolframalpha.com/input/?i=plot+xe^(-x^2)+where+x\%3D-1..3}{\ALPHA}

\vspace{\SPACE}

\verb|plot xe^(-x^2) where -1 < x < 3| \href{https://www.wolframalpha.com/input/?i=plot+xe^%28-x^2%29+where+-1+%3C+x+%3C+3}{\ALPHA}

\vspace{\SPACE}

\verb|plot x exp(-x^2) on [-1,3]| \href{https://www.wolframalpha.com/input/?i=plot+x+exp(-x^2)+on+[-1%2C3]}{\ALPHA}

\vspace{\SPACE}

To graph several functions together we just list them off or write ``and'' between our expressions. For example,
to graph $y=e^{-0.2x}$, $y=e^{-0.2x}\sin(3x)$, and $y=-e^{-0.2x}$ together where $1 \leq x \leq 10$ we could type:

\vspace{\SPACE}

\verb|plot e^(-0.2x), e^(-0.2x)sin(3x), -e^(-0.2x) on [1,10]| \href{https://www.wolframalpha.com/input/?i=plot+e^(-0.2x)%2C+e^(-0.2x)sin(3x)%2C+-e^(-0.2x)+on+[1%2C10]}{\ALPHA}

or

\verb|plot exp(-0.2x) and exp(-0.2x)sin(3x) and -exp(-0.2x) where x=1 to 10| \href{https://www.wolframalpha.com/input/?i=plot+exp(-0.2x)+and+exp(-0.2x)sin(3x)+and+-exp(-0.2x)+where+x%3D1+to+10}{\ALPHA}

\vspace{\SPACE}

\item[Solving Equations] Most of the time the equations we need to solve are of the form: $f(x)=0$. Solutions to such an equation are called {\it roots}
(or {\it zeros}) of $f(x)$. In Alpha, it is usually enough just to type in the function $f(x)$ and it will automatically solve $f(x)=0$ (find roots) for us. For example,
if we type:

\vspace{\SPACE}

\verb|(-9x^4+20x^3-9)/(x^4-3)^2| \href{https://www.wolframalpha.com/input/?i=%28-9x^4%2B20x^3-9%29%2F%28x^4-3%29^2}{\ALPHA}

\vspace{\SPACE}

Alpha automatically solves the equation $\displaystyle \frac{-9x^4+20x^3-9}{(x^4-3)^2}=0$. It not only finds the 2 real roots, but also finds 2 complex roots. Notice the button near the real roots. This allows you to switch between approximate and exact answers (Alpha chose approximate answers because the exact ones are really complicated). Also, notice there is a button which allows us to see more digits in case we need more precision. If we tell Alpha:

\vspace{\SPACE}

\verb|solve 5x^2+3x-5=0=0| \href{https://www.wolframalpha.com/input/?i=solve+5x^2%2B3x-5%3D0}{\ALPHA}

\vspace{\SPACE}

Alpha again solves the equation, but this time a button labeled ``show steps'' appears so we can see how to find the solution algebraically.

Alpha will also solve several equations at once. We can just ask it to ``solve equation \#1 and equation \#2''. Or we can give it a list of equations to solve such as ``solve equation \#1, equation \#2, equation \#3, etc.''

\vspace{\SPACE}

\verb|solve x^2+3x=y and y=x+3| \href{https://www.wolframalpha.com/input/?i=solve+x^2%2B3x%3Dy%2C+y%3Dx%2B3}{\ALPHA}

\vspace{\SPACE}

\verb|solve x+e^y-ln(z)=1, x+5y=5, z=e^y| \href{https://www.wolframalpha.com/input/?i=solve+x%2Be^y-ln(z)%3D1%2C+x%2B5y%3D5%2C+z%3De^y}{\ALPHA}

\vspace{\SPACE}

Suppose we wish to solve some awful equation like: $\sin(x^2+e^{-x^2}+\ln|x^2+1|)=\sqrt{2}-1$

\vspace{\SPACE}

\verb#sin(x^2+e^-x^2+ln|x^2+1|)=sqrt(2)-1# \href{https://www.wolframalpha.com/input/?i=sin%28x^2%2Be^-x^2%2Bln|x^2%2B1|%29%3Dsqrt%282%29-1}{\ALPHA}

\vspace{\SPACE}

Alpha goes ahead and solves the equation, but does not find all possible solutions (this isn't surprising because the equation cannot be solved algebraically --- it's quite bad). Suppose we wish to find a solution close to 10. We might try to enter something like ``solve $\sin(x^2+e^{-x^2}+\ln|x^2+1|)=\sqrt{2}-1$ over $9.5 < x < 10.5$''  -- the key word is ``over''. Sometimes this will work.

\verb#solve sin(x^2+e^(-x^2)+ln|x^2+1|)=sqrt(2)-1 over 9.5 < x < 10.5# \href{https://www.wolframalpha.com/input/?i=solve+sin%28x%5E2%2Be%5E%28-x%5E2%29%2Bln%7Cx%5E2%2B1%7C%29%3Dsqrt%282%29-1+over+9.5+%3C+x+%3C+10.5}{\ALPHA}

But this equation is so bad Alpha still chokes. To help it out we can try using {\it real} Mathematica syntax. In Mathematica the numerical solver is called ``FindRoot''. The following command will find a solution close to 10:

\vspace{\SPACE}

\verb#FindRoot[sin(x^2+e^-x^2+ln|x^2+1|)=sqrt(2)-1, {x,10}]# \href{https://www.wolframalpha.com/input/?i=FindRoot[sin%28x^2%2Be^-x^2%2Bln|x^2%2B1|%29%3Dsqrt%282%29-1%2C+{x%2C10}]}{\ALPHA}

\vspace{\SPACE}

Alpha will do some incredible things, but it has its limits. In general, if Alpha is giving you trouble, try searching for the real Mathematica input. 

\item[Plugging in Values] To plug values into an expression, we could merely replace every copy of our variable with a number. But this is tedious and unpleasant. To get Alpha to plug-in values simply use a phrase like ``where x=5'' or
``at x=5''. 

\vspace{\SPACE}

\verb|x^2+3x+4 where x=-1| \href{https://www.wolframalpha.com/input/?i=x^2%2B3x%2B4+where+x%3D-1}{\ALPHA}

\vspace{\SPACE}

\verb|x^2+3x+4 at x=-1| \href{https://www.wolframalpha.com/input/?i=x^2%2B3x%2B4+at+x%3D-1}{\ALPHA}

\vspace{\SPACE}

If we wish to plug in multiple values, we can tell Alpha something like ``x=[value 1, value 2, value 3, etc.]'' 

\vspace{\SPACE}

\verb|x^2+3x+4 at x=[-1,5,100]| \href{https://www.wolframalpha.com/input/?i=x^2%2B3x%2B4+at+x%3D[-1%2C5%2C100]}{\ALPHA}

\vspace{\SPACE}

\verb|x^2+3x+4 where x=[-1,0,2,pi]| \href{https://www.wolframalpha.com/input/?i=x^2%2B3x%2B4+where+x%3D[-1%2C0%2C2%2Cpi]}{\ALPHA}

\vspace{\SPACE}

Be careful about trying this with {\it really} complex or sensitive commands. For example, plugging in a list of values doesn't seem to want to work with the ``piecewise'' command (see below).

\item[Differentiation and Integration] Finding derivatives is easy. Just tell Alpha ``derivative''.

\vspace{\SPACE}

\verb|derivative e^(-x^2)+5x-7| \href{https://www.wolframalpha.com/input/?i=derivative+e^(-x^2)%2B5x-7}{\ALPHA}

\vspace{\SPACE}

Alpha will automatically look for roots (zeros of the derivative are critical points). 

Computing definite and indefinite integrals is equally easy. We can just tell Alpha either ``integrate'' or ``int''. The following commands
compute the indefinite integral $\int \ln(x)+x^4\,dx$:

\vspace{\SPACE}

\verb|integrate ln(x)+x^4| \href{https://www.wolframalpha.com/input/?i=integrate+ln(x)%2Bx^4}{\ALPHA}

\vspace{\SPACE}

\verb|int ln(x)+x^4| \href{https://www.wolframalpha.com/input/?i=int+ln(x)%2Bx^4}{\ALPHA}

\vspace{\SPACE}

To compute definite integrals we again use ``int'' or ``integrate'' but also need to include the limits of integration. We can do this much in the same way we specify bounds for a plot. For example, we can compute the value of the definite integral $\displaystyle \int_{-1}^2 xe^{x^2}+5\,dx$ by typing in the following commands:

\vspace{\SPACE}

\verb|int xe^(x^2)+5 from x=-1 to 2| \href{https://www.wolframalpha.com/input/?i=int+xe^%28x^2%29%2B5+from+x%3D-1+to+2}{\ALPHA}

\vspace{\SPACE}

\verb|int xe^(x^2)+5 on [-1,2]| \href{https://www.wolframalpha.com/input/?i=int+xe^%28x^2%29%2B5+on+[-1%2C2]}{\ALPHA}

\vspace{\SPACE}

\verb|int xe^(x^2)+5 where -1 < x < 2| \href{https://www.wolframalpha.com/input/?i=int+xe^%28x^2%29%2B5+where+-1+%3C+x+%3C+2}{\ALPHA}

\vspace{\SPACE}

{\it Note:} When finding absolute minimums and maximums, one can use ``minimum'' or ``minimize'' and ``maximum'' or ``maximize''. Alpha will attempt to find a global extrema. You can also ask Alpha to find an extrema when a  function is restricted to an interval using something like ``minimum ... on [a,b]''. However, I am generally uncomfortable with these functions, I have had them give me inaccurate answers. It's better to find critical points and do careful analysis.

\item[Piecewise Defined Functions] We need to use piecewise defined functions in several problems. Unfortunately, Alpha does not handle these well at all (maybe improvements will be made with time). Currently to enter a piecewise defined function, we must use Mathematica syntax. For example, the function
$\displaystyle f(x) = \left\{\begin{array}{ccc} x^2 & & x < -2 \\ -2x & & -2 \leq x < 0 \\ e^{x/10} & & x \geq 0 \end{array} \right.$ can be entered as

\vspace{\SPACE}

\verb|piecewise[{{x^2,x<-2},{-2x,-2<=x<0},{e^(x/10),x>=0}}]| \href{https://www.wolframalpha.com/input/?i=piecewise[{{x^2%2Cx%3C-2}%2C{-2x%2C-2%3C%3Dx%3C0}%2C{e^%28x%2F10%29%2Cx%3E%3D0}}]}{\ALPHA}

\vspace{\SPACE}

Alpha is pretty bad about doing anything to a piecewise defined function. Dervatives don't seem to want to work. However, you can coax Alpha to do this
by using ``D[piecewise[....]]'' but even this has issues. Integration, plotting, and plugging in values all seem to work just fine. 

\vspace{\SPACE}

\verb|int piecewise[{{x^2,x<-2},{-2x,-2<=x<0},{e^(x/10),x>=0}}] from x=-4 to 4| \href{https://www.wolframalpha.com/input/?i=int+piecewise[{{x^2%2Cx%3C-2}%2C{-2x%2C-2%3C%3Dx%3C0}%2C{e^%28x%2F10%29%2Cx%3E%3D0}}]+from+x%3D-4+to+4}{\ALPHA}

\vspace{\SPACE}

\verb|plot piecewise[{{x^2,x<-2},{-2x,-2<=x<0},{e^(x/10),x>=0}}] on [-4,10]| \href{https://www.wolframalpha.com/input/?i=plot+piecewise[{{x^2%2Cx%3C-2}%2C{-2x%2C-2%3C%3Dx%3C0}%2C{e^%28x%2F10%29%2Cx%3E%3D0}}]+on+[-4%2C10]}{\ALPHA}

\vspace{\SPACE}

\verb|piecewise[{{x^2,x<-2},{-2x,-2<=x<0},{e^(x/10),x>=0}}] where x=-3| \href{https://www.wolframalpha.com/input/?i=piecewise[{{x^2%2Cx%3C-2}%2C{-2x%2C-2%3C%3Dx%3C0}%2C{e^%28x%2F10%29%2Cx%3E%3D0}}]+where+x%3D-3}{\ALPHA}

\vspace{\SPACE}

Beware, Alpha doesn't like us trying to plug in  a list of values ``piecewise[....] where $x=[-3,0,1,2]$'' doesn't work. Since differentiation does not work (or at least it doesn't work easily) we must find the derivative of each formula individually. If we do this, we must be careful to throw out roots of derivatives that occur outside the domain of that formula.
For example, in our function above, the formula $x^2$ has a critical point at $x=0$ (since the derivative is $2x$ which is 0 at $x=0$). However, we only use the
formula $x^2$ when $x<-2$. This means that while $x=0$ is a critical point of $y=x^2$, it is not a critical point of our piecewise defined function. In general, if we 
have trouble preforming an operation on a piecewise defined function, we should just perform the operation on each piece --- when in doubt, deal with piecewise functions one piece at a time.

Also, just for the record, the syntax for ``piecewise'' is as follows:\\ piecewise[\{\{formula, condition\}, \dots, \{formula, condition\}\} \fbox{, optional catch-all case} ]

\item[The Normal Distribution] Alpha knows definitions for many things including the normal distribution. To access this information we merely type ``\href{https://www.wolframalpha.com/input/?i=normal+distribution}{normal distribution}''. If we scroll down, Alpha displays a formula for the correspoding probability density function. In general, if you move your mouse to the corner of a box, Alpha will act like you're lifting up the edge of a piece of paper. ``Underneath'' you have options such as ``Save as image'' and ``Copyable plaintext''. Clicking on the ``copyable plaintext'' button pops up a box with (one possibility for) the proper syntax for entering the normal distribution's density function. Using ``Ctrl-C'' and ``Ctrl-V'' we can copy and paste this information into Alpha's command line. 

After pasting the density function into the command line, we will need to replace ``mu'' and ``'sigma'' with the mean and standard deviation (given in whatever problem we're working on). For example, if $\mu=3$ and $\sigma=4$, we'll have

\vspace{\SPACE}

\verb|e^(-(x-3)^2/(2 4^2))/(sqrt(2 pi) 4)| \href{https://www.wolframalpha.com/input/?i=e^%28-%28x-3%29^2%2F%282+4^2%29%29%2F%28sqrt%282+pi%29+4%29}{\ALPHA}

\vspace{\SPACE}

Then to find the probability $x$ is at least 5, we would type

\vspace{\SPACE}

\verb|int e^(-(x-3)^2/(2 4^2))/(sqrt(2 pi) 4) from 5 to infinity| \href{https://www.wolframalpha.com/input/?i=int+e^%28-%28x-3%29^2%2F%282+4^2%29%29%2F%28sqrt%282+pi%29+4%29+from+5+to+infinity}{\ALPHA}

\vspace{\SPACE}

If we need to find what number would give us a bound $y$ such that we have a $0.25$ probability that $x$ is below $y$, we would type

\vspace{\SPACE}

\verb|int e^(-(x-3)^2/(2 4^2))/(sqrt(2 pi) 4) from -infinity to y| \href{https://www.wolframalpha.com/input/?i=int+e^%28-%28x-3%29^2%2F%282+4^2%29%29%2F%28sqrt%282+pi%29+4%29+from+-infinity+to+y}{\ALPHA}

\vspace{\SPACE}

Then we would need to copy the result: $\displaystyle \frac{1}{2} \left( \mathrm{erf}\left(\frac{y-3}{4\sqrt{2}}\right)+1\right)$  (move your mouse to the corner to
lift up the flap and then choose ``copyable plaintext'' and copy/paste the right-hand-side of the equation). Then we need to set this result equation to $0.25$... 

\vspace{\SPACE}

\verb|1/2 (erf((y-3)/(4 sqrt(2)))+1) = 0.25| \href{https://www.wolframalpha.com/input/?i=1%2F2+%28erf%28%28y-3%29%2F%284+sqrt%282%29%29%29%2B1%29+%3D+0.25}{\ALPHA}

\vspace{\SPACE}

Alpha happily solves our equation and tells us that $y \approx 0.302041$. Therefore, there is a $0.25$ probability that $x$ is below $0.302041$.

Sometimes we can get Alpha to do this kind of task in one step such as ``(int ... from -infinity to y) = 0.25'. However, in this case Alpha gets confused. 
In general, if Alpha is giving you a hard time, try splitting your task up into simpler steps.
\end{description}
\end{document}
