I have the following reccurence relation:
T(n) = T(n-1)+ T(n-2) + 1
I tried to expand it but it didn't get me anywhere and I'm stuck. Can someone help please?
expand it like t(n-1)=t(n-2)+t(n-3) and t(n-2)=t(n-3)+t(n-4)
it will give 2+4+8+........2^n=O(2^n) solving gp
Related
Just started a new course (data struct) and having some trouble with a question:
For what F(n) function is this true?
My direction is that it should happen when The N exponent is 1 or less, because that will match the definition of thetha as the function will be closer and bounded by C1*F(n) and C2*F(n), but im not sure about that. Thanks!
Notice that
0n + 1n + 2n + ... + n·n
= n(0 + 1 + 2 + ... + n)
= n(n(n+1)/2)
with that last step following from Gauss's sum. Therefore, the summation is Θ(n3).
I'm studying the same course right now, and I think that if you apply the next rule it might work out.
lim n->inf f(x) / g(x) = c ,
I was taking a derivative in Mathematica and the result containted the term Sqrt', and I was wondering what the ' on the end ment? I believe in means 1/Sqrt from doing the derivative by hand but if someone could confirm this is how the result is displayed I would appreciate it. Here is my input and output.
In f[p_] := cSqrt[(m^2)*(c^2) + (p - eA/c)^2] + e*phi
In f'[p]
Out 2 (-(eA/c) + p) Derivative[1][cSqrt][c^2 m^2 + (-(eA/c) + p)^2]
Best,
Ben
This may help:
http://blog.wolfram.com/2011/05/20/mathematica-qa-three-functions-for-computing-derivatives/
Apparently ' is the standard shorthand notation for the derivative.
Using code FullSimplify[Abs[q + I*w], Element[{q, w}, Reals]] results in
Abs[q + I w]
and not
Sqrt[q^2 + w^2]
What am I missing?
P.S. Assuming[{q \[Element] Reals, w \[Element] Reals},
Abs[q + I*w]] does not work either.
Note: Simplify[Abs[w]^2, Element[{q, w}, Reals]] and Simplify[Abs[I*q]^2, Element[{q, w}, Reals]] work.
The problem is that what you assume to be "Simple" and what MMA assumes to be simple are two different things. Taking a look at ComplexityFunction indicates that MMA primarily looks at "LeafCount". Applying LeafCount gives:
In[3]:= Abs[q + I w] // LeafCount
Out[3]= 8
In[4]:= Sqrt[q^2 + w^2] // LeafCount
Out[4]= 11
So, MMA considers the Abs form to be better. (One can visually explore the simplicity using either TreeForm or FullForm). What we need to do is tell MMA to treat MMA as more expensive. To do this, we take the example from ComplexityFunction and write:
In[7]:= f[e_] := 100 Count[e, _Abs, {0, Infinity}] + LeafCount[e]
FullSimplify[Abs[q + I w], Element[{q, w}, Reals],
ComplexityFunction -> f]
Out[8]= Sqrt[q^2 + w^2]
As requested. Basically, we are telling MMA through f[e] that the count of all parts of the form Abs should count as 100 leaves.
EDIT: As mentioned by Brett, you can also make it more general, and use _Complex as the rule to look for:
In[20]:= f[e_] := 100 Count[e, _Complex, {0, Infinity}] + LeafCount[e]
FullSimplify[Abs[q + I w], Element[{q, w}, Reals],
ComplexityFunction -> f]
Out[21]= Sqrt[q^2 + w^2]
I suggest using ComplexExpand, which tells the system that all variables are real.
In[28]:= Abs[q + I*w] // ComplexExpand
Out[28]= Sqrt[q^2 + w^2]
These comments are not helpful. Mathematica is failing to evaluate complex numbers, as in Abs[5+i20] is left unchanged. The i is coded correctly. Making abstract observations about 'what is or is not simple' is unrelated and wrong. There is a float that should result, not some algebra. N and ImportForm do not work, either.
First of all, math is not my area.
Imagine a problem like this:
I have a number of money to spend, say 500, and i need to spend them on a fixed number of days, say 20. I have a fixed maximum of money to spend per day, like 50. I don't need to spend money on a day.
Now i need to know how to calculate the total number of money I have to spend each day to get a spending curve like the following:
My goal is a function that takes a number of money and a number of days, and returns an tuple with day number and ammount of money for that day.
I know i need to use logarithms of some type, and i've tried pretty much everything that my brain can handle. I've been looking at wolfram mathworld and this formula:
y = a + b ln x
But it does not really help me.
An hint or example in PHP, Python or C# would be great, but any language will do.
PLEASE let me know if you need any more information or if the question is vague, I really want to solve this. Thank you!
I don't understand why you want a log distribution. A parabolic one will do to obtain the curve form you want:
spend[day] = a day^2 + c
where:
a -> (6 * (TD - TA)) / (TD *(-1 - 3 * TD + 4 * TD^2))
c -> -((1 + 3 * TD - 6*TA*TD + 2 * TD^2)/ (-1 - 3 * TD + 4 * TD^2))
TA = Total Amount
TD = Total Days
With this the amount you spend the last day is 1.
For your example values: (amt 500, days 20)
Are you sure what you are asking for is not a linear equation?
For example
y=f(x)=-50x+500 and the total number of days would be x where y=0.
Does anyone know how to minimize a function containing an integral in MATLAB? The function looks like this:
L = Int(t=0,t=T)[(AR-x)dt], A is a system parameter and R and x are related through:
dR/dt = axRY - bR, where a and b are constants.
dY/dt = -xRY
I read somewhere that I can use fminbnd and quad in combination but I am not able to make it work. Any suggestions?
Perhaps you could give more details of your integral, e.g. where is the missing bracket in [AR-x)dt]? Is there any dependence of x on t, or can we integrate dR/dt = axR - bR to give R=C*exp((a*x-b)*t)? In any case, to answer your question on fminbnd and quad, you could set A,C,T,a,b,xmin and xmax (the last two are the range you want to look for the min over) and use:
[x fval] = fminbnd(#(x) quad(#(t)A*C*exp((a*x-b)*t)-x,0,T),xmin,xmax)
This finds x that minimizes the integral.
If i didn't get it wrong you are trying to minimize respect to t:
\int_0^t{(AR-x) dt}
well then you just need to find the zeros of:
AR-x
This is just math, not matlab ;)
Here's some manipulation of your equations that might help.
Combining the second and third equations you gave gives
dR/dt = -a*(dY/dt)-bR
Now if we solve for R on the righthand side and plug it into the first equation you gave we get
L = Int(t=0,t=T)[(-A/b*(dR/dt + a*dY/dt) - x)dt]
Now we can integrate the first term to get:
L = -A/b*[R(T) - R(0) + Y(T) - Y(0)] - Int(t=0,t=T)[(x)dt]
So now all that matters with regards to R and Y are the endpoints. In fact, you may as well define a new function, Z which equals Y + R. Then you get
L = -A/b*[Z(T) - Z(0)] - Int(t=0,t=T)[(x)dt]
This next part I'm not as confident in. The integral of x with respect to t will give some function which is evaluated at t = 0 and t = T. This function we will call X to give:
L = -A/b*[Z(T) - Z(0)] - X(T) + X(0)
This equation holds true for all T, so we can set T to t if we want to.
L = -A/b*[Z(t) - Z(0)] - X(t) + X(0)
Also, we can group a lot of the constants together and call them C to give
X(t) = -A/b*Z(t) + C
where
C = A/b*Z(0) + X(0) - L
So I'm not sure what else to do with this, but I've shown that the integral of x(t) is linearly related to Z(t) = R(t) + Y(t). It seems to me that there are many equations that solve this. Anyone else see where to go from here? Any problems with my math?