Hi, I need to find all possible solutions of the equation
a^2+b^2+c^2+d^2=1, the values of the variables (a/b/c/d)
will be within the range -1 to +1. It would be nice if
anyone please help in this regard. Thanks a lot in advance.
"Rakib " <rakahmed@gmail.com> wrote in message <g5hbqj$rj5
$1@fred.mathworks.com>...
> Hi, I need to find all possible solutions of the equation
> a^2+b^2+c^2+d^2=1, the values of the variables (a/b/c/d)
> will be within the range -1 to +1. It would be nice if
> anyone please help in this regard. Thanks a lot in advance.
If this single equation is the only condition satisfied by a, b, c, and d, then
what you call "all possible roots" is a three-dimensional infinite continuum of
points. It is the hypersurface of a hypersphere in four dimensions with unit
radius. The set of "roots" is a high order of infinity in cardinality.
Even with matlab's finite number of possible double precision floating point
numbers, the total number of approximate quadruplet solutions would be
astronomically large. There would never be time enough to list them all, not
even if you continued to run your computer until the universe had suffered a
complete heat death.
Of course if you wish to restrict the roots to, say, integral values, that is an
entirely different story. I would say there are exactly eight such roots.
"Roger Stafford"
<ellieandrogerxyzzy@mindspring.com.invalid> wrote in
message <g5hdmh$is9$1@fred.mathworks.com>...
> "Rakib " <rakahmed@gmail.com> wrote in message
<g5hbqj$rj5
> $1@fred.mathworks.com>...
> > Hi, I need to find all possible solutions of the
equation
> > a^2+b^2+c^2+d^2=1, the values of the variables
(a/b/c/d)
> > will be within the range -1 to +1. It would be nice if
> > anyone please help in this regard. Thanks a lot in
advance.
>
> If this single equation is the only condition
satisfied by a, b, c, and d, then
> what you call "all possible roots" is a three-
dimensional infinite continuum of
> points. It is the hypersurface of a hypersphere in four
dimensions with unit
> radius. The set of "roots" is a high order of infinity
in cardinality.
>
> Even with matlab's finite number of possible double
precision floating point
> numbers, the total number of approximate quadruplet
solutions would be
> astronomically large. There would never be time enough
to list them all, not
> even if you continued to run your computer until the
universe had suffered a
> complete heat death.
>
> Of course if you wish to restrict the roots to, say,
integral values, that is an
> entirely different story. I would say there are exactly
eight such roots.
>
> Roger Stafford
>
Dear Roger,
Thanks for the helpful info. Actually, I should write I
want to restrict the roots to values like .1,.2...1.
Thanks.
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
wrote in message <g5hdmh$is9$1@fred.mathworks.com>...
> If this single equation is the only condition satisfied
by a, b, c, and d, then
> what you call "all possible roots" is a three-dimensional
infinite continuum of
> points. It is the hypersurface of a hypersphere in four
dimensions with unit
> radius.
Wasn't actually the size of our own universe? All you need
is to show that the universe doesn't have hole. Perelman has
done the rest.
"Bruno Luong" <b.luong@fogale.fr> wrote in message <g5hgf0
$h8t$1@fred.mathworks.com>...
> "Roger Stafford"
<ellieandrogerxyzzy@mindspring.com.invalid>
> wrote in message <g5hdmh$is9$1@fred.mathworks.com>...
>
> > If this single equation is the only condition
satisfied
> by a, b, c, and d, then
> > what you call "all possible roots" is a three-
dimensional
> infinite continuum of
> > points. It is the hypersurface of a hypersphere in
four
> dimensions with unit
> > radius.
>
> Wasn't actually the size of our own universe? All you
need
> is to show that the universe doesn't have hole. Perelman
has
> done the rest.
>
> Bruno
>
Couldn't get it, it would be nice if you please make it a
little clear.
"Rakib " <rakahmed@gmail.com> wrote in message
<g5hl4n$1bf$1@fred.mathworks.com>...
> >
> Couldn't get it, it would be nice if you please make it a
> little clear.
The equation you wrote is actually same as the equation that
describes a possible shape of universe (hypersphere in 3d).
Listing all the roots of your equations is like listing all
the possible locations in the universe (I let you imagine
the task). Don't foget that your computer belongs to the
universe itself, so a modest task of listing all the
physical location within your computer is already
practically impossible (possible only if 100% of space if
efficiently used, which is of course not true).
Grigory Perelman is a mathematician that has proved recently
a century old Point Carr? conjecture, one way to check the
shape of the universe is such.
"Bruno Luong" <b.luong@fogale.fr> wrote in message
<g5hmuq$pik$1@fred.mathworks.com>...
> "Rakib " <rakahmed@gmail.com> wrote in message
> <g5hl4n$1bf$1@fred.mathworks.com>...
>
> > >
> > Couldn't get it, it would be nice if you please make it a
> > little clear.
>
> The equation you wrote is actually same as the equation that
> describes a possible shape of universe (hypersphere in 3d).
> Listing all the roots of your equations is like listing all
> the possible locations in the universe (I let you imagine
> the task). Don't foget that your computer belongs to the
> universe itself, so a modest task of listing all the
> physical location within your computer is already
> practically impossible (possible only if 100% of space if
> efficiently used, which is of course not true).
>
> Grigory Perelman is a mathematician that has proved recently
> a century old Point Carr? conjecture, one way to check the
> shape of the universe is such.
>
> Bruno
>
You could generate random numbers on the hypersphere
like this:
dim=4; % number of dimensions
n=10; % number of points on hyper sphere
x=randn(n,dim);
%--- normalize them to be on the hypersphere
%--- you may fix the case if all x=0...
x=x./(sqrt(sum(x.^2'))'*ones(1,dim));
"Per Sundqvist" <sunkan@fy.chalmers.se> wrote in message
<g5hts2$g8$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.fr> wrote in message
> <g5hmuq$pik$1@fred.mathworks.com>...
> > "Rakib " <rakahmed@gmail.com> wrote in message
> > <g5hl4n$1bf$1@fred.mathworks.com>...
> >
> > > >
> > > Couldn't get it, it would be nice if you please make it a
> > > little clear.
> >
> > The equation you wrote is actually same as the equation that
> > describes a possible shape of universe (hypersphere in 3d).
> > Listing all the roots of your equations is like listing all
> > the possible locations in the universe (I let you imagine
> > the task). Don't foget that your computer belongs to the
> > universe itself, so a modest task of listing all the
> > physical location within your computer is already
> > practically impossible (possible only if 100% of space if
> > efficiently used, which is of course not true).
> >
> > Grigory Perelman is a mathematician that has proved recently
> > a century old Point Carr? conjecture, one way to check the
> > shape of the universe is such.
> >
> > Bruno
> >
>
> You could generate random numbers on the hypersphere
> like this:
>
> dim=4; % number of dimensions
> n=10; % number of points on hyper sphere
> x=randn(n,dim);
> %--- normalize them to be on the hypersphere
> %--- you may fix the case if all x=0...
> x=x./(sqrt(sum(x.^2'))'*ones(1,dim));
>
> %test
> j=1;
> x(j,1)^2+x(j,2)^2+x(j,3)^2+x(j,4)^2
>
A parametric analytic solution exist in terms of the
hyperspherical coordinates (they are angles in range 0,2pi,
except the last angel whis is 0,pi). Read about it here: http://en.wikipedia.org/wiki/Hypersphere
"Rakib " <rakahmed@gmail.com> wrote in message
<g5hfvm$d80$1@fred.mathworks.com>...
> "Roger Stafford"
> <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
> message <g5hdmh$is9$1@fred.mathworks.com>...
> > "Rakib " <rakahmed@gmail.com> wrote in message
> <g5hbqj$rj5
> > $1@fred.mathworks.com>...
> > > Hi, I need to find all possible solutions of the
> equation
> > > a^2+b^2+c^2+d^2=1, the values of the variables
> (a/b/c/d)
> > > will be within the range -1 to +1. It would be nice if
> > > anyone please help in this regard. Thanks a lot in
> advance.
(snip)
> > Of course if you wish to restrict the roots to, say,
> integral values, that is an
> > entirely different story. I would say there are exactly
> eight such roots.
> >
> > Roger Stafford
> >
> Dear Roger,
> Thanks for the helpful info. Actually, I should write I
> want to restrict the roots to values like .1,.2...1.
Then scale by a factor of 100.
You are now looking for all (positive) integer
solutions of the equation
a^2+b^2+c^2+d^2=100
This is a form of nonlinear diophantine
problem, but a simple one, since exhaustive
calculation will solve it. Use ndgrid, and test
all combinations. Could take about 3 or 4 lines
of MATLAB code.
I get 43 total solutions, of which 5 are actually
distinct solutions if I discard those which are
only permutations of another solution.
"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g5hvem$f2r$1@fred.mathworks.com>...
> "Rakib " <rakahmed@gmail.com> wrote in message
> <g5hfvm$d80$1@fred.mathworks.com>...
> > "Roger Stafford"
> > <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
> > message <g5hdmh$is9$1@fred.mathworks.com>...
> > > "Rakib " <rakahmed@gmail.com> wrote in message
> > <g5hbqj$rj5
> > > $1@fred.mathworks.com>...
> > > > Hi, I need to find all possible solutions of the
> > equation
> > > > a^2+b^2+c^2+d^2=1, the values of the variables
> > (a/b/c/d)
> > > > will be within the range -1 to +1. It would be
nice if
> > > > anyone please help in this regard. Thanks a lot in
> > advance.
>
> (snip)
>
> > > Of course if you wish to restrict the roots to,
say,
> > integral values, that is an
> > > entirely different story. I would say there are
exactly
> > eight such roots.
> > >
> > > Roger Stafford
> > >
> > Dear Roger,
> > Thanks for the helpful info. Actually, I should write
I
> > want to restrict the roots to values like .1,.2...1.
>
> Then scale by a factor of 100.
>
> You are now looking for all (positive) integer
> solutions of the equation
>
> a^2+b^2+c^2+d^2=100
>
> This is a form of nonlinear diophantine
> problem, but a simple one, since exhaustive
> calculation will solve it. Use ndgrid, and test
> all combinations. Could take about 3 or 4 lines
> of MATLAB code.
>
> I get 43 total solutions, of which 5 are actually
> distinct solutions if I discard those which are
> only permutations of another solution.
>
> John
Thank you so much for the constructive helps. Can you
please check whether the following lines do:
[a,b,c,d]=ndgrid(-1:.1:1,-1:.1:1,-1:.1:1,-1:.1:1);
z=1-a^2-b^2-c^2-d^2;
Thanks again.
"Rakib " <rakahmed@gmail.com> wrote in message
<g5i135$8en$1@fred.mathworks.com>...
> Thank you so much for the constructive helps. Can you
> please check whether the following lines do:
> [a,b,c,d]=ndgrid(-1:.1:1,-1:.1:1,-1:.1:1,-1:.1:1);
> z=1-a^2-b^2-c^2-d^2;
> Thanks again.
I see you did not listen. Multiply by
100. Or, multiply your variables by 10.
Either way, you need to turn this into a
problem of integers. If you do not do
this, your next (confused) post will be
something to the effect of "Why does
MATLAB not give me the correct
answers?"
Then there will be along list of
responses explaining floating point
arithmetic to you, and why you should
never test for exact equality in floating
point arithmetic.
Once you have done this, why not try it
yourself? If you think it will work, why
not test the relevant code fragment in
MATLAB? This is the best way to learn.
"Rakib " <rakahmed@gmail.com> wrote in message <g5i135$8en
$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> message <g5hvem$f2r$1@fred.mathworks.com>...
> > I get 43 total solutions, of which 5 are actually
> > distinct solutions if I discard those which are
> > only permutations of another solution.
> > John
>
> Thank you so much for the constructive helps. Can you
> please check whether the following lines do:
> [a,b,c,d]=ndgrid(-1:.1:1,-1:.1:1,-1:.1:1,-1:.1:1);
> z=1-a^2-b^2-c^2-d^2;
> Thanks again.
I get the following seven types of exact solution:
a b c d
.0 .0 .0 1
.0 .0 .6 .8
.1 .1 .7 .7
.1 .3 .3 .9
.1 .5 .5 .7
.2 .4 .4 .8
.5 .5 .5 .5
With all possible permutations and sign reversals this would be 744 distinct
solutions. (Of course the trouble with calling these exact is that matlab's
double cannot exactly represent any of the values .1, .2, .3, .4, .6, .7, .8, and .
9.)
"Roger Stafford"
<ellieandrogerxyzzy@mindspring.com.invalid> wrote in
message <g5i6je$8gt$1@fred.mathworks.com>...
> "Rakib " <rakahmed@gmail.com> wrote in message <g5i135$8en
> $1@fred.mathworks.com>...
> > "John D'Errico" <woodchips@rochester.rr.com> wrote in
> > message <g5hvem$f2r$1@fred.mathworks.com>...
> > > I get 43 total solutions, of which 5 are actually
> > > distinct solutions if I discard those which are
> > > only permutations of another solution.
> > > John
> >
> > Thank you so much for the constructive helps. Can you
> > please check whether the following lines do:
> > [a,b,c,d]=ndgrid(-1:.1:1,-1:.1:1,-1:.1:1,-1:.1:1);
> > z=1-a^2-b^2-c^2-d^2;
> > Thanks again.
>
> I get the following seven types of exact solution:
>
> a b c d
> .0 .0 .0 1
> .0 .0 .6 .8
> .1 .1 .7 .7
> .1 .3 .3 .9
> .1 .5 .5 .7
> .2 .4 .4 .8
> .5 .5 .5 .5
>
> With all possible permutations and sign reversals this
would be 744 distinct
> solutions. (Of course the trouble with calling these
exact is that matlab's
> double cannot exactly represent any of the
values .1, .2, .3, .4, .6, .7, .8, and .
> 9.)
I got 744 distinct solutions too. It's kind of interesting
to knock the problem down to 3D or 2D to see where the
solutions lie when plotted.
Thanks, everyone. Seems you have got it, however, I am
still struggling to code it. Hope to find it after a few
try. Thanks once again.
"Steve Amphlett" <Firstname.Lastname@Where-I-Work.com>
wrote in message <g5i765$g86$1@fred.mathworks.com>...
> "Roger Stafford"
> <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
> message <g5i6je$8gt$1@fred.mathworks.com>...
> > "Rakib " <rakahmed@gmail.com> wrote in message <g5i135
$8en
> > $1@fred.mathworks.com>...
> > > "John D'Errico" <woodchips@rochester.rr.com> wrote
in
> > > message <g5hvem$f2r$1@fred.mathworks.com>...
> > > > I get 43 total solutions, of which 5 are actually
> > > > distinct solutions if I discard those which are
> > > > only permutations of another solution.
> > > > John
> > >
> > > Thank you so much for the constructive helps. Can
you
> > > please check whether the following lines do:
> > > [a,b,c,d]=ndgrid(-1:.1:1,-1:.1:1,-1:.1:1,-1:.1:1);
> > > z=1-a^2-b^2-c^2-d^2;
> > > Thanks again.
> >
> > I get the following seven types of exact solution:
> >
> > a b c d
> > .0 .0 .0 1
> > .0 .0 .6 .8
> > .1 .1 .7 .7
> > .1 .3 .3 .9
> > .1 .5 .5 .7
> > .2 .4 .4 .8
> > .5 .5 .5 .5
> >
> > With all possible permutations and sign reversals this
> would be 744 distinct
> > solutions. (Of course the trouble with calling these
> exact is that matlab's
> > double cannot exactly represent any of the
> values .1, .2, .3, .4, .6, .7, .8, and .
> > 9.)
>
> I got 744 distinct solutions too. It's kind of
interesting
> to knock the problem down to 3D or 2D to see where the
> solutions lie when plotted.
>
"Steve Amphlett" <Firstname.Lastname@Where-I-Work.com> wrote
in message <g5i765$g86$1@fred.mathworks.com>...
> "Roger Stafford"
> <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
> message <g5i6je$8gt$1@fred.mathworks.com>...
> > "Rakib " <rakahmed@gmail.com> wrote in message <g5i135$8en
> > $1@fred.mathworks.com>...
> > > "John D'Errico" <woodchips@rochester.rr.com> wrote in
> > > message <g5hvem$f2r$1@fred.mathworks.com>...
> > > > I get 43 total solutions, of which 5 are actually
> > > > distinct solutions if I discard those which are
> > > > only permutations of another solution.
> > > > John
> > >
> > > Thank you so much for the constructive helps. Can you
> > > please check whether the following lines do:
> > > [a,b,c,d]=ndgrid(-1:.1:1,-1:.1:1,-1:.1:1,-1:.1:1);
> > > z=1-a^2-b^2-c^2-d^2;
> > > Thanks again.
> >
> > I get the following seven types of exact solution:
> >
> > a b c d
> > .0 .0 .0 1
> > .0 .0 .6 .8
> > .1 .1 .7 .7
> > .1 .3 .3 .9
> > .1 .5 .5 .7
> > .2 .4 .4 .8
> > .5 .5 .5 .5
> >
> > With all possible permutations and sign reversals this
> would be 744 distinct
> > solutions. (Of course the trouble with calling these
> exact is that matlab's
> > double cannot exactly represent any of the
> values .1, .2, .3, .4, .6, .7, .8, and .
> > 9.)
>
> I got 744 distinct solutions too. It's kind of interesting
> to knock the problem down to 3D or 2D to see where the
> solutions lie when plotted.
>
Yes, it could perhaps also be understood in terms of exact
trigonometric angles, using hypersphere angles:
"Rakib " <rakahmed@gmail.com> wrote in message
<g5i8ps$70j$1@fred.mathworks.com>...
> Thanks, everyone. Seems you have got it, however, I am
> still struggling to code it. Hope to find it after a few
> try. Thanks once again.
I've uploaded a new version of my partitions.m,
that will solve your problem. It should appear
on the FEX sometime tomorrow.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.