Ask Your Question
0

max_symbolic, polynomial expressions, assumptions

asked 2021-03-11 13:39:33 +0200

JTS gravatar image

The following works as expected:

var('b')
with assuming(b>1):
    v = max_symbolic(7*b-5,0).full_simplify()
    print(v)

yields 7*b - 5

The following does not (maybe my expectations are unrealistic)

with assuming(b>1):
    v = max_symbolic(b^2-b+1,0).full_simplify()
    print(v)

yields max(0, b^2 - b + 1), even though the latter expression is always > 3/4

I have a bunch of expressions such as the one below, that I want to analyze, to get a piecewise-defined function:

print(myexpr,"\n\n")
print(myexpr.full_simplify(),"\n\n")
with assuming(a>2):
    print(myexpr.full_simplify(),"\n\n")

max(max(3, a + 1) + 2*max(2*max(3, a + 1) + 1, a + max(3, a + 1)), a*max(3, a + 1) + max(2*max(3, a + 1) + 1, a + max(3, a + 1))) 


max(max(3, a + 1) + 2*max(2*max(3, a + 1) + 1, a + max(3, a + 1)), a*max(3, a + 1) + max(2*max(3, a + 1) + 1, a + max(3, a + 1))) 


max(5*a + 7, a^2 + 3*a + 3)

This is good, however:

with assuming(a>2000):
    print(myexpr.full_simplify())

yields max(5a + 7, a^2 + 3a + 3)

Can such expressions, as above, in max_symbolic be converted into piecewise defined functions? (I would also be interested in having more than one parameter, and having SAGE partition the parameter space appropriately and automatically).

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-03-11 21:03:11 +0200

Emmanuel Charpentier gravatar image

updated 2021-03-11 21:04:32 +0200

In short : not a chance...

A few counter-examples :

  • max_symbolic(0, sin(1/x)) (infinity of roots)

  • max_symbolic(0, a_5*x^5 + a_4*x^4 + a_3*x^3 + a_21*x^2 + a_1*x + a_0) (no way to compute roots (if any real...)).

More generally, it has been proved that the problem of the nullity of an arbitrary expression has no solution(i. e. it has been proved that some expressions may be null but not provably so) ; in consequence, there is no guarantee that your expression can be processed to get the roots necessary to write the desired piecewise expression.

HTH,

edit flag offensive delete link more

Comments

Thank you for your answer. I tried restricting the problem to simplifying max of two piecewise linear expressions (hoping to get to max of piecewise polynomial functions with breakpoints that are algebraic and lying in some convenient extension of Q) but I ran into a bug, I think:

a = piecewise([((0,1),x),((1,2),1-x)]).extension(3)
b = piecewise([((0,3/2),3*x-1),((3/2,7/2),7/2-7*(x-3/2))]).extension(4)
xrange = [x/100 for x in range(400)]
p = list_plot([(x,a(x)) for x in xrange])
p +=  list_plot([(x,b(x)) for x in xrange], color='black')
p +=  list_plot([(x,max(a(x),b(x))) for x in xrange], color='red')
show(p)
max_symbolic(a,b).full_simplify()

The plot show the max, again a piecewise linear function, but max_symbolic (or simplify?) throws an exception "R

JTS gravatar imageJTS ( 2021-03-12 11:46:23 +0200 )edit

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: 2021-03-11 13:39:33 +0200

Seen: 159 times

Last updated: Mar 11 '21