Click here to Skip to main content
15,885,835 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How can I add or subtract 2 Algebraic expressions in C which have 2 variables. I realize it could be done using matrix but that would leave many null spaces. Can anyone please write a program dynamically allocating the arrays. How can I do with sparse matrix (array representation)
Example question:
P1(x,y) = 5x^2y + 9x^3y^2
P2(x,y) = 9x^3y^2 + 12y^2 + 10x^4

What I have tried:

I have tried to do it normally using matrix in C but my professor discarded it as it was creating too much unnecessary memory
Posted
Updated 30-Jul-17 18:48pm

Sorry, we do not do your homework for you.
 
Share this answer
 
You don't need to use a matrix. Simply use a collection of structures, each of which contains:
  • coefficient
  • power of x
  • power of y
and sum the coefficients of like power combinations.

/ravi
 
Share this answer
 
Comments
Member 11560490 31-Jul-17 21:31pm    
Yeah, I agree with you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900