# Index operators, dependent coefficients

Discussion in 'Mac Apps and Mac App Store' started by kanenas, Nov 17, 2010.

1. Nov 17, 2010
Last edited: Nov 18, 2010

### kanenas macrumors newbie

Joined:
Jun 20, 2008
#1
In Grapher, is there any way of indexing multi-values (e.g. "{0,2..10}") or point sets? That is, is there an function (or operator) that takes a multi-valued expression and an integer and returns the i-th item of the expression (an f such that e.g. "f({0,2,5}, 2)" is 2 (for 1 based indexing) or 5 (for 0 based indexing); I don't care about where indexing starts)? Is there a function that takes a point set, a row index and column index and returns the item in the point set at the given row and column? I tried subscripting a multi-valued constant, but it didn't work.

What I'm trying to accomplish overall is to graph a family of equations differing only in the values of coefficients, each of which is dependent on one another. For example, say we want to graph y=mx+b for (m, b) in {(-1, 1), (2, 3), (4, 2)}. If I define m and b as separate sets (m={-1, 2, 4}, b={1, 3, 2}), then the coefficients used are the cross product of m and b and I'll get extraneous pairings (e.g. (m,b)=(-1, 2)).

One solution for two or three coefficients is to define a constant as a set of vectors, then multiply the transpose of a basis vector by the constant to extract a component from a vector. The two problems with this option is that it's a little verbose for my tastes (requiring extra constants for the basis vectors) and doesn't work for four or more coefficients. In the case of the example equation (and writing column vectors as row vectors), we would define:

• mb := {<-1, 1>, <2,3>, <4,2>}
• e_0 := <1,0>
• e_1 := <0,1>
• y = (e_0^T mb) x + (e_1^T mb)

Another solution is to use the ternary "if-then-else" operator or piecewise form (). This option is much to verbose for my liking. Example:

• n := {0..2}
• m(n) := (n==0) ? -1 : ((n==1) ? 2 : ((n==2) ? 4 : 0))
• y = m(n) x + b(n)

What other approaches can you think of, elegant or not?

I could use a more powerful math program to graph the family of equations, but the point here is to get Grapher to do it. Hopefully, someone will come up with something worthy enough to put on the MacRumors' Grapher guide.

Looking for ideas, I've read through Yves Baros' guide, checked Terry Lindenmuth's documentation and the Curvus Pro 3.1 manual with no success.

2. , Nov 19, 2010
Last edited: Nov 19, 2010

### YB24 macrumors member

Joined:
Apr 3, 2007
Location:
Dordogne-France http://y.barois.free.fr/grapher/
#2
Grapher 2.1 : using matrices

Bonjour Kanenas,
your first idea of a solution in attachment :
1 equation for 2x3 or more data ;
1 equation for 3 or more straight lines.
Do you like it ?
As you wrote matrices in Grapher are limited to 3 rows or columns.

So long, YB 24 (Yves Barois)

File size:
18.7 KB
Views:
20
3. ### kanenas thread starter macrumors newbie

Joined:
Jun 20, 2008
#3
I like that writing the equation as a matrix multiplication is more succinct (it's certainly going in the Grapher guide), but it doesn't get past the three coefficient limit.

In addition to not having a limit on the number of coefficients, indexing expressions (such as with the piecewise implementation) can be animated. Any ideas on this front?

4. ### YB24 macrumors member

Joined:
Apr 3, 2007
Location:
Dordogne-France http://y.barois.free.fr/grapher/
#4
Grapher : indexing expressions

Hi !
In attachment all what I think Grapher can do about indexing : may be you'll find better ? I hope so.
For animation, could you be more explicit about what you want : what equation or curve and what parameter (only one) to animate.
Ciao, YB24

File size:
41.7 KB
Views:
53
File size:
15.9 KB
Views:
18
File size:
14.3 KB
Views:
23
5. ### kanenas thread starter macrumors newbie

Joined:
Jun 20, 2008
#5
I think that sums up Grapher's capabilities, sad to say. So far, piecewise functions are the only solution that meet the requirements.

I'm interested in animating the equations with indexed coefficients along the index. That is, say we had a function f(x,k) = a_1(k)f_1(x)+...a_n(k)+f_n(x). We could then animate k, either as an animated parameter or as a quicktime movie. This would in effect animate along all the coefficients, but since they are dependent on one another, it would work for an arbitrary number of them. See attachment for an animated version of the example above (equation y=m(k)x+b(k)).

File size:
44.4 KB
Views:
18
6. ### YB24 macrumors member

Joined:
Apr 3, 2007
Location:
Dordogne-France http://y.barois.free.fr/grapher/
#6
Grapher : animating index

I think you got THE IDEA, congratulations !
In attachments : a Grapher file (circles animated by an index, using conditions), its QuickTime file .mov, and updated text "Indexing".

So long, YB24

File size:
18 KB
Views:
17
File size:
85.9 KB
Views:
18
File size:
72.4 KB
Views:
39