Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kanenas

macrumors newbie
Original poster
Jun 20, 2008
24
0
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 (
Piecewise.png
). 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))
  • F82mj.png
  • 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.
 
Last edited:
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)
 

Attachments

  • DonnéesEnMatrices.gcx.zip
    18.7 KB · Views: 62
Last edited:
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?
 
Grapher : indexing expressions

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?

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
 

Attachments

  • Indexing.pdf
    41.7 KB · Views: 135
  • IndexingEquations1.gcx.zip
    15.9 KB · Views: 78
  • IndexingEquations2.gcx.zip
    14.3 KB · Views: 58
I think that sums up Grapher's capabilities, sad to say. So far, piecewise functions are the only solution that meet the requirements.

For animation, could you be more explicit about what you want : what equation or curve and what parameter (only one) to animate.
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)).
 

Attachments

  • Animated index.gcx.zip
    44.4 KB · Views: 50
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
 

Attachments

  • IndexAnimé.gcx.zip
    18 KB · Views: 53
  • IndexAnimé.mov.zip
    85.9 KB · Views: 54
  • Indexing.pdf
    72.4 KB · Views: 112
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.