Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to get Mathematica to solve the following equality in terms of $w_i$

$\displaystyle \frac{\sum_{i = 1}^{n} x_i }{\sum_{i = 1}^{n} y_i} = \frac{\sum_{i = 1}^{n} ( (\frac{x_i}{y_i}) w_i ) }{n} $

(Background: http://math.stackexchange.com/questions/137332/relationship-between-ratios-and-averages-of-ratios)

But it's telling me "This system cannot be solved with the methods available to Solve."

Now, I'm guessing this is because I haven't given Mathematica enough information about my assumptions (specifically, that $w_i$ is expressible as a function of $x_i$ and $y_i$, or something similar)

What am I doing wrong here, and how would I go about using Mathematica to solve equalities like these?

Solve[Sum[Subscript[x, i], 
     {i, 1, n}]/
    Sum[Subscript[y, i], 
     {i, 1, n}] == 
   Sum[(Subscript[x, i]/
       Subscript[y, i])*
      Subscript[w, i], 
     {i, 1, n}]/n, 
  Subscript[w, i]]

PS.) I realize my title stinks... I blame myself for not even knowing enough about what my problem is to give this question a cogent title. If someone could Edit the question and give it a real title and/or suggest one, I'd be appreciative.

share|improve this question
    
Your notation is extremely general, and the system won't understand it. If you decide on how many variables and equations you'll have exactly, then it can solve it. Also, it sees w_i as a single symbol, and it doesn't know that it's related to w_1, w_2, .... –  Szabolcs May 31 '12 at 19:12
    
@Szabolcs I understand what you're saying - but that doesn't tell me how to fix the problem. Could you tell me how you'd go about getting Mathematica to do what I'm trying to get it to do? –  Steve May 31 '12 at 19:17
    
I don't believe that there is any way to get it to solve such a system without you choosing a value for n first. I know my comment is not an answer, that's why I wrote it as a comment. –  Szabolcs May 31 '12 at 19:27

1 Answer 1

up vote 7 down vote accepted

Mathematica can only handle this if you give an explicit value to n.

If I understand correctly, what you want is: for what values of $w_i$ in terms of $y_i$ is the equations going to be satisfied for any $x_i$.

You need to use SolveAlways, not Solve, for this.

Example:

eqn = Sum[Subscript[x, i], {i, 1, n}]/
    Sum[Subscript[y, i], {i, 1, n}] == 
   Sum[(Subscript[x, i]/Subscript[y, i])*Subscript[w, i], {i, 1, n}]/
    n;

num = 3; (* let's solve for n==3 *)

SolveAlways[eqn /. n -> num, Table[Subscript[x, i], {i, num}]]

The output is

$$ \left\{\left\{y_1\to 0,w_1\to 0\right\},\left\{y_1\to 0,y_2\to 0\right\},\left\{y_1\to 0,y_3\to 0\right\},\left\{y_1\to -y_2,y_3\to 0\right\},\left\{y_1\to -y_3,y_2\to 0\right\},\left\{y_2\to 0,w_2\to 0\right\},\left\{y_2\to 0,y_3\to 0\right\},\left\{y_2\to -y_3,y_1\to 0\right\},\left\{y_3\to 0,w_3\to 0\right\},\left\{w_1\to \frac{3 y_1}{y_1+y_2+y_3},w_2\to \frac{3 y_2}{y_1+y_2+y_3},w_3\to \frac{3 y_3}{y_1+y_2+y_3}\right\}\right\} $$

You'll see that only the last solution is different from 0.

share|improve this answer
1  
Thanks so much for this! This is almost what I want - and, my brain can convert the result you show into the more generic w_i = n * y_i / Sum[y_i, {i, 0, n}] solution - but I'm surprised that Mathematica can get as far as you've shown me, but not make the result more general. Is this, definitively, as far as Mathematica is capable of taking the solution? –  Steve Jun 1 '12 at 0:49
    
@Steve Unless I'm mistaken, Mathematica is not able to do symbolic manipulations on general sums (sums that go up to a symbolic value). I'd love to be proven wrong though. –  Szabolcs Jun 1 '12 at 8:57
    
Great information... much appreciated. Thanks again for your time! –  Steve Jun 1 '12 at 17:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.