On Jun 4, 3:00 pm, CuppoJava <patrickli_2...@hotmail.com> wrote:
> Hey guys.
> Thanks for the help. I have to clarify my question a bit.
>
> f(x,y) and a0 are given and do not assume any properties.
> Find g(x,y) and b0, such that for *any* list of numbers v,
>
> (reduce f a0 v) = (reduce g b0 (reverse v))

This is not always possible. Proof: assume, for some f and a, that we
have the requisite g and b. Suppose a is such that (f a x) = x for any
x.

Case one: v = [v1]. It follows that (f a v1) = (g b v1) = v1.

Case two: v = [v1 v2]. Then (f (f a v1) v2) = (f v1 v2) = (g (g b v2)
v1) = (g v2 v1).

Case three: v = [v1 v2 v3]. Then (f (f (f a v1) v2) v3) = (g (g (g b
v3) v2) v1)
(f (f v1 v2) v3) = (g (g v3 v2) v1) = (g (f v2 v3) v1) = (f v1 (f v2
v3)), for any v1, v2, v3. So f is associative.

Thus, if f is not associative, either (f a x) != x for some x, or no
such g, b exist. OTOH, if f is associative and we have (f a x) = x,
then g = (flip f) works with b = a.

I haven't been able to prove the existence or nonexistence of such g,
b in other cases of f, a yet. I suspect f is required to be
associative regardless of the value of a.


>
> ------------------------------
>
> In case it helps at all, my specific problem is like this:
>
> v is a list of number pairs.
> v = [ [1 1] [0.5 1] [0.1 1] [0.3 3] ]
> a0 = [0 0]
>
> and f =
> (fn [[c2 a2] [c a]]
>   [(+ c (* (- 1 a) c2)) a2])

This makes things much simpler, yes. I haven't analysed this function
mathematically, so I can't say whether it's possible under the given
constraints. But it might be, which is probably better than a "no".
And it will be easier to prove things about this specific function
than about all functions.

>
> It's the formula I'm using for blending translucent pixels on top of
> each other.
> Currently I'm drawing back to front and accumulating the color with
> the above function.
>
> But for optimization purposes, it's much better to render front to
> back and take advantage of an early exit condition. But for that, I
> need a inverse-reduce function g(x,y), which is how this question
> popped into my head.

Does it have to be (reduce f a0 v) = (reduce g b0 (reverse v))? It
might be simpler if it were (reduce f (cons a0 v)) = (reduce g
(reverse (cons b0 v))).
Does the early exit condition depend on f/g, or might it be possible
to have g simply collect values of (reverse v), and then later pass
them to f?

What little I know of the subject makes me suspect the answers are
both "yes it does", but it can't hurt to ask.

>
> Thanks so much for the help
>   -Patrick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to