Ask Your Question

Konstantin's profile - activity

2024-02-23 18:26:10 +0200 received badge  Famous Question (source)
2023-02-25 13:52:48 +0200 received badge  Notable Question (source)
2022-10-30 13:33:05 +0200 received badge  Popular Question (source)
2021-12-28 03:11:56 +0200 asked a question How can I substitute an unknown function in an expression with a known function?

How can I substitute an unknown function in an expression with a known function? I have defined an unknown function "p"

2021-12-26 05:57:53 +0200 received badge  Editor (source)
2021-12-26 05:57:53 +0200 edited answer How can I easily create and handle polynomials with symbolic coefficients?

Interestingly, when doing: a = var('a', 100) I get an error message: AttributeError: 'sage.rings.integer.Integer' ob

2021-12-26 05:57:43 +0200 commented answer How can I easily create and handle polynomials with symbolic coefficients?

Interestingly, when doing: a = var('a', 100) I get an error message: AttributeError: 'sage.rings.integer.Integer' ob

2021-12-26 05:57:00 +0200 commented answer How can I easily create and handle polynomials with symbolic coefficients?

a = var('a', 100) I get an error message: AttributeError: 'sage.rings.integer.Integer' object has no attribute 'strip'

2021-12-26 05:03:43 +0200 answered a question How can I easily create and handle polynomials with symbolic coefficients?

Interestingly, when doing: a = var('a', 100) I get an error message: AttributeError: 'sage.rings.integer.Integer' ob

2021-12-26 05:00:11 +0200 marked best answer How can I easily create and handle polynomials with symbolic coefficients?

I would like to create polynomial functions with symbolic (yet unknown) coefficients, like:

p(x)=a*x^5 + b*x^4 + c*x^3 + d*x^2+e*x+f

Then I would like to experiment with the degree and thus the number of coefficients, for example:

p(x)=a*x^7 + b*x^6 + c*x^5 + d*x^4+e*x^3+f*x^2+g*x+h

The problem is I always have to explicitely declare the coefficients, as variables, like:

var("a b c d e f g h")

So I should always have to enumerate them by hand.

Isn't exist some automatism to do this? For example:

Polynomial(x,degree=7)

and it would return

c0*x^7 + c1*x^6 + c2*x^5 + c3*x^4+c4*x^3+c5*x^2+c6*x+c7

Sometimes I also would like to query the coefficients, to solve an equation system, which contains those coefficients:

p(x)=a*x^7 + b*x^6 + c*x^5 + d*x^4+e*x^3+f*x^2+g*x+h
eq=[
derivative(p(x),x).subs(x=0)==0,
derivative(p(x),x,2).subs(x=0)==0,
p(x=0)==0,
p(x=x0)==1,
p(x=1)==1+z,
derivative(p(x),x).subs(x=1)==0,
derivative(p(x),x,2).subs(x=1)==0,
derivative(p(x),x).subs(x=x0)==1
]
s=solve(eq,a,b,c,d,e,f,g,h)

Again, when calling solve(), I have to explicitly enumerate the coefficients again, instead of some shortcut, like:

s=solve(eq,p(x).coefficients())

When I try to experiment with the degree of my polynomial p(x), to try out a higher or lower degree, and with more or less equations in the system, I always have to declare my coefficients as vars again and again, which is very annoying.

Furthermore when I tried to query coefficients by, eg.:

p.coefficient(x)

or

p.coefficient(x^3)

The first returns "g" as the coefficient, which is good. But how can I access or query the "free" coefficient, "h" which isn't multiplied by x?

p.coefficient(0)

Doesn't return anything. If it would return the free coeff, then I could get the coefficients by calling a map() with lambda function.

2021-12-26 05:00:11 +0200 received badge  Scholar (source)
2021-12-25 23:19:49 +0200 asked a question How can I easily create and handle polynomials with symbolic coefficients?

How can I easily create and handle polynomials with symbolic coefficients? I would like to create polynomial functions w

2021-12-23 04:24:15 +0200 received badge  Student (source)
2021-12-23 04:09:54 +0200 asked a question How can I plot two parametric functions in a common coordinate system?

How can I plot two parametric functions in a common coordinate system? I can easily use parametric_plot() to plot 1 para