Hi!

I don’t know if Sympy has a method to do it. The truth is I don’t know much.

Using my limited knowledge I wrote a function to do it. I’m sure that it can be 
improve a lot but it works:

- - - - -
def newpoly(coefs):
    p = ""
    for i in range(len(coefs)):
        p += str(coefs[i]) + '*x**' + str(len(coefs)-i-1) + '+'
    p = p[:-1]
    return sympify(p)

newpoly([4,8,3])
- - - - -

Javier

> El 22 feb 2021, a las 16:39, Michał Pawłowski 
> <[email protected]> escribió:
> 
> Thank you so much. But is it also possible to get formula from such array?
> 
> I.e.
> getFormula("[2, 0, 2]")
> 2*x**2+2
> 
> Thanks 
> Mike 
> 
> poniedziałek, 22 lutego 2021 o 12:56:57 UTC+1 [email protected] 
> napisał(a):
>> Hi!
>> 
>> Poly(4*x**2+8*x+4).all_coeffs()
>> 
>> Javier
>> 
>>>> El 22 feb 2021, a las 12:44, Michał Pawłowski <[email protected]> 
>>>> escribió:
>>>> 
>>> Hi.
>> 
>>> 
>>> I'd like to get polynomial qualifiers returned as array, in example:
>>> 
>>> getQualifiers("4*x**2+8*x+4")
>>> [4, 8, 4]
>>> 
>>> or
>>> 
>>> getQualifiers("4*x**2+4")
>>> [4, 0, 4]
>>> 
>>> Is it possible?
>>> 
>>> Thanks
>>> Mike
>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "sympy" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/sympy/51ffa1bd-3654-40b5-a1c2-dc650b277222n%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/1653484a-a2b8-4d6b-882f-b8c6e96b15e2n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/709A5E4B-0F17-4394-AEC0-A8FEC800A995%40gmail.com.

Reply via email to