can someone check this

This is a discussion on can someone check this within the C Programming forums, part of the General Programming Boards category; I am trying to write a program that executes the improved Euler method of curve fitting. I am pretty sure ...

can someone check this

I am trying to write a program that executes the improved Euler method of curve fitting. I am pretty sure i have written the code correctly to run it, but when it runs, the numbers get massive very quickly, and i worry i;m making a fundamental (C programming) error.

Of course you can't pass in x[0], since the array x doesn't exist yet. Passing in a variable as you have it is the proper way to go.

If you haven't looked up printf yet, do so -- the f stands for formatted, after all, so you can specify your output format pretty exactly.

I didn't trace out the math very exactly, but I am not aware of a calculus-based formula for which setting a differential element (like dt) equal to 1 is even slightly appropriate. If 0.01 works, you're lucky, 0.001 or smaller is not uncommon.

If the x axis of a graph is time, the accuracy of my curve fit depends on how many points along the x axis i choose. For this i said that i would plot a point for every second that passes. Hence dt = 1.

Thank you for telling me about printf, when you begin programming, all you hear is printf lets you print to screen - i'll look it up now.