flat assembler
Message board for the users of flat assembler.
Index
> Heap > Algorithm for algebraic expansion 
Author 

MHajduk
TmX wrote: Expanding forms like this by hand: For example, we can see how it would look in the case of n = 4 (I wrote all formulas in LaTeX because of better readability): Coefficients for x^k are sums of products made of all different combinations of k coefficients a_{i} and nk coefficients b_{j} (0 <= i, j < n). 

11 Aug 2009, 11:30 

Borsuc
Do you mean, to do this yourself, or do you want to program one that does it for you?
If you only want to expand it, not make a program that does it, you can use this: http://maxima.sourceforge.net/ for many other tasks _________________ Previously known as The_Grey_Beast 

11 Aug 2009, 19:11 

TmX
Thanks MHajduc for the hint
Borsuc wrote: Do you mean, to do this yourself, or do you want to program one that does it for you? i mean to make such program myself btw, maxima is a nice thing maybe i should reinstall it again (and scilab for numerical things....) 

12 Aug 2009, 04:46 

r22
@TmX algebraic expansion can be done (I believe) very simply
First we need a format to hold our initial values. We'll use a DWORD integer for the power of X and a DWORD single fp for the scalar. (2  x) using this format would be... Code: Term1: //binomial ? dd 2.0 dd 0; x^0 = 1, 2.0 * 1 = 2.0 dd 1.0 dd 1 ; x^1 = x, 1.0 * x = x Once we have all our terms formatted like the above we have to start expanding them. Here's a pseudo algorithm for the expansion. Code: //i.e. arr1 = {2.0, 0, 1.0, 1} // (2.0  x) FUNCTION EXPAND arr1, arr2 RETURN new Array retarr = new Array FOR x = 0; x<arr1.length; x=x+2 FOR y = 0; y<arr2.length; y=y+2 retarr.push( arr1[x] * arr2[y] ) retarr.push( arr1[x+1] + arr2[y+1] ) NEXT y NEXT x return retarr END FUNCTION //you take the resulting array and use it and the next Term/[binomial?] as the arguments for the next call to EXPAND After all your expansion you'll be left with an array/stack of all the expanded terms. Many will be liketerms so you'll have to loop through the array and combine them, but I'll leave you with this task. *Disclaimer* the above algorithm popped into my head while I was reading this thread and may be completely wrong, it's not tested. 

12 Aug 2009, 13:07 

r22
I'm kind of curious if TmX was able to implement algebraic expansion in FASM...


17 Aug 2009, 13:41 

< Last Thread  Next Thread > 
Forum Rules:

Copyright © 19992020, Tomasz Grysztar. Also on YouTube, Twitter.
Website powered by rwasa.