Discrepancy in simplification [closed] - wolfram-mathematica

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
For the below mentioned
simplify[(1/x)*(t/x)^(N-1)*(1-(t/x)^N)^(-2)]
and
simplify[(1/x)*(t/x)^(N-1)*(-1+(t/x)^N)^(-2)]
I am getting the same output which is
(t/x)^N/(t (-1 + (t/x)^N)^2)
How is it possible? Kindly help.
Thanks in advance.

The only terms that are different in your "code" are
(1-(t/x)^N)^(-2)
and
(-1+(t/x)^N)^(-2)
and these are identical too. It's because the parentheses that are raised to the power of -2 are negatives of each other. A power of something to -2 is equal to 1 over the power the same thing to 2 and, as you certainly know, x^2 is equal to (-x)^2.
Proof: just perform the exponentiation. Let B = (t/x)^N (so that I don't need to write it over and over again). The first expression:
(1 - B)^(-2) = 1 / ((1 - B)^2) = 1 / (1 - 2*B + B^2)
And the second expression:
(-1 + B)^(-2) = (B - 1)^(-2) = 1 / ((B - 1)^2) = 1 / (B^2 - 2*B + 1) = ...
... = 1 / (1 - 2*B + B^2)
Proved.
If we were to substitute back for the B then the result is
1 / ((t/x)^2N - 2*(t/x)^N + 1)

Related

Time complexity of T(n) = 27T(n/3) + (n^3)log(n) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need some help with this recurrence. I tried it by myself and I got teta( (n^3)logn) but Wolfram Alpha says this:
I guess this is like an
O( (n^3) log^2(n)). I can't use master theorem, so I solved it by recurrence. This is my solution, but I don't know what's wrong with it
You made a mistake in the last stage. Using these properties: log(x) + log(y) = log(xy) and log(x/y) = log(x) - log(y) and log(x^y) = y log(x)`, we have the following:
sum_{i=0}{k-1} log(m/3^i) = log(m^k / (1 * 3 * 3^2 * ... * 3^(k-1)))
= log(m^k) - log(3^((k-1)k/2))
= k log(m) - (k-1)k/2 log(3) = c * k * (k-1) = Theta(log(m) * log(m))
Therefore, the time complexity is m^3 log^2(m).

Expected value of independent random variables - Algorithms [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
There are n independent random variables X1,X2..Xn. Each random variable can take value of either 0 or 1. The probability that a variable Xi has a value of 1 is 1/n. What is the expected value of square of sum of X1..Xn.
This may be homework, so I'll give a few hints:
We want E((\sum_i X_i) ^2). Now show that:
E((\sum_i X_i)^2) = E(\sum_i X_i^2 + 2\sum_{1<= i < j <= n} X_i * X_j)
= n * E(X_i^2) + 2 * choose(n, 2) * E(X_i * X_j)
Now all you need is:
E(X_i^2), E(X_i * X_j)
For any i and j, since they are i.i.d.

matrix expression simplify [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
i am wondering if it is possible to simplify:
T*V + V*T // V = V^(t) symmetric
where both operands are matrixes
I don't think this is possible due to the following considerations:
If we multiply two matrices A and T, where A is symmetric (i.e. A(i,j) = A(j,i)), we have the following:
For A*T we have that the item in row z and column s is computed as:
__n__
\
/ A(z,i)*T(i,s)
-----
i=1
For the other way around, T*A, we get for row z, column s:
__n__ __n__
\ \
/ T(z,i)*A(i,s) = / T(z,i)*A(s,i)
----- -----
i=1 i=1
So, as long as we do not know anything about the entries T(i,j) in T, I think we can not say how these sums relate to each other.

How can I solve The Riddle of Nine 9's programmatically? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How can I solve this riddle programmatically? Could someone help me with some pseudo-code or something?
Nine 9s
Combining nine 9's with any number of the operators +, -, *, /, (, ), what is the smallest positive integer that cannot be expressed?
Hints:
The answer isn't zero. You can express zero like this:
(9 - 9) * (9 + 9 + 9 + 9 + 9 + 9 + 9).
Also, zero isn't a positive integer.
The answer isn't one. You can express one like this:
9 - (9 * 9 - 9)/9 + 9 - 9 + 9 - 9
It's not a trick question.
Be sure to handle parentheses correctly.
Notes:
You cannot use exponentiation.
You cannot concatenate (for example,
put two 9's together to make 99).
The - operator can be used in either
its binary or unary form.
Assume base 10.
This is actually a famous puzzle and there are probably many solutions hovering around the internet. I am not sure if any of them is correct or not. Does anybody have a well explained solution?
The answer is 195, here is some Python code that simply builds up all possible expressions by forming new expressions from exp1 OP exp2. It runs in 0.165s on my PC.
exp = [set() for _ in xrange(10)]
exp[0].add(0)
exp[1].update([9, -9])
for i in xrange(1, 10):
for a in list(exp[i]):
for j in xrange(i, 10):
for b in list(exp[j-i]):
exp[j].update([a+b, a-b, a*b])
if b != 0:
exp[j].add(a/b)
n = 0
while n in exp[9]:
n += 1
print n
EDIT:
If the answers must be exact integers (and not just the rounded result of integer division) then a check must be done when division is done.
if ((b != 0) and ((a/b) == float(a)/b)):
exp[j].add(a/b)
Under this interpretation of the rules, the new answer is 138.
(the existing version computes 1386/10 [or -1386/-10] and gets 138)
195, http://members.iinet.net.au/~tmorrow/mathematics/ninenines/ninenines.html

How to calculate the inverse factorial of a real number? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Is there some way to calculate the inverse factorials of real numbers?
For example - 1.5 ! = 1.32934039
Is there some way to obtain 1.5 back if I have the value 1.32934039?
I am trying
http://www.wolframalpha.com/input/?i=Gamma^(-1)[1.32934039]
but that is a fail.
Using wolframalpha.com, you can ask for
Solve[Gamma[x+1]==1.32934039,x]
As mentioned in the comments, Gamma does not have a unique inverse. True even when you are solving for a conventional factorial, e.g.
Solve[Gamma[x+1]==6,x]
yields several answers, of which one is 3.
Instead of using Gamma[] in WolframAlpha, you can also use Factorial[]:
Solve[Factorial[x]==6,x]
Solve[Factorial[x]==1.32934039,x]
David Cantrell gives a good approximation of Γ-1(n) on this page:
k = the positive zero of the digamma function, approximately 1.461632
c = Sqrt(2*pi)/e - Γ(k), approximately 0.036534
L(x) = ln((x+c)/Sqrt(2*pi))
W(x) = Lambert W function
ApproxInvGamma(x) = L(x) / W(L(x) / e) + 1/2
For integers you can do:
i = 2
n = someNum
while (n != 1):
n /= i
i += 1
return (i==1 ? i : None)
The factorial for real numbers has no inverse. You say that "each function must have an inverse". That is incorrect. Consider the constant function f(x)=0. What is f^-1(42)? For a function to be inverse it must be both an injection and a surjection.

Resources