T(n) = T(n/k) + (k − 1)
Suppose we set 𝑘 =. √n how to Find asymptotic running of T(n). any ideas or help is appreciated ..thanks
Related
a - O(n^(log_3 4))
b - Theta(n log n)
c - Theta(n^2).
d - O(n)
e - Theta(n^(log_4 3))
Essentially your problem is a recurrence relationship like this;
T(n) = 5*T(n/3) + Theta(n^2)
You can use what is called the Master Theorem
to get an answer for this.
Your parameters are: a:=3 b:=5 and f(n):=n^2. I'm sure from here you can solve your question and get your answer.
I have a non-linear optimization problem which, in Mathematica, could be solved as:
FindMaximum[{(81 x + 19)^0.4 + (80 (1 - x) + 20)^0.6, 0 <= x <= 1}, x]
However, now I am on a computer without Mathematica and I would like to solve a similar problem in Python, using the CVXOPT module. I looked at the examples and found linear programs, quadratic programs, and other kinds of programs, but could not find this simple program.
Can I solve such a program with CVXOPT?
I did not find a solution with cvxopt, but I found a much better alternative - cvxpy:
import cvxpy as cp
x = cp.Variable()
prob = cp.Problem(
cp.Maximize((81*x + 19)**0.6 + (80*(1-x)+20)**0.6),
[0 <= x, x <= 1])
prob.solve() # Returns the optimal value.
print("status:", prob.status)
print("optimal value", prob.value)
print("optimal var", x.value)
Prints:
status: optimal
optimal value 23.27298502822502
optimal var 0.5145387371825181
Can someone show me how to isolate K in the following equation? (I want to use excel to find K, and I will know a,b,c,d,and f, so I need K isolated):
a = (b/c * exp(-K*d)+a)*exp(-Kf)
I am having a bit of trouble with Sympy's solveset. I am trying to use Sympy to find a solution to an basic circuit analysis question involving three unknown resistors and two equations. I realize that I will have to guess at the value of one of the resistors and then calculate the value of the other two resistors. I am using superposition to solve the circuit.
This is the circuit and superposition I am trying to solve
import sympy
V_outa, V_outb, R_1, R_2, R_3, V_1, V_2 = symbols('V_outa V_outb R_1 R_2 R_3 V_1 V_2')
### Here are a bunch of variable definitions.
R_eq12 = R_2*R_3/(R_2+R_3)
R_eq123 = R_eq12 + R_1
V_outa = V_1 *R_eq12/R_eq123
R_eq13 = R_1*R_3/(R_1+R_3)
R_eq123b = R_2 + R_eq13
V_outb = V_2 * R_eq13/R_eq123b
### Here is my governing equation.
V_out = 0.5* V_outb + (1/6) *V_outa
### Now I can start setting up the equations to solve. This sets the
### coefficient of the V1 term equal to the 1/2 in the governing equation
### and the coefficient of the V2 term equal to 1/6. I have also guessed
### that R_3 is equal to 10 ohms.
eq1 = Eq(1.0/2.0, V_out.coeff(V_2).subs(R_3, 10))
eq2 = Eq(1.0/6.0, V_out.coeff(V_2).subs(R_3, 10))
#### Now when I try to solve eq1 and eq2 with solveset, I get an error.
solveset([eq1, eq2], (R_2, R_3))
And here is the error I get:
ValueError: [Eq(0.500000000000000, 10*R_1/((R_1 + 10)*(10*R_1/(R_1 +
10) + R_2))), Eq(0.166666666666667, 10*R_1/((R_1 + 10)*(10*R_1/(R_1 +
10) + R_2)))] is not a valid SymPy expression
The other thing I don't understand is the set type I get when I try to solve it this way. Could someone also explain what set type this is, and how to make use of it?
expr3 = -1.0/2.0 + V_out.coeff(V_2).subs(R_3, 10)
solveset(expr3, R_2)
A screen shot of the weird set type
Any help would be much appreciated. I know it is a solvable set because Wolfram Alpha had no problems with it.
Thanks!
David
The problem link is here. The problem is basically to count all such sub matrices of a given matrix of size N by M, whose sum of elements is between A and B inclusive. N,M<=250. 10^-9<=A<=B<=10^9.
People have solved it using DP and BIT. I am not clear how.
First, i tried to solve a simpler version, 1-D case of the above problem: Given an array A, of length N, count all subarrays, where sum of elements in the subarray lies between A and B, but still couldn't think of better than O(n^2). Here is what i did :
I thought of making another array for keeping prefix sum of the original array, say prefix[N]. prefix[i] = A1 + A[2] + A[3] + ...A[i]. set prefix[ 1] = A [ 1]. Then for each i from 2 to N, problem is to count all j <= i such that sum Z = A[j] + A[j+1] + ..A[i] lies between A and B. This is equivalent to prefix[i] - prefix[j-1]. But it's still O(n^2), as for each i, j is hitting i places.
can anybody help me step by step to advance me in the given approach to solve the main problem ?.