subscripts in CAS?

12122016, 06:40 PM
Post: #1




subscripts in CAS?
In Maxima, you can use subscripts, such as
Code: sum(a[k]*x^k, k, 0, 5); Code: a[5]*x^5+a[4]*x^4+a[3]*x^3+a[2]*x^2+a[1]*x+a[0] or more general Code: sum(a[k]*x^k, k, 0, n); Is there a way to use subscripts in a similar manner on the Prime? 

12122016, 08:57 PM
Post: #2




RE: subscripts in CAS?
(12122016 06:40 PM)Wes Loewer Wrote: In Maxima, you can use subscripts, such as The exact command on the prime returns a similar looking polynomial except the notation at(a,k1) is used in place of a[k] for display. This allows you to later store a vector/list into the variable a and the polynomial will be modified accordingly (on the display). You can, instead, use a(k) which will then be displayed as a(k) on the screen. In this case, a is implicitly considered a function. sum(a(k)*x^k, k, 0, n); Graph 3D  QPI  SolveSys 

12132016, 02:40 AM
(This post was last modified: 12132016 02:46 AM by compsystems.)
Post: #3




RE: subscripts in CAS?
examples of use on CAS MODE, n>0
0: with Σ cmd purge(a); Σ(a[k]*x^k,k,1,3) > x*a[1]+x^2*a[2]+x^3*a[3] // with [] at(a, k1) == a[1] Σ(a(k)*x^k,k,1,3) > x*a(1)+x^2*a(2)+x^3*a(3) // with () a:=MAKELIST(x,x,1,3); > {1,2,3} Σ(a(k)*x^k,k,1,3) > x+2*x^2+3*x^3 1: with SUM cmd purge(a); sum(a[k]*x^k,k,1,3); > x*a[1]+x^2*a[2]+x^3*a[3] // with [] sum(a(k)*x^k,k,1,3); > x*a(1)+x^2*a(2)+x^3*a(3) // with () a:=MAKELIST(x,x,1,3); > {1,2,3} sum(a(k)*x^k,k,1,3) > x+2*x^2+3*x^3 2: with SEQ cmd purge(a); seq(a(k)*x^k,k,1,3); > [x*a(1),x^2*a(2),x^3*a(3)] a:=MAKELIST(x,x,1,3); > {1,2,3} seq(a(k)*x^k,k,1,3); >[x,2*x^2,3*x^3] ΣLIST( seq(a(k)*x^k, k,1,3)) > x+2*x^2+3*x^3  I would like to see the notation using the character ↓ To differentiate it from other operations with parenthesis (evaluation) and so that prettyprint can decode more easily seq(a↓(k)*x^k,k,1,5); > [x*a↓(1),x^2*a↓(2),x^3*a↓(3),x^4*a↓(4),x^5*↓a(5)] 

12152016, 04:53 AM
Post: #4




RE: subscripts in CAS?
What I had in mind was the ability to treat a[k] as you would any other identifier, such as solve([a[1]+a[2]+a[3]=1,a[1]^2+a[3]=2, a[2]a[3]=3],[a[1],a[2],a[3]])
Perhaps it would be better to just show the application I was working on. The following is a function I wrote for Maxima which calculates the coefficients used for the various polynomial integration rules: Trapezoid Rule (n=1), Simpson's Rule (n=2), Simpson's 3/8 Rule (n=3), etc. Notice how eqs and coefs are lists of equations and coefficients which are determined at run time. In particular, the linsolve() function uses the coefs list as the list of variables to solve for. Code:
I've not been able to figure out how to do this on the Prime. It boils down to being able to treat a subscripted identifier as it would any other identifier. 

12152016, 07:45 AM
Post: #5




RE: subscripts in CAS?
Replacing makelist by seq seems to work:
Code:
Code:


12152016, 06:40 PM
Post: #6




RE: subscripts in CAS?  
12172016, 12:21 PM
(This post was last modified: 12172016 12:29 PM by compsystems.)
Post: #7




RE: subscripts in CAS?
Using brackets [], should index to zero and And parentheses in 1.
{a,b,c}(1) > a {a,b,c}[0] > a but {a,b,c}[0] > "Index outside range ..." {a,b,c}(1) or {a,b,c}[1] > a So you have two things that do the same thing. for what? Starting at zero, we avoid rewriting the expressions sum(a[k]*x^k, k, 0, 5) > sum(a[k]*x^k, k, 1, 6) 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)