Re: Roots of AX^2 + BX + C



In article
<56a4a5a7-4dad-4a56-859c-8f66cb0f25ad@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
nils_von_nostrand@xxxxxxxxx wrote:

Recently a student and I talked about the probability of the roots a
quadratic equation (AX^2 + B*X + C) to be complex. As we all know, the
roots will be complex if (B^2-4*A*C) is less than zero.

The student and I both thought that for any three randomly chosen
POSITIVE numbers, there is a 50% chance of (B^2-4*A*C) to be negative.
However, when I ran a small simulation using MATLAB, I found that the
roots are positive only 25% of the time. I ran the simulation several
times and the results are quite consistent.

Can someone please explain why three (uniformly distributed) randomly
chosen numbers, A, B, C would behave such that B^2-4*A*C is positive
for only 25% of the time ?


I suspect that your random number generator was not producing numbers
->uniformly<- distributed on the open interval from 0 to oo, which is
what you imply by "randomly chosen positive numbers".


In any case, it is the ratios A/B and C/B which will determine the sign
of (B^2 - 4*A*C), so you can set B = 1 and only worry about A and C.

But I am afraid that even MATLAB will have difficulty with generating
random members of a uniform distribution on (0,oo).

Thank you

(faculty member in Mechanical Engineering)


MATLAB code follows:
% an m-file to check b^2-4ac
clear all;
close all;

rand('twister',sum(100*clock));

N = 1000; % number of sample points
randarray = rand(3*N,1);

A = randarray(1:N);
B = randarray(N+1:2*N);
C = randarray(2*N+1:3*N);

R = B.^2-4*A.*C;
LA1 = R>0; %Logical array in MATLAB.

apositive = sum(LA1);
anegative = sum(~LA1);

apos_percent = (apositive/N)*100;
aneg_percent = (anegative/N)*100;


bar([apos_percent aneg_percent])
ylabel('pecentages');

[apos_percent aneg_percent]
.



Relevant Pages

  • Re: Solving polynomials faster with vectors?
    ... using vector calculations in MatLab (especially when using ... of a matrix or solving polynomial functions (roots) ... Thanks I will compare the roots method with eig, ...
    (comp.soft-sys.matlab)
  • Re: Solving polynomials faster with vectors?
    ... using vector calculations in MatLab (especially when using ... of a matrix or solving polynomial functions (roots) ... will have to be content with using 'roots' for your quintic equations. ...
    (comp.soft-sys.matlab)
  • Re: plotting a MATLAB function
    ... I am trying to plot an exponential function in MATLAB, ... to plot this funcion so I can find roots, but I am stuck on this early ... Anyway, if you're looking to find the roots of a polynomial, look at the ... FZERO (which is part of MATLAB itself) or FSOLVE (from Optimization ...
    (comp.soft-sys.matlab)
  • room impulse response analysis and polynomial factoring
    ... Thus i am using roots() a matlab funtion to compute ... seem to work well when i tested them with small polynomials as ...
    (comp.dsp)
  • room impulse response and polynomial factoring
    ... Thus i am using roots() a matlab funtion to compute ... seem to work well when i tested them with small polynomials as ...
    (comp.speech.research)