HW0092
Math 2984 - Fall 2017
Intro to Mathematical Problem Solving


TASK: Estimate the probability that a "random" quadratic equation will have real roots, using a FOR loop and the RAND() function.


COMMENT: A typical quadratic equation has the form:
\begin{align} y &= a x^2 + b x + c \end{align}
The roots of this equation can be written as
\begin{align} r &= \frac{-b \pm \sqrt { b^2 - 4ac } }{2a} \end{align}
and so the equation has real roots if, and only if

        b^2 - 4ac => 0
      

Suppose each of the coefficients a, b, and c are choose using MATLAB's rand() function. Then sometimes, the resulting equation will have real roots and sometimes not.

Use a FOR loop to run N cases. In each case, generate a, b and c using rand(), and then test whether the equation has real roots. Let M be the number of times the equation has real roots, and report the estimated probability as M/N.


INSTRUCTIONS:

        Use "input()" to get a value for N.
        Initialize M.

        Your FOR loop runs N times.
          Set the values A, B and C by calling rand().
          If the resulting equation has real roots, increase M.
        End your loop

        Print the value of M/N
      


CHECK: When you are ready to test your program, you should use a reasonably large value for N, such as 10,000 or more. It's hard to guess in advance what a good approximation to the answer will be. However, just as an example, if I run the program with just N = 20, I got an answer of 0.35. That is only a rough estimate, but now you probably know the answer should not be 0.0001 or 0.95!


SUBMIT: Your work should be stored in a script file called "hw0092.m". Your script file should begin with at least three comment lines:

        % hw0092.m
        % YOUR NAME
        % This script (describe what it does)
        % Add any comments here that you care to make.
      
If this problem is part of an assignment, then submit it to Canvas.