cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Require real solutions from the symbolic solver

jstavitsky
1-Newbie

Require real solutions from the symbolic solver

I'd like to get  purely real solution out of the symbolic solver (ie not a product of i) - is it possible to require this? For example solving  x^2 +y^2 = 1 for x should return sqrt(1-y^2).

Am I just failing to use assume keyword correctly?

Thanks

Joe

1 ACCEPTED SOLUTION

Accepted Solutions
lturek
4-Participant
(To:jstavitsky)

Joseph Stavitsky wrote:

I'd like to get  purely real solution out of the symbolic solver (ie not a product of i) - is it possible to require this?

Sometimes, yes.

For example solving  x^2 +y^2 = 1 for x should return sqrt(1-y^2).

Why do you think that sqrt(1-y^2) is "purely" real? Thats only the case if y is real and |y|<1.

Furthermore it would be wrong if MC simply would return that single root as the correct solution is +- the root

Am I just failing to use assume keyword correctly?

How could we tell if you don't show what you are doing??

Unfortunately "assume" is a pita - it may work as expected but very often it doesn't and it may even be completely ignored in some cases.

So forcing MCs symbolics to avoid the imaginary unit in its results can be quite tricky and is unreliable.

Sometimes the order of the keywords matters and sometimes results look differently if, eg, you use a keyword like "simplify" twice. So quite often its a trial an error type of game.

LT

View solution in original post

2 REPLIES 2
lturek
4-Participant
(To:jstavitsky)

Joseph Stavitsky wrote:

I'd like to get  purely real solution out of the symbolic solver (ie not a product of i) - is it possible to require this?

Sometimes, yes.

For example solving  x^2 +y^2 = 1 for x should return sqrt(1-y^2).

Why do you think that sqrt(1-y^2) is "purely" real? Thats only the case if y is real and |y|<1.

Furthermore it would be wrong if MC simply would return that single root as the correct solution is +- the root

Am I just failing to use assume keyword correctly?

How could we tell if you don't show what you are doing??

Unfortunately "assume" is a pita - it may work as expected but very often it doesn't and it may even be completely ignored in some cases.

So forcing MCs symbolics to avoid the imaginary unit in its results can be quite tricky and is unreliable.

Sometimes the order of the keywords matters and sometimes results look differently if, eg, you use a keyword like "simplify" twice. So quite often its a trial an error type of game.

LT

correct on all counts ty

Top Tags