Construct a companion matrix
CJam, 32 31 28 bytes
0q~)f/f-_,(_,\0a*1+fm<~]W%z
Try it online
This takes the input in ascending order, using the CJam list format. Sample input:
[-4.0 -7.0 13.0]
Explanation:
0 Push a 0 for later sign inversion.
q~ Get and interpret input.
) Pop off last value.
f/ Divide all other values by it.
f- Invert sign of values.
_, Get count of values, which corresponds to n.
( Decrement by 1.
_, Create list of offsets [0 1 ... n-1] for later.
\ Swap n-1 back to top.
0a* Create list of n-1 zeros.
1+ Append a 1. This is the second-but-last column [0 0 ... 0 1].
fm< Apply rotation with all offsets [0 1 ... n-1] to column.
~ Unwrap the list of 0/1 columns.
] Wrap all columns
W% Invert their order from last-to-first to first-to last.
z Transpose to get final matrix.
` Convert to string for output.
APL, 40 30 bytes
{(-n↑⍵÷⊃⊖⍵),⍨⍉1↓⍉∘.=⍨⍳n←1-⍨≢⍵}
Accepts input in ascending order.
Explanation:
{
n←1-⍨≢⍵ ⍝ Define n = length(input)-1
∘.=⍨⍳ ⍝ Create an n×n identity matrix
⍉1↓⍉ ⍝ Drop the leftmost column
,⍨ ⍝ Append on the right:
(-n↑⍵ ⍝ n negated coefficients,
÷⊃⊖⍵) ⍝ divided by the n+1st
}
Try it online
CJam, 23 20 bytes
{)W*f/_,,_ff=1f>\.+}
This is a function that pops the input (ascending order) from the stack and pushes the output in return.
Try it online in the CJam interpreter.
How it works
) e# Pop the last element from the input array.
W* e# Multiply it by -1.
f/ e# Divide the remaining array elements by this product.
_, e# Push a copy of the array and compute its length (L).
,_ e# Push [0 ... L-1] twice.
ff= e# For each I in [0 ... L-1]:
e# For each J in [0 ... L-1]:
e# Push (I==J).
e# This pushes the L x L identity matrix.
1f> e# Discard the first element of each row, i.e., the first column.
\ e# Swap the result with the modified input.
.+ e# Vectorized append; append the input as a new column.