Re: Roots of AX^2 + BX + C
- From: Virgil <Virgil@xxxxxxxxx>
- Date: Wed, 22 Oct 2008 13:48:53 -0600
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]
- References:
- Roots of AX^2 + BX + C
- From: nils_von_nostrand
- Roots of AX^2 + BX + C
- Prev by Date: Re: inverse AGM
- Next by Date: Re: inverse AGM
- Previous by thread: Roots of AX^2 + BX + C
- Next by thread: Re: Roots of AX^2 + BX + C
- Index(es):
Relevant Pages
|