1. Integration

Which numerical integration method is best to use for an arbitary function of which nothing is known?

Currently I'm using "Simpson's rule", something I found using google. I found something called the "Romberg method" too, but I was unable to find its implementation.

"Simpson's rule" seems quite OK, though.

Secondly, when you are writing math formulas using ascii, how do you write integrals?
Examples:
Code:
```integrate(f, a,b)
integral{a,b}(f)
§[a,b] f(x)```

2. Which numerical integration method is best to use for an arbitary function of which nothing is known? Currently I'm using "Simpson's rule", something I found using google."
That's a good method. The other way I was taught in AP Calc was called the Trapezoidal Rule, but the Simpson's Rule has less of a margin of error; however, it is easier to calculate the margin of error for the Trapezoidal rule. It all depends on how precise you need to be. You could always increase the number of partitions to gain better accuracy.

Secondly, when you are writing math formulas using ascii, how do you write integrals?
Examples:
Code:
```integrate(f, a,b)
integral{a,b}(f)
§[a,b] f(x)```
If you mean in your code, I'd suggest that first one; it's the only one that I think is valid code. If you're outputting the integral, the last one looks the best.

3. Originally posted by joshdick
That's a good method. The other way I was taught in AP Calc was called the Trapezoidal Rule,
Yes, I tested the trapezoidal rule and found that it gave much less precision with much more steps.
Originally posted by joshdick
If you mean in your code, I'd suggest that first one; it's the only one that I think is valid code.
The thing is, I'm creating my own programming language (see my sig), and I want the syntax to be as intuitive as possible.

4. Originally posted by Sang-drax
The thing is, I'm creating my own programming language (see my sig), and I want the syntax to be as intuitive as possible.
Wow, man, that's really ambitious. Very cool. I like a lot of your features. It's like you're taking all of the little annoying obstacles in C++ and getting rid of them. In your case, I think that third way looks the nicest. The only thing is, how do type that symbol? I don't think most programmers want to have to hit something like shift+option+ctrl, etc. It looks nice; I think that third way would be nice for output, but I think it'd be bothersome to program that symbol.

Kudos for undertaking such a project. Oh, and what does your signature mean?

5. Yes, there's a problem with the '§' character -- it doesn't look the same in a console window and in a windows edit control.
It is quite easy to type on my keyboard (swedish) though.

And my signature?
I found a quote in Latin saying "Quidquid Latine dictum sit, altum videtur", it means "Whatever is said in Latin sounds profound". I used that quote for a while, then I wanted to reduce my sig to one line only.

6. Will your language support OOP?

7. That would indeed be nice.

I have been experimenting a little with different syntaxes to implement objects. As I've said, I'd like the syntax to be as easy as possible.

8. >Secondly, when you are writing math formulas using ascii, how
>do you write integrals?

I've used the simulation program PSI a lot, it had an easy, nice and intuitive language.

y = int (f par: y0);

When writing ASCII integrals in documents I prefer a notation like the one below. For the given integral above it would be:

Code:
```
o-o
/
y = y(0) + | f(x) dx
/
-o-o
```
>The thing is, I'm creating my own programming language (see
>my sig), and I want the syntax to be as intuitive as possible.

Interesting, what kind of language? A general purpose language? Or mathematical language?

9. Originally posted by Shiro

Interesting, what kind of language? A general purpose language? Or mathematical language?
Mainly a mathematical lanuage.
It has built-in support for complex numbers, vectors, matrices, etc.

It is inspired by C++, Pascal and a bit from the TI-83 and Casio calculator languages.

10. In that case you might want to take a look at Matlab. It has a language designed for numerical calculations. For some Matlab examples take a look at:

http://www.cs.uaf.edu/~bueler/MatlabEx.htm

It has some nice constructions for use with matrices and vectors, but it is not always a very intuitive language. The way of for-loops in Matlab is an example of it:

for j = 1:2:n-1

This is the same as:

for (j = 1; j <= n-1; j += 2)

11. Originally posted by Shiro
It has some nice constructions for use with matrices and vectors, but it is not always a very intuitive language. The way of for-loops in Matlab is an example of it:

for j = 1:2:n-1

Yes, I've looked at Matlab, although I'm using a program called Mathcad much more. It represents its formulas graphical.

For-loops look like this in Omicron:
Code:
```for i = 1 ... x+2
//..
next```

12. MathCad, I've heard of it, but never used it. But I know it is like Maple, it also gives the graphical representation of formula's, just as you put them to the paper.

The for-loop in Maple is a bit easier to understand, it is like:

for i from 1 by 2 to 100 do print(i) od;

You can also do such like this, combine for with while:

for i from 1 by 2 while i < 100 do print(i) od;

Using words instead of abstract operators is more typing, but in my opinion it is also more intuitive and easier.

BTW, I've been in Växjö last year, but I still don't know how to pronounce it in Swedish? Could you write it phonetic?
[/edit]

13. Originally posted by Shiro

BTW, I've been in Växjö last year, but I still don't know how to pronounce it in Swedish? Could you write it phonetic?
[/edit]
You have? Interesting...
Are you from the Netherlands?
I remember that my school (Katedralskolan) had an exchange with a school in the Netherlands.

As for the pronounciation of "Växjö":
• First sound is a normal 'v'-sound, as in 'vacation' or 'very'
• seconly, the same sound as the first sound in 'extra'
• then a normal 'k'
• then a 'sch'-sound, like the german word 'scheisse'
• the last sound is the same as in the german word for oil: 'öl'

stress the first vowel

14. Just to say something about integration:
It depends on the function when choosing between Simpson's Rule, Trapezoidal rule, right, left, or middle methods.

On average Simpson's rule is a better estimation. There are some functions though where others will be better. Simpon's Rule creates parabalas and then calculates the area under them. This is based on that any 3 points can be used to create a parabala.

You can calculate the error percent based on the rule. I forgot the exact equations. You can probably find them on-line though. You need to find the point where the second and fourth derivitive diverges to, though. I'm not sure how you could do this in a programming language without a significant amount of calculations.

- Sean

15. Originally posted by sean345

You can calculate the error percent based on the rule. I forgot the exact equations. You can probably find them on-line though.
Yeah, here's a good page (PDF)
http://www.eeng.dcu.ie/~ee317/Course_Notes/Numintg.pdf