david wrote:
Quote:
|
Ok. In my situation I would know the possible input values, but not the corresponding output values. Someone must have done something like this before, for example: 1. Find a complicated formula in a textbook to calculate some value. You would know the possible input values, but there would be no tables of corresponding output values. 2. Implement the formula in C++ 3. Do some test to check that the implentation of the formula in C++ is correct (matches the original formula from the textbook). Maybe the only way to do this test is to manually do some calculations using the textbook formula and then compare with the outputs from the C++ function - but I was wondering if there is a more formal way to do this.
|
I don't know of any formal method (and I think the jury is out on
whether it's even possible to define a formal method - you may run into
the halting problem if you try for a really clean formal method). But
I'd like to suggest a couple quick practical ideas.
- What actual inputs/outputs are really easy to compute (on the
pencil-and-paper side)? Do those first against your C++ function as a
sanity check.
- Can you compute any interesting related properties of the formula
(again on the P&P side)? Like the derivative with respect to each of
its inputs? Or does it have asymptotic behavior anywhere? You can use
these observations to guide your choice of inputs to, and verification
of, the C++ function.
- Does the C++ implementation give reasonable answers when various
input(s) are very large or very small? Or when the inputs are of very
different orders of magnitude?
If your formula is some kind of iterative approximation, you're going
to run into all kinds of questions that are discussed in the field of
"numerical analysis", but then you probably are already familiar with
numerical analysis if you're doing an iterative approximation. I'm
guessing your formula is a relatively straightforward one-time
computation sort of thing.
--JMike