[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sets: predicate notation in Octave
From: |
Juan Pablo Carbajal |
Subject: |
Re: Sets: predicate notation in Octave |
Date: |
Wed, 24 Dec 2014 12:17:23 +0100 |
On Tue, Dec 23, 2014 at 10:11 PM, Hugh Mayfield
<address@hidden> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi there,
>
> I mentioned this in the IRC channel but the girls / guys there didn't
> know, so asking again here. Have had a look at the manual and FAQ.
>
> I have Maths coursework to do over the holidays. One of the questions
> involves working with sets: working out intersections and
> subtractions. The difficult bit is working out how to tell Octave
> what the various subsets contain, without spelling it out value by
> value (don't think lecturer would be impressed with that). One of the
> subsets is something like (in mathematical notation, which I don't
> think I can reproduce in a plain text email):
>
> (x: x > 0, x <= 30, x is a member of set N)
>
> where "N" is the symbol representing the natural numbers.
>
> If someone could help me out with how to code this in Octave, would be
> really grateful. I'm trying to make a stand on campus against
> proprietary software, and we are required to use online solvers or
> mathematical software to evidence our work, so really hoping to use
> Octave.
>
> Regards,
>
> Hugh
>
> - --
> Hugh Mayfield
> mayfield.motd.org
> Public key 7819F5A7 - please use encryption and digital signing
> emailselfdefense.fsf.org - prism-break.org - fsf.org - gnu.org
> Please try not to email me from platforms like Google or Microsoft
> Please don't upload photos of me to Facebook
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
>
> iQIcBAEBAgAGBQJUmdp3AAoJEE5eVyd4GfWnsd4QAK9WQTIZsMPOyn2ouxjArCbb
> fzKzXlm/JBQJco8vo6+o9auYnpKG78sIpLPMuLtTICkRsFC13Y/0iwJdeKJtZ1SR
> A8FMSwpxvoTMXMICxOHcIRWKhCw1dwHLJWOXDSAVz7nVwLSM6UHRW34U2YfzTmYK
> czru3aFq+oUqf9zVH2zPC4gAlkwIfDZzB2aTE0pW2G77LT7Cw1BNmPsqmm20Te+v
> WPNgUjzgyfVnWbs4Ah32NfJKY77CR/lo2rb9Lt96Vck4ez3SzbKrBdaRxaVuk2ht
> XHH4u2pLnGJJjYNF3/nLR1LEYnCLiY2JioqD1O96G/u2Dv33S3S/DAfftlv7cyv7
> OV05VnUskJgIJCxmVb0LJvSJ5lHupVSRPSkFgaSiuIuuQP+fQUDylQ2cOGFRi4Ld
> FOAtkFvFAx9obfxPmPGSrgusAsYuSifx8ScMBw1TObDfTEYF4bT1ZQi78p1dBb6B
> uDmVdhYEMh+tfreOcUdNIG+ce1laRhMBSUl6qvWC3wf5gWdz669UjXrqb9RrHuIx
> 9VGy/AokOgIZYyv/xTnIzOrJ6xiipFRKL3flq98qzyhoS5jIzprJTyIfdQrwareY
> 3IEeBp2pl3P7eyqdCe3FE8y9Scg1i0BXDOkVnqWHXwS/LLh2rPzn8I8zN/hBwCI2
> lrLNxaKpgBXHRz9uvlN7
> =pzEr
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave
Hi Hugh,
I do not think it is easy to make sets comprehension in Octave. You
can use functions to do it but at the end I think it is likely the
manipulation will be in the actual elements of the set.
The set you describe is simply x = 1:30 but this is indeed enumerating
the elements of the set.
The other thing you can do is to define the characteristic function
(indicator function) of the given set, for your example
X = @(x) x>0 & x<=30 & x-fix(x) == 0
and see if you can work with this representation. If you want to
operate on these type of functions, I think you will have to define a
new class that implements the properties of these functions
(https://en.wikipedia.org/wiki/Indicator_function#Basic_properties)
...just by looking at it it seems quite some work, but maybe it isn't.
Is it an option to use geometry to work with the sets?
If your sets can be represented in the line or in the plane, then you
could associate geometrical entities to them and work with the
geometry package. Just an idea.
What kind of set do you expect to encounter? Only numerical sets? Or
would you also have sets describe din natural language? If the last
case also happens who will do the translation in to numbers, strings
or any other object that can be manipulated in Octave?
Finally, once you can more or less define with what type of sets you
will be working, you should decide whether Octave is the best tool.
Octave is meant for numerical computations, you can stretch that a
little bit, but you better choose the right tool if you want to
convince somebody.
Consider functional programming languages, Python or other languages
that have a more general scope than Octave.