Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.6K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Tell a function the argument is positive?

Posted 6 years ago

Hi all, would be grateful to help with the following. Consider the code:

p = x /. Solve[(a - x)/y^2 == 1, x];
q = ((3 a - 2 p)/(4 y^2));
f[x_] = x Sign[x] ;
Assuming[q > 0, Simplify[f[q]]]

The output is:

((a + 2 y^2) Sign[a + 2 y^2])/(4 y^2 Sign[y]^2)

I am trying to tell function f[] that it's argument is positive, and hence Sign[] operator is +1. However, Sign operator is still in the Out cell.

By the way, if I remove the first line in which p is defined via Solve, everything works fine. It's something about the fact that q depends on an output from a function that makes "Assuming q>0" work incorrectly

What's wrong?

POSTED BY: Sergey Volochkov
5 Replies

Try FullSimplify instead of Simplify...

POSTED BY: Gianluca Gorni

Gianluca, your solution stops working again with a small change in the equation being solved in the first line. In particular, if take your code and change only the first line to:

p = x /. Solve[(a - x)/(c y^2)+(b - x)/(d y^2) == 1, x][[1]];

Then again, Sign appears in the answer, disappointingly. If you know how to get rid of it, it would help me a lot.

POSTED BY: Sergey Volochkov

I really don't know. I discovered it by chance.

POSTED BY: Gianluca Gorni

Thanks a lot, Gianluca! Can you briefly explain, or point towards the relevant section in the documentation, how does the internal engine of Mathematica interpret {a/b}>0 and why it is different from a/b>0. I mean I don't get an error, so in terms of synthax both are acceptible. But somehow Mathematica cannot figure out what I mean when it sees {a/b}>0. Then, what DOES it see.

Thanks again!

POSTED BY: Sergey Volochkov

This way it works:

p = x /. Solve[(a - x)/y^2 == 1, x][[1]];
q = ((3 a - 2 p)/(4 y^2));
f[x_] = x Sign[x];
Assuming[q > 0, Simplify[f[q]]]

Compare

Assuming[{a/b} > 0, Simplify@Sign[a/b]]
Assuming[a/b > 0, Simplify@Sign[a/b]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard