Ask Your Question
-2

find coefficient of generating functions with three variable

asked 2024-08-31 21:07:48 +0100

anonymous user

Anonymous

I want to write a sage math code to find the coefficient of $x^{15}d^7r^8$ in the expansion of $$\frac{1}{1-\bigg( \frac{xd+(xd)^2+(xd)^3}{1+(xd)+(xd)^2+(xd)^3} + \frac{xr+(xr)^2+(xr)^3}{1+xr+(xr)^2+(xr)^3} \bigg)}$$

I use free version of ChatGPT,but it writes always wrong code because it knows SAGE until 2021. Can you help me ?

edit retag flag offensive close merge delete

Comments

Homework question?

Max Alekseyev gravatar imageMax Alekseyev ( 2024-09-01 01:17:45 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-09-01 12:56:06 +0100

Emmanuel Charpentier gravatar image

updated 2024-09-01 15:41:03 +0100

Well... your expression is a rational fraction of two polynomials, of degree 6 in $x$. There is no such thing as an $x^{15}\dots$ coefficient.

However, this fraction can be approximated (Taylor development) as series in $x$, whose coefficient in $x^{15}$ may contain terms in $d^7$, which may contain a term in $r8$. An obvious way to search is :

sage: foo=1/(1-((x*d+(x*d)^2+(x*d)^3)/(1+x*d+(x*d)^2+(x*d)^3)+(x*r+(x*r)^2+(x*r)^3)/(1+x*r+(x*r)^2+(x*r)^3)))
sage: foo.series(x, 16).coefficient(x^15).expand().coefficient(d^7).expand().coefficient(r^8)
3296

I use free version of ChatGPT,

Don't. For mathematical purposes, ChatGPT (and other LLM engines) are (expensive) noise|bullshit generators. Do it yourself.

EDIT : lazier alternative:

sage: R1.<x,d,r>=LazyPowerSeriesRing(QQbar)
sage: foo=1/(1-((x*d+(x*d)^2+(x*d)^3)/(1+x*d+(x*d)^2+(x*d)^3)+(x*r+(x*r)^2+(x*r)
....: ^3)/(1+x*r+(x*r)^2+(x*r)^3)))

foo is the (infinite) polynomial approximating youir fraction with an arbitrary precision. The term you seek is of total degree 30, therefore one of the terms of :

sage: foo[30] # Alternative : foo.coefficient(30)
x^15*d^12*r^3 + 65*x^15*d^11*r^4 + 546*x^15*d^10*r^5 + 1860*x^15*d^9*r^6 + 3296*x^15*d^8*r^7 + 3296*x^15*d^7*r^8 + 1860*x^15*d^6*r^9 + 546*x^15*d^5*r^10 + 65*x^15*d^4*r^11 + x^15*d^3*r^12

eliminating the terms of too high degree in $d$ and $r$ gives us the relevant term :

sage: foo[30].truncate(d, 8).truncate(r, 9)
3296*x^15*d^7*r^8

HTH,

edit flag offensive delete link more

Comments

This problem admits an analytic solution, and I strongly suspect it's a homework problem, which does not require using any CAS.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-09-01 15:47:15 +0100 )edit

I'd be quite interested by (hints to) your analytic solution...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-09-01 17:48:52 +0100 )edit

First hint is that the coefficient in question is the same as in $\sum_{k=0}^{15} (...)^k$, where $(...)$ denotes the same expression in parentheses as in the original expression.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-09-01 17:59:45 +0100 )edit

@Emmanuel Charpentier: I don't want to spoil the problem for OP, but you are welcome to email me if anything is unclear.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-09-01 19:36:24 +0100 )edit

I don't know how to mail someone on this site...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-09-02 05:21:00 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-08-31 21:07:48 +0100

Seen: 250 times

Last updated: Sep 01