P3
Math 2984 - Fall 2017
Intro to Mathematical Problem Solving


Project Task #3: Write a MATLAB function that determines the probability that a random quadratic polynomial q(x)=ax^2+bx+c will have real roots. Do this calculation WITHOUT using a FOR loop!


COMMENT: Assume that the coefficients a, b, and c are generated from the randn() function.

Normally, your procedure would be:

      initialize p to 0.
      for i = 1 : m
        generate a, b, c, using randn();
        determine if q(x) has real roots.
        if real roots, increase p by 1.
      end
      p = p / m
      

However, you need to do this calculation without using a FOR loop. Instead, you should use vector operations.


INSTRUCTIONS:

        Write a function header with input M and output P.

        function p = p3 ( m )
          a = ( a vector of M values produced by randn )
          b = (similar)
          c = (similar)
          d = a quantity whose value determines whether there are real roots
          i = logical vector that checks which entries of d have the "right" value
          p = how many entries in i correspond to real roots
          p = p / m
          return
        end
      


CHECK: If your code is correct, then as M increases, you should expect the value of the probability p to be about 0.64


SUBMIT: Your function file should be called "p3.m", and should begin with:

        % p3.m
        % YOUR NAME
        % This script (describe what it does)