I have these two equations:
pl1 = ((2*α + 1)^2/((2*α + 1)^2 - (1 - α)^2))
(3/(2 α + 1) (xmed1 - (1 - α)/(2 α + 1) xmed2) +
((-3 α)/(2*α + 1) (1 - α)/(2 α + 1)*pl3))
pl3 = (2*α + 1)^2/((2*α + 1)^2 - (1 - α)^2)
(3/(2 α + 1) (xmed3 - (1 - α)/(2 α + 1) xmed2) +
((-3 α)/(2*α + 1) (1 - α)/(2 α + 1)*pl1))
parameters are α, xmed1, xmed2, xmed3.
I'm trying to plug pl1 into pl3 and solve for pl3. Basically just save myself the time of doing the algebra by hand.
I currently am not even able to set pl3 as a variable as I get as output:
$RecursionLimit: Recursion depth of 1023 exceeded during evaluation of (1+2 α)^2
So now I have no idea what to do. Obviously, this is my first crack at using mathematica. Thought I would speed up tedious algebra but now I've spent the last 5 hours going through tutorials and reading the documentation for mathematica... Probably should have just done it by hand!
Note the double equals == for solving.
FullSimplify[Solve[
{pl1 == ((2*α + 1)^2/((2*α + 1)^2 - (1 - α)^2))
(3/(2 α + 1) (xmed1 - (1 - α)/(2 α + 1) xmed2) +
((-3 α)/(2*α + 1) (1 - α)/(2 α + 1)*pl3)),
pl3 == (2*α + 1)^2/((2*α + 1)^2 - (1 - α)^2)
(3/(2 α + 1) (xmed3 - (1 - α)/(2 α + 1) xmed2) +
((-3 α)/(2*α + 1) (1 - α)/(2 α + 1)*pl1))},
{pl1, pl3}]]
Related
1/sqrt(x^2 + y^2 + 1 - sqrt(2) sqrt(x^2 + y^2) (x/sqrt(x^2 + y^2) + y/sqrt(x^2 + y^2))) - 1/sqrt(x^2 + y^2 + 1 - sqrt(2) sqrt(x^2 + y^2) (x/sqrt(x^2 + y^2) + y/sqrt(x^2 - y^2)))
trying to do a contour plot of an equation like this but can't get wolfram alpha or mathematica to accept it. It is plotting nothing. When I do it on wolfram alpha computation time exceeded.
Do I need to simplify this expression?
The function is : F(n-1) n F(n-1)
Its a type of palindrome function called Zimmer Series.
The values would be : 1, 121, 1213121, ...
I want to figure the summation of the individual digits.
1 + (1+2+1) + (1+2+1+3+1+2+1) + ...
Any help is welcome.
Breaking this down into steps, we first find out a formula for the summation of a single value of the series and then we can find out the summation of said formula.
Expanding the definition you gave and manipulating it:
F(n) = n + 2F(n-1)
F(n) = n + 2(n-1) + 22(n-2) + 23(n-3) + ... + 2n-1
2F(n) = 2n + 22(n-1) + 23(n-2) + ... + 2n-1(2) + 2n
F(n) - 2F(n) = -F(n) = n - 2 - 22 - 23 - ... - 2n
From this and using the formula for Geometric Progression we can then get an expression for a single term of the series.
F(n) = (2n + 2n-1 + ... + 2) - n
= (2n+1 - 2) - n
Now we just have to work out the summation of this expression.
G(n) = Σ F(n) = Σ (2n+1 - 2 - n)
G(n) = (2n+2 - 22) - (2n) - (n(n+1)/2)
Simplifying this should hopefully give you the answer you seek!
G(n) = (2n+2 - (n(n+5)/2) - 22)
Trying this out on a few of the terms just to double check.
G(1) = (21+2 - (1(1+5)/2) - 22)
G(1) = 1
G(2) = (22+2 - (2(2+5)/2) - 22)
G(2) = 5 = 1 + (1 + 2 + 1)
G(3) = (23+2 - (3(3+5)/2) - 22)
G(3) = 16 = 1 + (1 + 2 + 1) + (1 + 2 + 1 + 3 + 1 + 2 + 1)
EDIT: Mark Dickinson is right, I misinterpreted the question, this solution is incorrect.
I think after the second term the sequence is of the form difference in Arithmetic Progression.
Let me show you how
Second Term = 1+2+1
Third Term = 1+2+1+3 + 1+2+1
Difference = 1+2+1+3 = 7
Third Term = 1+2+1+3+1+2+1
Fourth Term = 1+2+1+3+ 1+4+1+3 +1+2+1
Difference = 1+4+1+3 = 9
Fourth Term = 1+2+1+3+1+4+1+3+1+2+1
Fifth Term = 1+2+1+3+1+4+ 1+5+1+4 +1+3+1+2+1
Difference = 1+5+1+4 = 11
So as you can see the difference is in the arithmetic progression and you find the sum of the terms using the formula for the sum of numbers whose different are in Arithmetic Progression
I understand that why bubble sort is O(n^2).
However in many explanations I see something like this:
(n-1) + (n-2) + (n-3) + ..... + 3 + 2 + 1
Sum = n(n-1)/2
How do you calcuate Sum from this part:
(n-1) + (n-2) + (n-3) + ..... + 3 + 2 + 1
Can anyone help?
Here's the trick:
If n is even:
n + (n-1) + (n-2) + … + 3 + 2 + 1
= [n + 1] + [(n-1) + 2] + [(n-2) + 3] + … + [(n - (n/2 - 1)) + n/2]
= (n + 1) + (n + 1) + (n + 1) + … + (n + 1)
= n(n+1)/2
If n is odd:
n + (n-1) + (n-2) + … + 3 + 2 + 1
= [n + 1] + [(n-1) + 2] + [(n-2) + 3] + … + [(n - (n-1)/2 + 1) + (n-1)/2] + (n-1)/2 + 1
= (n+1) + (n+1) + (n+1) + … + (n+1) + (n-1)/2 + 1
= (n+1)(n-1)/2 + (n-1)/2 + 1
= (n^2 - 1 + n - 1 + 2)/2
= (n^2 + n)/2
= n(n+1)/2
For your case, since you're counting up to n-1 rather than n, replace n with (n-1) in this formula, and simplify:
x(x+1)/2, x = (n-1)
=> (n-1)((n-1)+1)/2
= (n-1)(n)/2
= n(n-1)/2
The simplest "proof" to understand without deriving the equation is to imagine the complexity as area:
so if we have sequence:
n+(n-1)+(n-2)...
we can create a shape from it... let consider n=5:
n 5 *****
n-1 4 ****
n-2 3 ***
n-3 2 **
n-4 1 *
Now when you look at the starts they form a right angle triangle with 2 equal length sides ... that is half of n x n square so the area is:
area = ~ n.n / 2 = (n^2)/2
In complexities the constants are meaningless so the complexity would be:
O(n^2)
How do you compute the worst case time complexity of this algorithm
for j = 1 to i do
for k = 1 to j do
print(i,j,k)
Since we have no conditions which would affect the runtime of this algorithm the complexity would remain the same: there is always the same time complexity.
Let's keep it simple.
If we do just consider the semantic important instruction in the inner loop we can calculate the complexity as followed:
Every outer loop run increases the next inner loop run count by one.
We would have 1 + 2 + 3 + 4 + 5 + ... + i-1 + i loop runs, everytime the outer loop finished, the inner loop will be executed one more time than before.
Now we try to generalize this expression.
We double the initial term to represent it in an alternative form, you'll recognize why.
2 * (1 + 2 + 3 + 4 + 5 + ... + i-1 + i) = (1 + 2 + 3 + 4 + 5 + ... + i-1 + i) + (1 + 2 + 3 + 4 + 5 + ... + i-1 + i)
2 * (1 + 2 + 3 + 4 + 5 + ... + i-1 + i) = (1+i) + (2 + (i-1)) + (3 + (i-2)) + ... + ((i-1) + 2) + (i+1)
Now we can see that in this representation we have a multiple of the same term.
2 * (1 + 2 + 3 + 4 + 5 + ... + i-1 + i) = (1+i) + (1+i) + (1+i) + ... + (1+i) + (1+i)
2 * (1 + 2 + 3 + 4 + 5 + ... + i-1 + i) = i*(1+i)
Since we still have the double of our initial complexity, we need to divide by 2, which results in closed-form expression.
1 + 2 + 3 + 4 + 5 + ... + i-1 + i = (i*(1+i))/2
resulting in our complexity O(i(i+1)/2) => O(i^2)
We can do so due to the fact that given a polynomial inside an O() you can simply replace it with x^highest_power
We don't take care of the instructions which are mandatory processed by the control structures itself; I do not think this is the task. If you desire so, please let me know.
Can someone please explain in plain English how to calculate it?
I know that you have to visit n+2+(n-1)+2+...+2+2 elements, but how do you get to 1/2n^2 + 5/2n - 3? Thanks!
n + 2 + (n - 1) + 2 + ... + 2 + 2 is equal to (n + 2) + (n + 1) + ... + 4. It's an arithmetic progression and its sum is calculated as (n + 2 + 4) * (n + 2 - 4 + 1) / 2. It's equal to (n + 6) * (n - 1) / 2 and finally 1/2 * n^2 + 5/2 * n - 3.
f(n) = O(g(n)) means there exists such constant C that f(n) <= C * g(n) for all sufficiently large n. If n is considered as natural number then 1/2 * n^2 + 5/2 * n - 3 = O(n^2) with C = 3/2 for example.