Message Boards Message Boards

0
|
5549 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Assemble a solveable equation from a list?

Posted 4 years ago

I have at some point in my calculations a list of numbers, examples being

{1, 140, 4144, 14400}

or

{1, 165, 8778, 172810, 1057221, 893025}

There is also a point where I have a corresponding list

{x^6, -140 x^4, 4144 x^2, -14400}

or

{x^10, -165 x^8, 8778 x^6, -172810 x^4, 1057221 x^2, -893025}

What I would like to do is assemble a solvable equation from either of the list types. So I would either have

Solve[{{x^6 - 140x^4 + 4144x^2 - 14400 ==0},x}]

or

Solve[{x^10 - 165x^8 + 8778x^6 - 172810x^4 + 1057221x^2 - 893025 ==0},x]

The format is always the same in that no matter how many terms there are the parity is always +, -, +, - ... == 0 and the right most term is always a constant and the others reading right to left are x^2, x^4, x^6... etc. Any pointer

POSTED BY: Paul Cleary
3 Replies
Posted 4 years ago

Power has the attribute "Listable", so no need for Map or MapIndexed:

list = {1, 165, 8778, 172810, 1057221, 893025};
list1 = Reverse[Range[Length[list]]];
eq = (((x^(2 (# - 1))* (-1)^#) &[list1])*list // Total) == 0
POSTED BY: Michael Helmle
Posted 4 years ago

That's perfect Henrik, works a treat, thank you. I had forgotten about the MapIndexed function.

POSTED BY: Paul Cleary

Not very elegant but straightforward is this:

list = {1, 165, 8778, 172810, 1057221, 893025};
signvect = -(-1)^Range[Length[list]];
eq = Total[signvect MapIndexed[#1 x^(2 (Length[list] - First[#2])) &, list]] == 0
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract