Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

Optimal solution

asked 6 years ago

Deepak Sarma gravatar image

If f(x) is a given real valued function, then how to find the minimum value of x>0 such that either 1f(x)>5 or f(x)=0. If no such x exist then it should return 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.

Preview: (hide)

Comments

1

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

tmonteil gravatar imagetmonteil ( 6 years ago )

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)=x32x22x+4. But a general sage program will be more helpful. Thank you.

Deepak Sarma gravatar imageDeepak Sarma ( 6 years ago )

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?

rburing gravatar imagerburing ( 6 years ago )

Most of my functions are not rationals., For example, I have some functions like f(x)=4.12x4.9x7.8x+8.4x+8.3x4. Can you please write a program that works for the two functions that I have mentioned?

Deepak Sarma gravatar imageDeepak Sarma ( 6 years ago )

Let us consider the 4×4 symmetric matrix Ax=(0111102x2x12x02x12x2x0)

Here I need to find minx>0:det(Ax)=0or||A1x||=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

Deepak Sarma gravatar imageDeepak Sarma ( 6 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 6 years ago

dan_fulea gravatar image

It is natural to substitute a=2x. 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 detA0. The vanishing ot the sum of the entries of A1 is then what we want, this happens for a=3, so the corresponding value of x is the solution of 2x=a=3, this is x=log23 .

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
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 6 years ago

Seen: 880 times

Last updated: Jul 25 '18