HW024
Math 2984 - Fall 2017
Intro to Mathematical Problem Solving


TASK: Estimate your chances of forming a triangle from 3 random numbers.


COMMENT: If X, Y and Z are the lengths of the sides of a triangle, then they must satisfy all three versions of the triangle inequality:

        X <= Y + Z
        Y <= X + Z
        Z <= X + Y
      
Suppose X, Y and Z are each set by calling MATLAB's rand() function. Then sometimes they could form a triangle, but sometimes not.

To estimate the probability of this occuring, we will do the experiment N times. If we let M count the number of times our random values form a triangle, then we want to report the value M/N at the end.


INSTRUCTIONS:

        Use the input() statement to get a value of n from the user.

        Initialze the variable "m" to zero.
 
        Start a for loop that repeats n times.

          Use rand() to set x, y, and z.

          if x, y, and z can form a triangle, increase m.
     
        end

        fprintf ( '  Using N=%d trials, estimated probability is %g\n', n, m / n );
      


CHECK: You want to use a large value of N to check your code, but as a guide, when I used N=10, I got an estimated probability of 0.6 which is not too far from the right answer.


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

        % hw024.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.