I am trying to create simple worksheets where students either: (a) see a randomly generated linear graph and must determine the equation or (b) are given a randomly generated linear equation and must plot the line.
How do I make the graph stay on the given portion of the plane? i.e. from -10 to 10 for both x and y.
Is there some "easy" way to do it, or do I have to use a formula that relates the randomly generated slope \m and y-intercept \b to an appropriate domain or range?
\documentclass{article}
\usepackage{pgf}
\pgfmathsetseed{\number\pdfrandomseed}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\newcommand{\LinearEquation}
{%
%slope
\pgfmathsetmacro{\m}{int(random(0,8)-4)}%
%y-intercept
\pgfmathsetmacro{\b}{int(random(0,8)-4)}%
% Linear Equation
\(y={\m}x+\b\)
}
\LinearEquation
\begin{tikzpicture}[scale=0.3]
\draw[help lines, gray, thin] (-10,-10) grid (10,10);
\draw[very thick,<->] (-10.3,0)--(10.3,0);
\draw[very thick,<->] (0,-10.3)--(0,10.3);
\draw[red, very thick, , range=-10:10, <->] plot (\x,\m*\x+\b); %this did not work
\end{tikzpicture}
\end{document}

