# 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.

edit retag close merge delete

1

Could you please provide some concrete examples of functions you want to deal with ?

( 2018-07-22 05:33:34 -0500 )edit

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 11:24:45 -0500 )edit

It is hard to do in complete generality. The set of values $x$ such that $1/f(x) > 5$ may also be non-empty but without a minimum, e.g. for $f(x) = 1/x$: there is no smallest real number greater than $5$. There may still be an infimum (greatest lower bound), e.g. $5$ in the preceding example. Would you want the infimum as output? Would you be satisfied with an answer for polynomials? Or for rational functions?

( 2018-07-22 11:39:37 -0500 )edit

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 23:56:51 -0500 )edit

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-23 00:12:52 -0500 )edit

Sort by » oldest newest most voted

It is natural to substitute $a=2^x$. Then the following code

var('a');
# a will be 2^x at some point
A = matrix( 4, 4, [ 0,1,1,1, 1,0,a,a, 1,a,0,a, 1,a,a,0 ] )
print "The matrix A is\n%s" % A
print "det(A) = %s" % A.det()
print "The inverse of A is\n%s" % A.inverse()
print "The sum of the entries in A.inverse() is %s" % sum( A.inverse().list() )


delivers:

a
The matrix A is
[0 1 1 1]
[1 0 a a]
[1 a 0 a]
[1 a a 0]
det(A) = -3*a^2
The inverse of A is
[-2/3*a    1/3    1/3    1/3]
[   1/3 -2/3/a  1/3/a  1/3/a]
[   1/3  1/3/a -2/3/a  1/3/a]
[   1/3  1/3/a  1/3/a -2/3/a]
The sum of the entries in A.inverse() is -2/3*a + 2


So for a value of $a$ different from zero we have $\det A\ne 0$. The vanishing ot the sum of the entries of $A^{-1}$ is then what we want, this happens for $a=3$, so the corresponding value of $x$ is the solution of $2^x=a=3$, this is $$x=\log_23\ .$$

P.S.

sage: A.inverse().subs( {a:3} )
[  -2  1/3  1/3  1/3]
[ 1/3 -2/9  1/9  1/9]
[ 1/3  1/9 -2/9  1/9]
[ 1/3  1/9  1/9 -2/9]
sage: sum(_.list())
0

more