# Examples for input function questions¶

\begin{variables}
\function{f}{x^4-5x^3+4x^2+3x+7}        % defines a function named f
\derivative{f_1}{f}{x}
\derivative{f_2}{f_1}{x}
\derivative{f_3}{f_2}{x}
\functionNormalize{f_1}     % Simplify the function f_1
\functionNormalize{f_2}
\functionNormalize{f_3}
\end{variables}

\begin{question}
\text{\textbf{Step 1}\\
\textit{Let f(x) = $f$.} \\
\textit{Compute f':}}
\explanation{Calculate the derivative of f}
\type{input.function}

\text{ f'(x) = }
\solution{f_1}
\checkAsFunction{x}{-10}{10}{100}       %The syntax is given by \checkAsFunction{ variable}{ min}{ max}{ steps}.
\end{question}

\begin{question}
\text{\textbf{Step 2}\\ \textit{Compute f''(x):}}
\explanation{Calculate the derivative of f'}
\type{input.function}

\begin{variables}
\end{variables}

\text{ f''(x) = }
\solution{f_2}
\checkAsFunction{x}{-10}{10}{100}

\end{question}

\begin{question}
\text{\textbf{Step 3}\\ \textit{Compute f'''(x):}}
\explanation{Calculate the derivative of f''}
\type{input.function}

\begin{variables}
\end{variables}

\text{ f'''(x) = }
\solution{f_3}
\checkAsFunction{x}{-10}{10}{100}

\end{question}


\begin{question}
\type{input.function}
\field{real}

\begin{variables}
\function{c}{sqrt(2x^2+1)}
\function{f}{sqrt(y)}
\function{g}{2x^2+1}
\end{variables}

\text{\textbf{Question 2}\\
\textit{Enter two functions f and g, such that their composition is $c$.}}
\explanation{Shows up in the correction in case the students answer is wrong.}

\text{ f(y) = } % this function by itself is neither correct nor incorrect.
\solution{f}
\inputAsFunction{y}{h}

\text{ g(x) = } % truth can only be checked be checking the compostition of the two functions.
\solution{g}
\inputAsFunction{x}{k}
\checkFuncForZero{h[k]-c}{-10}{10}{100}
\score{2.0}

\text{ f[g[x]] = }
\solution{c}
\checkAsFunction{x}{-10}{10}{100}
\score{0.5}
\end{question}


\begin{question}
\type{input.function}
\field{real}
\text{\textbf{Question 3}\\\textit{Find an anti-derivative F of $g$}}
\explanation{}

\begin{variables}
\function{f}{-cos(7x)}
\function{g}{7sin(7x)}
\end{variables}

\text{ F(x) = }
\solution{f}
\inputAsFunction{x}{k}
\checkFuncForZero{D[k]-g}{-10}{10}{100}
\end{question}


\begin{question}

\begin{variables}
\randint{a}{2}{5}
\function{f}{sinh(a#4x)} % a#4 stands for a to the power 1/4.
\end{variables}

\type{input.function}
\field{real}
\text{\textbf{Question 4}\\
\textit{Find a non-zero solution of the differential equation y^{(4)} = $a$y}}

\text{ y(x) = }
\solution{f}
\inputAsFunction{x}{k}
\checkFuncForZero{|D[D[D[D[k]]]]-a*k| + |1-abs(sign(k))|}{-10}{10}{100}, % Composition of 2 functionals:
% checks y^{(4)} = $a$y and $y$ non-zero.
\end{question}


\begin{question}
\type{input.function}
\field{integer}

\begin{variables} % In the following the pythagorean numbers are parametrized.
\randint{u}{1}{10}
\randint{v}{1}{10}

\randadjust{u,v}{u=v} % see Part 9 http://team.mumie.net/projects/support/wiki/GenericTexProblems

\function{f}{u*u+v*v}       % note: in fact this is a number resp. a constant function.
\functionNormalize{f} % Simplifies the expression as much as possible.
\function{a}{|u*u-v*v|}
\functionNormalize{a}
\function{b}{2*u*v}
\functionNormalize{b}
\end{variables}

\text{\textbf{Question 5}\\\textit{Find a pythagorean triangle with hypotenuse c = $f$.}\\
Note: By definition a\ne 0 and b \ne 0. }

\text{ a = }
\solution{a}
\inputAsFunction{x}{k}