COMPLEX

Discussions related to mathematics, numerical methods, graph plotting etc.
pez
Posts: 4
Joined: Tue 03 Apr 2018, 15:38

COMPLEX

Post by pez »

Hello.

In order to talk, somehow seriously, about mathematics in a computer
language, we need to have access to data of type COMPLEX, at least.

Sincerely,

Petros Zimourtopoulos
guest

Re: COMPLEX

Post by guest »

pez wrote: Sat 05 Jan 2019, 21:23In order to talk, somehow seriously, about mathematics in a computer
language, we need to have access to data of type COMPLEX, at least.
I always use a structure for this:

Code: Select all

      DIM COMPLEX{r,i}
Then to declare COMPLEX 'variables' one can do:

Code: Select all

    DIM a{} = COMPLEX{}, b{} = COMPLEX{}
Assignments can be done directly:

Code: Select all

      a{} = b{}
To add two COMPLEX numbers one might write (where PROCcomplexadd will typically be in a library):

Code: Select all

      PROCcomplexadd(o{}, a{}, b{})
There are more examples of complex arithmetic using BBC BASIC at Rosetta Code. I wouldn't want to claim that it is as elegant or as fast as a language with a COMPLEX data type (like Fortran) but it's perfectly acceptable for many purposes, for example I have used it for working with Fourier Transforms.
pez
Posts: 4
Joined: Tue 03 Apr 2018, 15:38

Re: COMPLEX

Post by pez »

guest wrote: Sat 05 Jan 2019, 21:56 I always use a structure for this:
- ok ! - : ) - but I said : "seriously, somehow", didn't I ? - regards - pez
guest

Re: COMPLEX

Post by guest »

pez wrote: Sat 05 Jan 2019, 22:02I said : "seriously, somehow", didn't I ?
But you posted to a BBC BASIC forum, and the answer I gave is the most "serious" one relevant to BBC BASIC that I know of. You will be pleased to learn that my membership of this forum expires in about two weeks time, after which you will not be troubled by replies from me that you don't like.
pez
Posts: 4
Joined: Tue 03 Apr 2018, 15:38

Re: COMPLEX

Post by pez »

guest wrote: Sat 05 Jan 2019, 22:20 But you posted to a BBC BASIC forum, and the answer I gave is the most "serious" one relevant to BBC BASIC that I know of. You will be pleased to learn that my membership of this forum expires in about two weeks time, after which you will not be troubled by replies from me that you don't like.
.
- hello - i am terribly sorry for the inconvenience - you are right - this
is the answer, of course - please, accept my apologies - sincerely - pez -
- ps - i just tried to contribute, imho: constructively, by proposing
a possible way out from this lingering dead end of mathematics in this
beloved, from a long time now, language - farewell -
.
guest

Re: COMPLEX

Post by guest »

pez wrote: Sun 06 Jan 2019, 15:38i just tried to contribute, imho: constructively, by proposing
a possible way out
It's not clear to me what you were "proposing". BBC BASIC is over 37 years old, and the core language hasn't changed significantly for decades; even the extensions to the language that I have added (none of which were as drastic or risky as the introduction of a COMPLEX data type would be) were completed at least four years ago.

Indeed I have always believed that one of the strengths of BBC BASIC is its stability, and now there are three versions with different source trees ('BBC BASIC for Windows', 32-bit 'BBC BASIC for SDL 2.0' and 64-bit 'BBC BASIC for SDL 2.0') any future changes would have to be made to all three, which implies being implemented in both assembly language and C code! And only one of them is Open Source.

I have also always argued that the only way an extension to BBC BASIC can be justified is if the existing language features cannot adequately achieve the required functionality, and that's not the case with complex numbers. As I showed, and the Rosetta Code task further demonstrated, BBC BASIC is capable of supporting complex arithmetic in a reasonably elegant fashion.

If one looks at the large number of languages for which a solution to the Rosetta Code Arithmetic/Complex task have been submitted, the great majority do not have a built-in COMPLEX data type and most of those use a structure in exactly the same way that I proposed. Even the Java solution does effectively the same thing.

So I don't think BBC BASIC has anything to be embarrassed about in respect of its support for complex numbers.
pez
Posts: 4
Joined: Tue 03 Apr 2018, 15:38

Re: COMPLEX

Post by pez »

- farewell -
guest

Re: COMPLEX

Post by guest »

pez wrote: Sun 06 Jan 2019, 17:44- farewell -
Me too. Why should I even bother to remain a member of this forum for the next couple of weeks? I'm sick of it.