Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

Restricting a variable to a (real) range

asked 5 years ago

Dox gravatar image

Hi. I'm solving a differential equation which depends on two parameters c1 and c2. They are both positive

assume(c1 > 0)
assume(c2 > 0)

but in order to solve the equation, maxima ask me whether c2-3 is positive, negative or zero. With the condition

assume(c2 - 3 > 0)

the equation is solved; But imposing c2 - 3 < 0 triggers and inconsistency... I believe that it is due to the initial assumption.

Question

Is it possible to set a condition like assume(0 < c2 < 3)?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 5 years ago

dsejas gravatar image

updated 5 years ago

Hello, @Dox. I am not completely sure what the inconsistency you mention is, but maybe it is due to the fact of using two assumes that clash with each other. You said you used

assume(c2 - 3 > 0)

and then you used

assume(c2 - 3 < 0)

So you are effectively telling Sage that c2>3 AND c2<3 at the same time, which represents an inconsistency. You can check this by calling

assumptions()

If both assumptions are there, you made a mistake.

The way to proceed is, once you have finished solving your problem with assume(c2 - 3 > 0) and you have your answer, you should use

forget(c2 - 3 > 0)

and then you can call assume(c2 - 3 < 0) without triggering an inconsistency. (You can check the effect of forget by calling assumptions again.)

Another way to proceed is the following: you should forget the previous assumptions that you made about c2, and then you can call

assume(0 < c2)
assume(c2 < 3)

These will effectively restrict c2 to the range (0,3). (Once again, you can check this, by calling assumptions().)

I hope this helps!

Preview: (hide)
link

Comments

Thank you @dsejas Yes, your comment was incredible useful! It drove me to a nice solution. Since I had a lot of assumptions, I was trying to find a way to drop the last assumption (still don't know it possible), and looking for that I found the with assuming(condition): code statement, which execute the code assuming the condition without registering in the assumptions() list! Thank you very much!

Dox gravatar imageDox ( 5 years ago )

Hello, @Dox. I'm glad that my answer could help. Actually, I didn't know the syntax

with assuming(condition):    code

Really nice!. However, when you say you were "trying to find a way to drop the last assumption (still don't know if possible)", doesn't the forget(<last_assumption_you_made>) syntax solve your problem? Maybe I can help with that too.

dsejas gravatar imagedsejas ( 5 years ago )

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: 5 years ago

Seen: 1,041 times

Last updated: May 17 '19