# Math Equation

Hi there,

It's been a while since I've seen this type of equation, not sure what to do here:

I am not sure this even makes sense, because if i = 1 then why not just say X subscript 1, instead of X subscript i? Also, "n-1" implies that we're considering a sample set of "n" numbers, which implies that the value of "i" changes "n" amount of times.

I don't know for sure though.

Hope you will help.
Thanks!
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
"I am not sure this even makes sense"   I am not sure either. Mainly because short cuts have been taken with the equation.
The summation sign could be more specific. What is being summed?  from what number to what number? to what does n refer?
If the original equation is written more specifically it will be easier for others to understand
President & FounderCommented:
it's been a while since college, but going by memory this is a time series summation, the X sub blah, is the value at given value in time. then add it all up in N time length
Principal Software EngineerCommented:
The format is not mathematically canonical, but I read it as:

The summation from i=1 to i=n-1, of the quantity {[e**(-xsubi) + 10)] / (xsubi + 10)}

Significant required information is missing.  The x array is not defined, nor is n defined.  Without that information it is not possible to calculate the values.

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

President & FounderCommented:
what is this for?
StatisticianCommented:
Hi there userTester,

I assume this is in the context of computer computations. Correct?

If so then there must be a vector called X (of length n - well of at least length n-1) somewhere defined.

I would first check the exact original formulae for

1. the meaning of the negative sign.  In usual notation (-Xi + 10) would mean  (10 - Xi) but it possible could mean - (Xi + 10)
2. the placement of the divisor.  In usual notation   Z / Xi + 10  would mean  (Z / Xi) + 10 but it possibly could mean Z / (Xi + 10)   where Z is  exp(- Xi + 10)   This may be a possibility in light of the other Xi + 10 in the numerator and doing the + 10 for each item in the sum is silly.

As in =>
.       Z
-------------
.  Xi + 10

In a scalar language with loops the usual interpretation would be calculated something like

``````sum := 0;

for i = 1 to n-1
sum := sum + exp(10 - X[i]) / X[i];

sum := sum + 10 * (n-1);
``````

===============

Though I suspect that (X[i] + 10) should be the divisor and that the minus should refer to all of X[i] + 10, so that
the scalar language solution becomes

`````` sum := 0;

for i = 1 to n-1
sum := sum + exp(- (X[i] + 10)) / (X[i] + 10);
``````

In an array language (for example J) the last calculation becomes

(^@:-   /   ])     10 +  }:X

(exponential after negate of <our list of variables>)  divided by  <our list of variables>      applied to
10 + <drop the last item of> X

Hope you get the drift. Please ask if you have additional questions or this is a mathematics question and the Xi 's follow some formulae.

Ian
Author Commented:
Dr. Klahn,

I think you're on the right track. The array is any sample set of numbers. I would suspect that "n" is the sample size.

This is part of a R Programming challenge. I suspect testing ability to code mathematical equations in R.
Author Commented:
"e" is the mathematical constant 2.718. I have no idea why it would be used here though?
StatisticianCommented:
If this is a challenge then they are expecting that you will NOT do it in a loop.

In R

• you can easily remove elements from a vector (by indexing )
• you can add a constant to a vector
• you can apply a function (in this case the exponential function) to a vector
• you can divide one vector by another (to produce a result rector)
• you can sum a vector to produce a scalar (well with R a scalar is a 1 element vector)
Look up the R references to learn how to do all of the above.  The solution should be relative short.
StatisticianCommented:
And as a challenge, doing a sort of silly expression is part of the exercise to make a (sort of) complex expression!
Author Commented:
ShannonEE

Interesting that you say I shouldn't use a loop but I will check for the exponential function and try the steps you suggest, thanks!
President & FounderCommented:
this seems like the equations from Filter theory, I thought Matlab or maple would be easier... but I've out of school for a while.
Author Commented:
Henry Liu

I don't think it is meant to be too complex, so the simplest thing it could be is probably what it is. The vector (array) can be any set of numbers, so "n" would be the number of numbers in the vector and "i" starts at 1, as Dr. Klahn mentioned.

ShannonEE mentioned that R has an exponential function, so that might help with implementation.

I will run the tests tomorrow and post here.
Author Commented:
ShannonEE

So I used a large enough vector (array) to provide a good range and did the following in R Studio and "manually" in MS Excel:

x <- c(3, 12, 14, 14, 19, 20, 22, 40, 45, 48, 51, 64, 67, 69, 73, 77, 78, 81, 90, 94, 99, 103, 107, 108, 111, 115, 119, 120, 130, 131, 135, 143, 152, 172, 185, 187, 187, 190, 197, 200, 201, 202, 203, 205, 207, 212, 213, 214, 216, 220, 229, 231, 231, 234, 236, 240, 242, 245, 246, 258, 258, 262, 270, 277, 279, 279, 282, 283, 295, 300, 315, 319, 322, 327, 329, 333, 338, 342, 343, 346, 355, 359, 362, 363, 376, 379, 384, 387, 388, 391, 393, 395, 404, 406, 411, 420, 439, 442, 448, 451, 459, 475, 498, 500, 501, 502, 502, 503, 506, 506, 506, 506, 508, 511, 514, 529, 530, 535, 539, 542, 543, 550, 559, 560, 574, 574, 575, 575, 575, 575, 576, 586, 589, 591, 591, 595, 607, 618, 626, 627, 629, 632, 633, 636, 640, 648, 649, 649, 654, 655, 664, 664, 664, 673, 682, 683, 689, 691, 696, 698, 713, 718, 724, 731, 733, 734, 737, 738, 738, 740, 740, 745, 748, 750, 752, 752, 756, 758, 758, 761, 761, 766, 783, 784, 788, 791, 794, 794, 796, 800, 802, 808, 811, 812, 815, 816, 816, 818, 818, 822, 827, 828, 829, 832, 837, 837, 843, 844, 846, 849, 852, 854, 855, 863, 868, 876, 885, 895, 895, 899, 901, 902, 903, 907, 909, 912, 925, 926, 929, 930, 934, 939, 943, 945, 951, 953, 961, 966, 972, 973, 981, 981, 982, 982, 987, 991, 992, 993, 996, 998)
x
v1 <- exp(-x + 10)
v1
v2 <- v1 / (x + 10)
v2
sum(v2)
Output: 84.36408

I am not sure how "n-1" fits into the picture. If I use "expm1()" instead of "exp()", it reduces the total by approximately 1. The documentation says that expm1(x) computes exp(x) - 1. Not sure if that's the same as n-1 though?
\Commented:
>> so "n" would be the number of numbers in the vector and "i" starts at 1, as Dr. Klahn mentioned.
Usually, given the equation in your OP picture, I agree with Dr. Klanh, that "n" represents the dimension of the vector.
What is odd, is that only n-1 elements are being considered in the summation.

When a summation runs to n-1, often the initial starting point is i = 0, rather than 1.
Author Commented:
phoffric

When a summation runs to n-1, often the initial starting point is i = 0, rather than 1

Good point, except that in R a vector starts at 1, a bit different from the "norm"!

I think I may have to get more clarity on "n-1".
\Commented:
Let Y_i be the term in the summation. If the R sum() function acting on a vector adds all the components of the vector together, then sum(Y_i) is adding Y_n to the desired result. But the upper bound is n-1. You can simply subtract out the last term, Y_n.

Your term has only one left parenthesis and one right parenthesis. Unless R has extra implied parenthesis, then the right-most + 10 is not part of the denominator.

Anyway, here are some fun facts which may or may not be related to your problem depending on how you interpret the parenthesis.

sum(Z_i + 10)  for i = 1..n-1 =  sum(Z_i) + sum(10)

sum (10) for i = 1..n-1 =  sum (10*1) = 10 * sum(1) = 10 * (n-1)
e.g., if n = 4, then we have sum(10) = 10 + 10 + 10 = 30 = 10 * (n-1) = 10 * 3 = 30

One other fact of interest: e^(a+10) = e^a * e^10, and
sum( e^a * e^10 ) = e^10 * sum(e^a)
Author Commented:
I will probably only get feedback on Monday regarding more clarity on a few things here, so hope everyone can hold out till then!
StatisticianCommented:
IN R indexind has many forms.

If i is one or more positive integers then ====>
X[i]  will give you a scalar if i is a scalar.  However if i is a vector, then X[i] results in a vector

If i is a Boolean (or logical  TRUE/FALSE) vector of compatible length to X then ===>
X[i] gives a vector  of length equal to the number of TRUE elements in i where the result is just the selection of the elements corresponding to TRUE in i

If i is a vector of negative integers then  ===>
X[i] is a vector of length equal to  ( length(x) - length(i) ) where the result is X in original order excluding those elements in positions  abs(i) .

You can't mix Booean and integer values into a vector. A vector is always of the same type.  However an integer vector can contain both positive and negative values.  In R indexing such a vector is not allowed.

As I said before

In R
• you can easily remove elements from a vector (by indexing )

I think you now have everything to give a really short and neat expression for your answer!

Good luck!
StatisticianCommented:
The other thing is that in R (as you would expect) expressions can be nested so that instead of

x
v1 <- exp(-x + 10)
v1
v2 <- v1 / (x + 10)
v2
sum(v2)

you could have written it as

sum( ...  /  ...)

without the intermediate assignments, where  ... is your calculations.
StatisticianCommented:
Going back to the original post - it uses the sum notation, although the way it was set out wasn't the best - there was too much vertical space, which made it harder to know what it was about.
this says that W is equal to the sum of {the expression evaluated in turn for each integer i between (and including) a and b }.  There is also very similar notation for doing continued products (which uses the capital Greek symbol pi in place of the capital Greek symbol sigma).

Also the notation for integration (as in mathematical calculus) follows the same idea.
StatisticianCommented:
Sorry typo in a previous comment:

In R indexing such a vector is not allowed.

should be

In R indexing using such a vector is not allowed.

you can't say  x[ c,(10, 11, 20, 30, -101)]  but you can say x[-27]  and x[ c(-1, -101)]  and x[c(10, 20, 30)]

======

You said

expm1(x) computes exp(x) - 1. Not sure if that's the same as n-1 though?

Answer:  Definitely NOT!  Just use the  exp function that you found, and make smart use of indexing.

=====
Author Commented:
Thanks to everyone who contributed to this discussion.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Statistics

From novice to tech pro — start learning today.