# Deepak Sarma's profile - activity

2018-07-25 06:48:40 -0600 asked a question Smallest positive numerical solution of an equation in one variable

I have some functions, all of which are functions of variable $x$ but some of them may not have any positive solutions. It is known that at least one of them have a positive solution. Now I need a list of all smallest positive solutions for those functions. For example consider $f=x^2+3x+2$ and $g=2^{(5x + 1)} - 3.2^{(3x + 1)}$. Here $f$ doesn't have any positive root but $g$ has (0.792481250360578). I want a sage code like min(solve([f,x>1],x))+min(solve([g,x>1],x)) to get the list as [0.792481250360578]. Thank you in advance.

2018-07-25 01:39:42 -0600 commented answer Optimizing a function of a given matrix

Thank you for your solution. It works with that particular matrix. But it doesn't work for all matrices.

For example consider $$A=\left(\begin{array}{rrrrr} 0 & 2^{x} & 1 & 1 & 1 \ 2^{x} & 0 & 1 & 1 & 1 \ 1 & 1 & 0 & 2^{x} & 2^{x} \ 1 & 1 & 2^{x} & 0 & 2^{x} \ 1 & 1 & 2^{x} & 2^{x} & 0 \end{array}\right)$$

or

$$A=\left(\begin{array}{rrrr} 0 & 1 & 2^{x} & 1 \ 1 & 0 & 1 & 2^{x} \ 2^{x} & 1 & 0 & 1 \ 1 & 2^{x} & 1 & 0 \end{array}\right)$$

Here I get an error "cannot evaluate symbolic expression numerically"

Note: For all my matrices, it is known that the solution is at most equal to 2. So if something like min(find_root(X,0,2)+find_root(Y,0,2)) could be used, that is also enough for me.

2018-07-24 22:49:07 -0600 commented answer Optimizing a function of a given matrix

Actually, I was stuck at this step. I tried the code "solve" to solve the two systems, but I don't get numerical value from this. Again I tried "find_root" code with the interval but one of the systems (First one) does not have a solution, and so it gives a long list of errors. Therefore I cannot evaluate the minimum of all solutions (min() doesn't work). For this particular matrix, I can find it by direct calculation. But what I need a general method to get my required (numerical value) whenever I input a matrix as a function of $x$. I need something like this

X=det(A); Y=sum((~A).list()); S=solve([X,x>0],x); T=solve([Y,x>0],x); min(S+T)

This doesn't give me numerical value. Note the last step, I want sage to calculate the minimum value of the ...

2018-07-23 09:50:52 -0600 asked a question Optimizing a function of a given matrix

Let us consider the $4\times 4$ symmetric matrix $$A_x=\left(\begin{array}{rrrr} 0 & 1 & 1 & 1 \ 1 & 0 & 2^x & 2^x \ 1 & 2^x & 0 & 2^x \ 1 & 2^x & 2^x & 0 \end{array}\right)$$

Here I need to find $\min { x>0: det(A_x)=0 \, or \, ||A_x^{-1}||=0 } ,$ where by $||M||$ we mean the sum of all entries of the matrix $M.$ I'm looking for a general sage program where my input will be a matrix with entries as functions of an inderminant (like the matrix $A_x$ above) which will give me the unique $x$ corresponding to my matrix. If no such real value exists, it should result as $\infty$ Can anyone help me? Thank you in advance.

2018-07-23 00:12:52 -0600 commented question Optimal solution

Let us consider the $4\times 4$ symmetric matrix $$A_x=\left(\begin{array}{rrrr} 0 & 1 & 1 & 1 \\ 1 & 0 & 2^x & 2^x \\ 1 & 2^x & 0 & 2^x \\ 1 & 2^x & 2^x & 0 \end{array}\right)$$

Here I need to find $\min { x>0: det(A_x)=0 \, or \, ||A_x^{-1}||=0 } ,$ where by $||M||$ we mean the sum of all entries of the matrix $M.$ If anyone helps me solving this problem using sage, this will be enough for me. Thank you

2018-07-22 23:56:51 -0600 commented question Optimal solution

Most of my functions are not rationals., For example, I have some functions like $f(x)=4.12^x-4.9^x-7.8^x+8.4^x+8.3^x-4.$ Can you please write a program that works for the two functions that I have mentioned?

2018-07-22 11:24:45 -0600 commented question Optimal solution

Actually, I need to check different kinds of functions. So I need a sage program where I can input any kind of such functions to get the result. Simply you can consider $f(x)=x^3-2x^2-2x+4.$ But a general sage program will be more helpful. Thank you.

2018-07-22 04:49:39 -0600 asked a question Optimal solution

If $f(x)$ is a given real valued function, then how to find the minimum value of $x>0$ such that either $\frac{1}{f(x)}>5$ or $f(x)=0.$ If no such $x$ exist then it should return $\infty$ as output. If anyone write the sage code for me by considering any real valued function it would be helpful for me. Thank you in advance.

2018-04-16 22:46:54 -0600 commented answer Pairs of graphs with same spectral radius but with different diameter and different number of edges

Thank you for the detail explanation. But what I see here we will get the graphs with same spectral radius and then we have check ourselves for graphs with different diameter and no of edges. But what to do if I want to write the program in such a way that it checks everything itself and finally give me a pair (or all such pairs) of my requirement?

2018-04-12 00:47:21 -0600 asked a question Pairs of graphs with same spectral radius but with different diameter and different number of edges

I know that graphs.cospectral_graphs() gives all pairs of graphs with same eigenvalues. But I need graphs with same spectral radius i.e. largest eigenvalue (the other eigenvalues may be different) and differing in diameter and number of edges. What to do for this? Thank you in advance.

2018-01-09 01:03:31 -0600 asked a question Complimentary eigenvalue of a matrix

How to obtain all the complimentary eigenvalues (also associated complimentary eigenvectors) of a given matrix. Complimentary eigenvalues and eigenvectors of a given matrix $A$ of order $n\times n$ is the solution to the following system

$x≥0_n$, $Ax−λx≥0_n$ and $⟨x, Ax−λx⟩=0$ where $x(\neq 0_n)\in R^n$

2018-01-08 02:17:55 -0600 commented answer List of all dominating sets in a graph

Thank you for your answer. But complement of an independent set is a vertex cover only for connected graph. How to include disconnected graphs here? And what about the first question, how to obtain all the dominating sets?

2018-01-05 03:24:11 -0600 asked a question List of all dominating sets in a graph

The inbuilt function in sage for dominating set of a graph $G$ is

# G.dominating_set()

But this gives only a minimum dominating set of the graph. What I want is the list of all dominating sets of the graph. How to get this? Besides in the inbuilt function we have some additional options, like dominating_set(independent=True) which gives a minimum independent dominating set of the graph. Now if I want a minimum dominating set with some other properties, how to set it? For example if I need a minimal dominating set D so that $D^c$(complement of D) is independent.

2017-11-22 12:28:36 -0600 commented question Random matrix satisfying a given polynomial

Sorry, I typed it wrong, I meant of the first polynomial you have written. But its immaterial, I just need an example how to construct such an example. you can consider any of the above polynomial(or any other suitable polynomial) to illustrate.

2017-11-22 11:06:58 -0600 commented question Random matrix satisfying a given polynomial

I want a particular solution. Suppose I want to get an example of a $5 \times 5$ matrix $A$ with real entries that satisfies $A^4+3A-2A+I=0$

2017-11-22 04:38:13 -0600 asked a question Random matrix satisfying a given polynomial

If a polynomial f(x) of order n is given, can we find a random square matrix A of order m so that f(A)=0?

I tried to construct it by finding the roots of f(x) and then creating random matrix with those roots as eigenvalues. But the problem occurs when n is not equal to m. I'm unable to set the eigenvalue, dimensions suitably.

2017-11-20 23:01:49 -0600 asked a question Variable matrices

If I type

sage: M = matrix(SR, 2, var('a,b,c,d'))
sage: show(~M)


it gives me the inverse of the matrix M with entries in terms of a, b, c, d.

Now what I want is to set four variable matrices A, B, C, D, each of size 2x2, and then I want to create the block matrix

sage: N = block_matrix([[A, B], [C, D]])


Finally I want some functions of N in terms of A, B, C, D.

For example, how can I get det(N) in terms of A, B, C, D?

2017-11-17 23:19:36 -0600 answered a question summation of matrices

L=[random_matrix(ZZ,5,5) for _ in range(1,10)]; sum(L[i] for i in range (0,9))

2017-11-17 07:04:44 -0600 commented answer summation of matrices

Thank you.

2017-11-17 05:15:03 -0600 asked a question summation of matrices

Can we use sum function to add a number of matrices? If not, then how to add a number of matrices with just a single command. Suppose I want to create 10 random matrices of order 5x5 and then want their sum as a result. I tried the following command, but it didn't work.

A_{i}=random_matrix(ZZ,5,5) for i in range(1,10); sum(A_{i}, i, 1, 10)

Note: I even could not generate 10 random matrices with the above command.