Can you help me to solve recurrence relation T(1)=5, and for all n>=2, T(n)=2T(n-1)+(3*n+1) - time-complexity

T(1)=5,
and for all n>=2: T(n)=2T(n-1)+(3*n+1).
I tried to solve this problem, but I have a problem with 3*n+1. When I put n-1, n-2,..., I don't know how to determine the formula for this problem.

Since there is only (3*n+1) as term and not T(3*n+1) this is solvable. First impression: you have 2T(n-1) as subterm, so the solution is something like 2^n.
Through a simple Excel data analysis I found the solution T(n)=-7-3n+15 * 2^(n-1), I will try to solve it per hand and will update my answer if I found the right path.
Edit: This was more difficult than expected...
Explanation:
first step is to get a sum formula for n. You can derive this pattern from the first few T(n).
Once you get the pattern, try to get rid of the sum.
To solve sums, try to get them in a similar format as sum_(i=1)^n (1) = n or sum_(i=0)^n (2^i) = 2^(n+1)-1
to do this you can manipulate the index such as sum_(i=2)^n (n-i) = sum_(i=0)^(n-2) (i) or to include/exclude elements from the sum.
the trickiest part was to solve sum_(i=0)^n ((n-i)*(2^i)). The idea here is to convert the multiplication (depending on i) to a sum (also depending on i).
please note the changing indice-numbers. sum_(i=0)^n (2^i) is not the same as sum_(i=1)^n (2^i)
The path is not the most efficient one, simplify as you wish.

Related

Cloudinary stuck on Displacement

I am trying to generate a mockup for t-shirts.
The result I am trying to achieve is the following: https://prnt.sc/kzhjk7
Using cloudinary, this is the closest result I have been able to produce:
https://res.cloudinary.com/worldwide-buy-llc/image/upload/c_scale,o_0,w_380/a_0,c_scale,l_TemplateSquare,r_0,w_380,x_900,y_190/c_scale,l_TemplateSquare,w_380,x_-310,y_240/c_scale,u_Mockups:Kids_White,w_3623,x_0,y_0/c_scale,l_Mockups:Kids_Whiteover,o_100,w_3623,x_0/v1538036215/TemplateSquare.png
However, it still looks different from the image that I would like to achieve.
I read that I could apply displacement. For this reason, I do have a displacement map stored at Mockups:Kids_WhiteOver
Do you know how can I apply it? Also the colors of the layers TemplateSquare appear weak in comparison to the target result ( https://prnt.sc/kzhjk7 ).
Any suggestion is very much appreciated since I am literally stuck to achieve that result. Many thanks in advance!
You can try removing the opacity from the transformation and use the multiplying effect.
How about this one: https://res.cloudinary.com/shirly/image/upload/o_0/l_TemplateSquare,w_380,y_300,x_-450/l_TemplateSquare,w_380,y_100,x_650/l_Kids_Whiteover,e_displace,x_10,y_10/u_kids_white,e_multiply/TemplateSquare.png
Let me know if that result can work for you.

SSRS if field value in list

I've looked through a number of tutorials and asks, and haven't found a working solution to my problem.
Suppose my dataset has two columns: sort_order and field_value. sort_order is an integer and field_value is a numerical (10,2).
I want to format some rows as #,#0 and others as #,#0.00.
Normally I would just do
iif( fields!sort_order.value = 1 or fields!sort_order.value = 23 or .....
unfortunately, the list is fairly long.
I'd like to do the equivalent of if fields!sort_order.value in (1,2,21,63,78,...) then...)
As recommended in another post, I tried the following (if sort in list, then just output a 0, else a 1. this is just to test the functionality of the IN operator):
=iif( fields!sort_order.Value IN split("1,2,3,4,5,6,8,10,11,15,16,17,18,19,20,21,26,30,31,33,34,36,37,38,41,42,44,45,46,49,50,52,53,54,57,58,59,62,63,64,67,68,70,71,75,76,77,80,81,82,92,98,99,113,115,116,120,122,123,127,130,134,136,137,143,144,146,147,148,149,154,155,156,157,162,163,164,165,170,171,172,173,183,184,185,186,192,193,194,195,201,202,203,204,210,211,212,213,263",","),0,1)
However, it doesn't look like the SSRS expression editor wants to accept the "IN" operator. Which is strange, because all the examples I've found that solve this problem use the IN operator.
Any advice?
Try using IndexOf function:
=IIF(Array.IndexOf(split("1,2,3,4,...",","),fields!sort_order.Value)>-1,0,1)
Note all values must be inside quotations.
Consider the recommendation of #Jakub, I recommend this solution if
your are feeding your report via SP and you can't touch it.
Let me know if this helps.

sum+sum equation issue in GAMS

I defined the following equation to calculate the sum of total power consumed by the system:
TotalPower.. systemPower =e= sum(J,P(J)) + sum(I,CP(I));
However, the variable systemPower gets only the result of the second sum and not both!. The declaration of P(J) is as following:
P.LO(I)=0;
P.up(I)=100;
P.l('i1')=2;
P.l('i2')=3;
Please, Can any one explain why I get the result of a single sum? How I can do to get both?. I tried also to separate them in different values but yet I get the same result.
Thank you in advance.
I though it is a good idea to share this it might help someone else. I used a variable directly instead of an equation and I put it in the following form and it worked.
systemPower.l = sum(I,P.l(I))+sum(I,CP(I));

Mathematica- Solve when given random variables and set equations

I'm trying to figure out if there's a way in mathematica where I can solve for particular variables when given other variables and a set of equations. Essentially there are 6 variables, and I'm given 3 of them and have to calculate the others using these equations-
Variables-
B,Qs,f0,R,c,L
Equations-
f0=1/(2*Pi*Sqrt[L*c])
Qs=(w*L)/R
w=2*Pi*f0
B=f0/Qs
We are given the values of any 3 of those variables and have to figure out the rest using those values.
I was thinking perhaps using Eliminate but I'm not sure exactly how that would be structured as I've only used it previously with set variables that don't change and a single output.
When using the Solve function with Mathematica, you can specify for what variables you want Solve to specify the solutions. Note that Solve may not be able to find expressions in terms of these variables (if the equations you give it are contradictory or insufficient) or for all values as some functions have no inverse or only partial inverses.
Your question looks a lot like homework in Electromagnetics, but here is an example with your original problem. You will have to adapt these ideas to give to Solve the set of variables you are looking for. Also remember to use == to specify equality testing. A simple = is for immediate assignment to a variable.
Solve[{f0 == 1/(2*Pi*Sqrt[L*c]), Qs == (w*L)/R, w == 2*Pi*f0, B == f0/Qs}, {f0, B, c}]
{{f0->w/(2 [Pi]), B->w/(2 [Pi] Qs), c->L/(Qs^2 R^2)}}

Mathematica: Commands return no output, but itself. Bug?

I am working with Wolfram Mathematica 8 and have the following problem. I have an optimization problem under certain constraints and want to have an analytical (symbolical solution). I am maximizing function piA. My input is:
piA[a_, WA1_, WA0_] =
a/(1 + a)*(X - (y*WA1 + 1)^(1/y)) - 1/(1 + a) ((y*WA0 + 1)^(1/y));
Maximize[{piA[a, WA1, WA0], WA0 >= -1/y, WA1 >= -1/y}, WA0]
What I get most of the times is:
Maximize[{-((1 + WA0 y)^((1/y))/(1 + a)) + (
a (X - (1 + WA1 y)^(1/y)))/(1 + a), WA0 >= -(1/y), WA1 >= -(1/y)},a]
Basically, the command does nothing, but outputs itself. Only once I have managed to get the proper output (too long to paste here). I have tested it with simpler functions and it works. Unfortunately, I cannot understand what causes the problem. It is not a syntax problem, since it has worked like that several times. Any help would be very much appreciated.
P.S. Just checked again and my input ALWAYS generates the wrong output. The time it generated the solution was when I accidentally set parameters X and y to certain numbers.
The most likely reason is that given the function and constraints, Mathematica doesn't know how to maximize your function with respect to WA0. Note you also have a free variables X and a in there, and it might not have enough information about the domain of X and a to be able to properly form a solution to your equation.
I've had instances where I tried feeding in some equations and constraints and Mathematica simply couldn't do anything with them because they were too general. This may be the case here as well. Is there a specific problem you're trying to solve, and is there any way you could give Mathematica more context?
I don't think this is a bug at all, but it's unfortunate that sometimes Mathematica will just spit back your input when it doesn't have any rules for solving what you gave it.
The usual reason these things happens seems to be when the expressions given are too general for Mathematica to handle, or when it it's faced with a set of expressions that are ill formed.
Just as an example, I tried passing in fractions into a function I wrote that specifically looked for rational expressions, thinking it would work. It turned out that it needed to handle both Rational[a, b] and Times[a, Power[b, -1]]. It could be the case that Mathematica is not expecting a constraint to be of the form GreaterEqual[a, b].
Mathematica returns an answer if you assign the variable a some value. Maybe you could build your strategy on that? In fact it does provide an answer if you assign a value to any of the variables.
( I would need more background of the problem to go from there... )