%Defining, Evaluating, and Plotting Functions (Sample Solution) %Math263A \documentclass[12pt]{article} \usepackage{times} \pagestyle{empty} \addtolength{\textwidth}{1.2in} \addtolength{\textheight}{1.2in} \addtolength{\oddsidemargin}{-.58in} \addtolength{\evensidemargin}{-.58in} \renewcommand{\baselinestretch}{1.0} \parindent = 0cm \parskip = .1cm \begin{document} \thispagestyle{empty} \begin{center} {\Large Defining, Evaluating, and Plotting Functions\footnote{ Copyright \copyright 2002 Todd Young. All rights reserved. Please address comments to young@math.ohiou.edu.}} \end{center} \textbf{Sample Solution} \begin{enumerate} \item The command \verb& syms x & declares \verb$x$ to be a symbolic variable. The command\\ \verb& f = sin(x) & makes \verb$f$ the symbolic function $\sin x$. \item The command \verb& subs(f,2) & numerically evaluates \verb$f(2)$. \\The command \verb& subs(f,'2') & symbolically evaluates \verb$f(2)$. \\The command \verb& double(ans) & numerically evaluates \verb&ans&, in this case $\sin 2$. \\(Note. \verb&double(ans)& does not mean \verb$2 * ans$; \verb&double& is short for double precision.) \item The command \verb& ezplot(f) & plots $y = \sin x$ using a default domain interval. \item First, we plot $y = exp(x) = e^x$ using a default domain interval. Second, we plot\\ $y = exp(x)$ using the domain interval [-2, 2]. \item This plots $y = x^2$ using a default domain interval. \item \begin{enumerate} \item For $x$ not too close to $0$, $\sqrt{x^2 - .00001} \approx \sqrt{x^2} = \verb$|$x\verb$|$$, and this is what the graph looks like using the default domain interval. However, if \verb$|$$x$\verb$|$ is close enough to 0, then the graph looks different (in fact, $\sqrt{x^2 - .00001}$ is not a real number if $x^2 < .00001$.) Some distinctive features of the graph are not apparent, because of the scale that \textsc{MatLab} chooses. \item The value of \verb$|$${x^7 - x}$\verb$|$ is relatively large for relatively small \verb$|$$x$\verb$|$. For example, \\$2^7 - 2 = 126$. Using the default domain it appears as though $x^7 - x = 0$ for $x$ in $[-1,1]$, which, of course, is \emph{not} the case. As in (b), some distinctive features of the graph are not apparent, because of the scale that \textsc{MatLab} chooses. \end{enumerate} \item \textsc{MatLab} plots function by locating points on the graph and connecting the points. \\If \verb& ezgraph & is used, \textsc{MatLab} will choose a default domain interval if one is not specified. If the true graph oscillates too rapidly, the computer may not fill in enough points to give an accurate representation. If the domain is not chosen properly, important features of the graph may be missed. Often, but not always, problems with plotting can be alleviated by choosing a different domain interval. \end{enumerate} \end{document}
View Site in Mobile | Classic
Share by: