# Thread: Complex math on 16F series?

1. ## Complex math on 16F series?

Code:
```d = 1 / ((x1 - x2) * (x1 - x3) * (x2 - x3));
a = d * (x1 * (y3 - y2) + x2 * (y1 - y3) + x3 * (y2 - y1));
b = d * (x1 * x1 * (y2 - y3) + x2 * x2 * (y3 - y1) + x3 * x3 * (y1 - y2));
c = d * (x1 * x2 * y3 * (x1 - x2) + x1 * x3 * y2 * (x3 - x1) + x2 * x3 * y1 * (x2 - x3));
y(x) = a*x*x + b*x + c```
Code:

Code:

Hello, there is some math to be done to calculate polynomial smoothing points. Fragment of code is shown above. X and Y will be in range of 100-900.
If I understand correctly, there is no way to calculate that on 16F core and need to go for 18F core, right?  Reply With Quote

2. ## Re: Complex math on 16F series?

Check this one first:
http://www.picbasic.co.uk/forum/showthread.php?t=12433

and then check this one second:
http://dt.picbasic.co.uk/CODEX/N-BitMath

or reverse the order.  Reply With Quote

3. ## Re: Complex math on 16F series?

Thanks, I will consider it (though I have not yet understood how to use it). I'm also considering moving to 18F core or pre-calculating these data and storing them in external EPROM.  Reply With Quote

4. ## Re: Complex math on 16F series?

You can do just about any math you have the RAM for, and display a result, but the real question is what you want to do with the result.
You’ll probably still need a result value that fits into a PBP variable to get PBP to do anything further.
Aside from that, variable types are just arbitrary allocations of RAM, that also tell the compiler how to treat it.

For the problem you posted it looks as though the result would overflow a 16 bit word.
I don’t understand the desire to push shit uphill though, unless it was just for a challenge.
For XC16 free compiler, that problem would drop straight in to the compiler and be valid (with the forgotten semicolon on the last line).

If you’re going to say C is hard, it’s not harder that what you’re about to try, if you are going to make your own arbitrary variable types.  Reply With Quote

5. ## Re: Complex math on 16F series?

This is polynomial interpolation, designed to smooth out camera slider movements. User enters 3 sets of X and Y data and then slider moves along these points. As long as input variables are in 100-900 range, so will be the output ones, which perfectly fit into WORD variable I guess.  Reply With Quote

#### Members who have read this thread : 17

You do not have permission to view the list of names.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts