Sympy assumptions

397 views
Skip to first unread message

Paul Royik

unread,
Dec 4, 2014, 9:38:00 AM12/4/14
to sy...@googlegroups.com
Suppose that I have an expression

e = x**2+sqrt(a**2*b**2)
What is the best way to assign to expression assumption that all variables are Positive, so that equivalent of e is x**2+ab?

Ondřej Čertík

unread,
Dec 4, 2014, 11:29:27 AM12/4/14
to sympy
It should be done like this:

In [11]: refine(e, Q.positive(a) & Q.positive(b))
Out[11]:
_______
2 ╱ 2 2
x + ╲╱ a ⋅b


But unfortunately that doesn't work. So the only other way is the old
way like this:

In [12]: a = Symbol("a", positive=True)

In [13]: b = Symbol("b", positive=True)

In [14]: x**2+sqrt(a**2*b**2)
Out[14]:
2
a⋅b + x


Ondrej

Paul Royik

unread,
Dec 4, 2014, 12:25:54 PM12/4/14
to sy...@googlegroups.com
I know this way, but is there any way to change  this after symbol creation?

Ondřej Čertík

unread,
Dec 4, 2014, 12:52:41 PM12/4/14
to sympy
On Thu, Dec 4, 2014 at 10:25 AM, Paul Royik <distan...@gmail.com> wrote:
> I know this way, but is there any way to change this after symbol creation?

The right way in my opinion is to just create a symbol with no
assumptions and then use refine(). As I wrote below, it doesn't yet
work for this case, but it will in the future. If you have time, we
would appreciate any help with this.

Ondrej
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/0057f9b0-377e-4409-aee8-d8284e1e0f06%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Francesco Bonazzi

unread,
Dec 5, 2014, 4:34:19 PM12/5/14
to sy...@googlegroups.com
newvars =symbols('x a b', integer=True)
e.xreplace(dict(zip([x,a,b], newvars)))

I did not test this.

Aaron Meurer

unread,
Dec 5, 2014, 4:49:35 PM12/5/14
to sy...@googlegroups.com
They need to be positive. Even for integer x, sqrt(x**2) != x if x is negative.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/75aa630a-4b0e-46b0-ac20-0f4ffff34f28%40googlegroups.com.

Richard Fateman

unread,
Dec 5, 2014, 6:48:32 PM12/5/14
to sy...@googlegroups.com
You are heading into erroneous waters.
It doesn't matter that 3>0.  sqrt(9) has two values,  +3 and -3.
Just because some other systems make this mistake does not mean
sympy should do this.

If you want to say something about the choice of branch for sqrt(x^2),
you have to say something about sqrt(x^2), not x.

It may be sensible if you mean to restrict the square root function.
But not that way.
Good luck

Francesco Bonazzi

unread,
Dec 5, 2014, 7:55:20 PM12/5/14
to sy...@googlegroups.com
Sorry I mistyped.

Yuxiang Wang

unread,
Dec 6, 2014, 11:03:06 AM12/6/14
to sy...@googlegroups.com
Hi Richard,

I do get your point that we don't have to make the same mistake with other systems, but I do think there is a benefit for consistency, if they have a purpose in doing that design. For most systems, sqrt() returns the principal/positive square root, so there is only one unique value. If we'd like a function to return all square roots, we can create another function dedicated to do that with a new name.

My two cents,

Shawn

Ondřej Čertík

unread,
Dec 6, 2014, 12:37:14 PM12/6/14
to sympy
Hi Richard,

On Fri, Dec 5, 2014 at 4:48 PM, Richard Fateman <fat...@gmail.com> wrote:
> You are heading into erroneous waters.
> It doesn't matter that 3>0. sqrt(9) has two values, +3 and -3.
> Just because some other systems make this mistake does not mean
> sympy should do this.
>
> If you want to say something about the choice of branch for sqrt(x^2),
> you have to say something about sqrt(x^2), not x.
>
> It may be sensible if you mean to restrict the square root function.
> But not that way.
> Good luck

Do you know any computer algebra system that treats functions as
multivalued, i.e. sqrt(9) returns both +3 and -3?
I would like to play with it. Incidentally, I've spent lot of time
lately thinking about how complex functions can be implemented in a
CAS, see e.g. these threads:

https://github.com/sympy/sympy/issues/8502
https://groups.google.com/forum/#!topic/sage-devel/6j-LcC6tpkE/discussion

Essentially there are two consistent ways --- either treat functions
as multivalued or as singlevalued (on a principal branch).

Ondrej

Aaron Meurer

unread,
Dec 6, 2014, 3:01:38 PM12/6/14
to sy...@googlegroups.com
Something that I'm not sure about with representing functions as
multivalued is, how do you represent arbitrary Riemann surfaces.

Another question is computational. How do you compute the surfaces in
general (say even for a limited class of expressions, like algebraic
functions), and how do you make cuts in a consistent manner?

The only thing I can think of is to write everything in terms of exp()
and log() and parameterized integers, e.g., sqrt(x) should really be
exp((log(x) + 2*pi*I*n)/2) for integer. This basically boils down to
sqrt(x) = +/- sqrt(x). Each rational power has to have a distinct
parameterized integer. This should lead to correct and general results
if you do it correctly, but I don't really see how to compute useful
things from this without getting huge expressions with tons of
parameterized integers.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVDVLVn1HjJTipQzMh3a5Ud2RyQcQMczg5LE_X4X-1S3VQ%40mail.gmail.com.

Joachim Durchholz

unread,
Dec 6, 2014, 7:01:32 PM12/6/14
to sy...@googlegroups.com
Am 06.12.2014 um 17:03 schrieb Yuxiang Wang:
> Hi Richard,
>
> I do get your point that we don't have to make the same mistake with other
> systems, but I do think there is a benefit for consistency, if they have a
> purpose in doing that design. For most systems, sqrt() returns the
> principal/positive square root, so there is only one unique value.

What's your list of "most" systems?
'cause numeric evaluation is quite different from symbolic math, and I
suspect that those "most" systems are those that do numeric calculations
- but that's just a hunch and I'd like to know for sure.

Ondřej Čertík

unread,
Dec 6, 2014, 7:31:00 PM12/6/14
to sympy
On Sat, Dec 6, 2014 at 1:01 PM, Aaron Meurer <asme...@gmail.com> wrote:
> Something that I'm not sure about with representing functions as
> multivalued is, how do you represent arbitrary Riemann surfaces.
>
> Another question is computational. How do you compute the surfaces in
> general (say even for a limited class of expressions, like algebraic
> functions), and how do you make cuts in a consistent manner?
>
> The only thing I can think of is to write everything in terms of exp()
> and log() and parameterized integers, e.g., sqrt(x) should really be
> exp((log(x) + 2*pi*I*n)/2) for integer. This basically boils down to
> sqrt(x) = +/- sqrt(x). Each rational power has to have a distinct
> parameterized integer. This should lead to correct and general results

Exactly. And sometimes you can absorb the 2*pi*n factors into the
multivalued function itself, for example you can just write:

log(a*b) = log(a) + log(b)

However, then, when you subtract this, you need to write this as:

log(a*b) - log(a) - log(b) = 2*pi*I*n

Also, when you evaluate things numerically, you need to keep the
2*pi*n factors around, for example in the above for a=b=-1, you need
to evaluate numerically as:

LHS: log((-1)*(-1)) = log(1) = 0 + 2*pi*I*n
RHS: log(-1) + log(-1) = (I*pi + 2*pi*I*k) + (I*pi + 2*pi*I*l) = 2*pi*I*(1+k+l)

So the multivalues on LHS and RHS are obviously equal. But if you
evaluate without the 2*pi*n factors, you get 0 = 2*pi*I, which is not
equal to each other.

> if you do it correctly, but I don't really see how to compute useful
> things from this without getting huge expressions with tons of
> parameterized integers.

I think there is probably a way to simplify things in many cases, but
it seems it is much more complicated than just using single values on
a principal branch, as we do in sympy currently.

Ondrej

Yuxiang Wang

unread,
Dec 6, 2014, 10:41:26 PM12/6/14
to sy...@googlegroups.com
Hi Joachim,

I was thinking of Mathematica and MATLAB Symbolic Toolbox, and both doing symbolic math rather than numerical systems. My experience is limited to these two though (that's the two my institution got a license for), so I'd be open to hear on more example / counter-examples.

-Shawn

Joachim Durchholz

unread,
Dec 7, 2014, 5:11:23 AM12/7/14
to sy...@googlegroups.com
Am 07.12.2014 um 04:41 schrieb Yuxiang Wang:
> Hi Joachim,
>
> I was thinking of Mathematica and MATLAB Symbolic Toolbox, and both doing
> symbolic math rather than numerical systems.

Ah okay, then my hunch was wrong. Good to know.

> My experience is limited to
> these two though (that's the two my institution got a license for), so I'd
> be open to hear on more example / counter-examples.

Let's see who else can contribute observations :-)

Joachim Durchholz

unread,
Dec 7, 2014, 5:21:44 AM12/7/14
to sy...@googlegroups.com
Am 07.12.2014 um 01:30 schrieb Ondřej Čertík:
> However, then, when you subtract this, you need to write this as:
>
> log(a*b) - log(a) - log(b) = 2*pi*I*n

Wouldn't you need to write

> log(a*b) = log(a) + log(b)

as

> log(a*b) = log(a) + log(b) + 2*pi*I*n

as well?

> I think there is probably a way to simplify things in many cases, but
> it seems it is much more complicated than just using single values on
> a principal branch, as we do in sympy currently.

Then we're already missing equalities that combine the value from the
principal branch with the value from any nonprincipal branch.
E.g. we wouldn't find all equalities on expressions that combine sin x
and sin 2x (for one trivial example). And there are interesting
equalities of that kind out there.

Joachim Durchholz

unread,
Dec 7, 2014, 5:33:20 AM12/7/14
to sy...@googlegroups.com
Am 06.12.2014 um 21:01 schrieb Aaron Meurer:
> Something that I'm not sure about with representing functions as
> multivalued is, how do you represent arbitrary Riemann surfaces.
>
> Another question is computational. How do you compute the surfaces in
> general (say even for a limited class of expressions, like algebraic
> functions), and how do you make cuts in a consistent manner?

I do not thing that consistent cuts are a well-defined concept in the
first place.
Consider having sin 2x and sin x in the same expression. (Or something
equivalent in log and exp.)
Things become more, er, interesting with more free variables (x, y, z, ...)

To catch all equalities:
- Parameterize them all with an integer.
- For n integer parameters, search Z^n (exploiting periods).

This might turn out to be too slow to be useful.
OTOH it might help with some simplifications.

> The only thing I can think of is to write everything in terms of exp()
> and log() and parameterized integers,

Can everything be broken down into this?
I'd have expected that not, since the cardinality of the set of
functions isn't countable, but maybe it's just that all practically
relevant expressions can be broken down that way, or maybe there's some
result that indeed everything multivalued can be written that way.

Richard Fateman

unread,
Dec 10, 2014, 6:40:38 PM12/10/14
to sy...@googlegroups.com
1994 paper by Adam Dingle and Richard Fateman 
Branch Cuts in Computer Algebra,  (ISSAC '94 proceedings. also search online).

When you say things about sqrt(), does it generalize to cuberoot?  If it
does not, you are in trouble, or will be down the road.

What is the principal value of  (1)^(1/6) ?  

Several systems have  RootOf( ...)  expressions.  e.g.  RootOf(s^2=x, s).
There are 2 values for s.   What systems?
Maple
Macsyma
Axiom/Fricas
Mathematica
  probably others.

You think you can use sqrt because the quadratic formula says
-b+-sqrt(b^2....)
etc. 
So you think you know what sqrt means.
But in that formula you can switch the values +- and the formula
is still valid.

How many other formulas do you expect to fiddle with where that is true?

Certainly not this one:    sqrt(y^2) = abs(y).

So if you go off and do the wrong thing, it is probably prudent to
understand that you are doing the wrong thing.  Beyond that, you
are certainly free to do it.

RJF

Joachim Durchholz

unread,
Dec 11, 2014, 11:16:09 AM12/11/14
to sy...@googlegroups.com
Am 11.12.2014 um 00:40 schrieb Richard Fateman:
> 1994 paper by Adam Dingle and Richard Fateman
> Branch Cuts in Computer Algebra, (ISSAC '94 proceedings. also search
> online).

That paper assumes that everything can be refactored to logarithms plus
arithmetic.
Does that assumption hold? I could imagine that expressions containing
irreducible integrals might not be normalizable in that fashion.

> When you say things about sqrt(), does it generalize to cuberoot? If it
> does not, you are in trouble, or will be down the road.
>
> What is the principal value of (1)^(1/6) ?

Not sure what you mean with that.

> Several systems have RootOf( ...) expressions. e.g. RootOf(s^2=x, s).
> There are 2 values for s. What systems?
> Maple
> Macsyma
> Axiom/Fricas
> Mathematica
> probably others.

Not sure how that relates to the point you're making.

> You think you can use sqrt because the quadratic formula says
> -b+-sqrt(b^2....)
> etc.
> So you think you know what sqrt means.

Not sure what assumptions you assume.

> But in that formula you can switch the values +- and the formula
> is still valid.

Not sure what you mean with that - switching the signs means I still get
the same set of expressions.

> How many other formulas do you expect to fiddle with where that is true?
>
> Certainly not this one: sqrt(y^2) = abs(y).

That could still be handled by doing case distinctions.

This is an interesting case though, since it tells us that we need a
quantor: Are we interested in "there exists a branch where the
expression holds" or in "the expression holds in all branches"?
I think we need the former when determining all solutions to an
equation, and the latter when verifying an assumption.

> So if you go off and do the wrong thing, it is probably prudent to
> understand that you are doing the wrong thing.

Actually the "wrong thing" could be the right thing in specific
circumstances (experimental physics is full of this kind of stuff), but
I agree that you need to be aware of the kind of shortcut you're taking
and where the boundaries are where the approach would break.

I'm not sure what kind of "wrong thing" you are referring to in this
particular exchange though.
You paper takes a geometric approach (defining cuts as lines across the
complex plane), and I can see that that might be more appropriate than
blindly enumerating all branches, which might run into performance
issues, and would need quite a bit of algorithmic work to deal with

Richard Fateman

unread,
Dec 13, 2014, 12:27:11 AM12/13/14
to sy...@googlegroups.com


On Thursday, December 11, 2014 8:16:09 AM UTC-8, Joachim Durchholz wrote:
Am 11.12.2014 um 00:40 schrieb Richard Fateman:
> 1994 paper by Adam Dingle and Richard Fateman
> Branch Cuts in Computer Algebra,  (ISSAC '94 proceedings. also search
> online).

That paper assumes that everything can be refactored to logarithms plus
arithmetic.
Does that assumption hold? I could imagine that expressions containing
irreducible integrals might not be normalizable in that fashion.

> When you say things about sqrt(), does it generalize to cuberoot?  If it
> does not, you are in trouble, or will be down the road.
>
> What is the principal value of  (1)^(1/6) ?

Well, there are 6 possible values.  You could pick (same as sqrt rule?)  the positive one, namely 1.
That doesn't strike me as a good choice,  since powers of 1 do not generate the other roots. 

Not sure what you mean with that.

> Several systems have  RootOf( ...)  expressions.  e.g.  RootOf(s^2=x, s).
> There are 2 values for s.   What systems?
> Maple
> Macsyma
> Axiom/Fricas
> Mathematica
>    probably others.

Not sure how that relates to the point you're making.

If instead of sqrt(x^2) --> abs(x)  or some such thing,  you could
consider an expression h=  RootOf(y=x^2,x).   Then the only "simplifications"
that would be allowed would be ones that are valid for ANY choice of root.
for example, squaring  h gives you y.
 

> You think you can use sqrt because the quadratic formula says
> -b+-sqrt(b^2....)
> etc.
> So you think you know what sqrt means.

Not sure what assumptions you assume.
No assumptions whatsoever. There are 2 roots to a quadratic.  Well known
fundamental theorem of algebra, or some such.
 

> But in that formula you can switch the values +- and the formula
> is still valid.

Not sure what you mean with that - switching the signs means I still get
the same set of expressions.

That's why the formula works. switching the sign on sqrt just exchanges the roots.
 

> How many other formulas do you expect to fiddle with where that is true?
>
> Certainly not this one:    sqrt(y^2) = abs(y).

That could still be handled by doing case distinctions.

If you plot abs(y)  you get a V-shaped curve, with a singularity at 0.
neither square root of y^2 has such a plot.
 

This is an interesting case though, since it tells us that we need a
quantor: Are we interested in "there exists a branch where the
expression holds" or in "the expression holds in all branches"?
I think we need the former when determining all solutions to an
equation, and the latter when verifying an assumption.

I'm not familiar with the term quantor, but it makes sense to me to
have 2 separate questions here. 
Maxima's  radcan() does something like the first.  It produces  a particular
interpretation of radicals that is intended to be canonical  (and often is)

> So if you go off and do the wrong thing, it is probably prudent to
> understand that you are doing the wrong thing.

Actually the "wrong thing" could be the right thing in specific
circumstances (experimental physics is full of this kind of stuff),

perhaps that is why some people advise against learning
math from a physicist.  (I was a physics major as an undergraduate
though)
 
but
I agree that you need to be aware of the kind of shortcut you're taking
and where the boundaries are where the approach would break.

I'm not sure what kind of "wrong thing" you are referring to in this
particular exchange though.
You paper takes a geometric approach (defining cuts as lines across the
complex plane), and I can see that that might be more appropriate than
blindly enumerating all branches, which might run into performance
issues, and would need quite a bit of algorithmic work to deal with

I think the paper has had little impact on how people write systems.
It has had a slight impact on how people write papers.

Richard Fateman

unread,
Dec 13, 2014, 12:49:00 AM12/13/14
to sy...@googlegroups.com


On Friday, December 12, 2014 9:27:11 PM UTC-8, Richard Fateman wrote:


On Thursday, December 11, 2014 8:16:09 AM UTC-8, Joachim Durchholz wrote:
Am 11.12.2014 um 00:40 schrieb Richard Fateman:
> 1994 paper by Adam Dingle and Richard Fateman
> Branch Cuts in Computer Algebra,  (ISSAC '94 proceedings. also search
> online).

That paper assumes that everything can be refactored to logarithms plus
arithmetic.
Does that assumption hold? I could imagine that expressions containing
irreducible integrals might not be normalizable in that fashion. 

I think the general problem is much worse.  I have found
very limited help for functions of more than one complex variable... and
we can easily construct such situations in a computer algebra system.

If we throw rigor to the wind for functions of a single variable, there is
no point in looking at the functions of several variables,  I was hoping
someone else (perhaps with more intuition, better background, ..)
could make further progress.
RJF




 

Joachim Durchholz

unread,
Dec 13, 2014, 9:08:58 AM12/13/14
to sy...@googlegroups.com
Am 13.12.2014 um 06:27 schrieb Richard Fateman:
>
> On Thursday, December 11, 2014 8:16:09 AM UTC-8, Joachim Durchholz wrote:
>>
>> Am 11.12.2014 um 00:40 schrieb Richard Fateman:
>>> 1994 paper by Adam Dingle and Richard Fateman
>>> Branch Cuts in Computer Algebra, (ISSAC '94 proceedings. also search
>>> online).
>>
>> That paper assumes that everything can be refactored to logarithms plus
>> arithmetic.
>> Does that assumption hold? I could imagine that expressions containing
>> irreducible integrals might not be normalizable in that fashion.

Repeating the unanswered questions:

Does the paper assume that everything is normalizable to log/exp?

If yes, does this assumption hold in general?

If the assumption does not hold in general, how large is the class of
problems where it does hold, as opposed to all problems that might be
relevant to somebody doing symbolic math?

>>> When you say things about sqrt(), does it generalize to cuberoot? If it
>>> does not, you are in trouble, or will be down the road.
>>>
>>> What is the principal value of (1)^(1/6) ?
>
> Well, there are 6 possible values.

Heh. I didn't write the question, and I knew the answer :-)

> You could pick (same as sqrt rule?) the positive one, namely 1.
> That doesn't strike me as a good choice,

I think picking *any* principal root would be problematic, because one
would miss equalities (think x^12 = x^15).
But that wasn't my point anyway. I was thinking about calculating for
all principal roots in parallel, and not choosing at all until it turns
out that some choice is inconsistent with other assumptions.

> since powers of 1 do not generate
> the other roots.

What's the definition of "generate"? That you can get all principal
roots by taking a power of the chosen value?

Not that I think that property is *that* important, you can always use
polar representation and generate additively (that's more in line with
the approach in your paper anyway).

>>> You think you can use sqrt because the quadratic formula says
>>> -b+-sqrt(b^2....)
>>> etc.
>>> So you think you know what sqrt means.
>>
>> Not sure what assumptions you assume.
>>
> No assumptions whatsoever.

You're making assumptions about my knowledge of math if you say "so you
think you know xxx".
I was wondering about these.

>>> But in that formula you can switch the values +- and the formula
>>> is still valid.
>>
>> Not sure what you mean with that - switching the signs means I still get
>> the same set of expressions.
>
> That's why the formula works. switching the sign on sqrt just exchanges the
> roots.

The point now being...?

>>> How many other formulas do you expect to fiddle with where that is true?
>>>
>>> Certainly not this one: sqrt(y^2) = abs(y).
>>
>> That could still be handled by doing case distinctions.
>
> If you plot abs(y) you get a V-shaped curve, with a singularity at 0.
> neither square root of y^2 has such a plot.

Yeah, you need both plots.
And you need to match them with abs() using a case distinction. Which
happen to be the same as the one abs() is making (otherwise the equation
wouldn't hold).

>> This is an interesting case though, since it tells us that we need a
>> quantor: Are we interested in "there exists a branch where the
>> expression holds" or in "the expression holds in all branches"?
>> I think we need the former when determining all solutions to an
>> equation, and the latter when verifying an assumption.
>
> I'm not familiar with the term quantor,

Oh right, it's "quantifier" in English.

> but it makes sense to me to
> have 2 separate questions here.

Agreeing on that one then.

>>> So if you go off and do the wrong thing, it is probably prudent to
>>> understand that you are doing the wrong thing.
>>
>> Actually the "wrong thing" could be the right thing in specific
>> circumstances (experimental physics is full of this kind of stuff),
>
> perhaps that is why some people advise against learning
> math from a physicist.

Heh. I can understand that sentiment.

Alan Bromborsky

unread,
Dec 13, 2014, 9:27:27 AM12/13/14
to sy...@googlegroups.com
You might want to take a look at the book by Garret Sobczyk

New Foundations in Mathematics
The Geometric Concept of Number

Birkhauser

Joachim Durchholz

unread,
Dec 13, 2014, 10:23:50 AM12/13/14
to sy...@googlegroups.com
Am 13.12.2014 um 15:27 schrieb Alan Bromborsky:
> You might want to take a look at the book by Garret Sobczyk
>
> New Foundations in Mathematics
> The Geometric Concept of Number
>
> Birkhauser

That's an interesting book for sure, though I'll probably lack the time
to study it myself.
I'm not sure how this applies to the topic at hand though - can you
elaborate?

Richard Fateman

unread,
Dec 15, 2014, 7:52:22 PM12/15/14
to sy...@googlegroups.com


On Saturday, December 13, 2014 6:08:58 AM UTC-8, Joachim Durchholz wrote:
Am 13.12.2014 um 06:27 schrieb Richard Fateman:
>
> On Thursday, December 11, 2014 8:16:09 AM UTC-8, Joachim Durchholz wrote:
>>
>> Am 11.12.2014 um 00:40 schrieb Richard Fateman:
>>> 1994 paper by Adam Dingle and Richard Fateman
>>> Branch Cuts in Computer Algebra,  (ISSAC '94 proceedings. also search
>>> online).
>>
>> That paper assumes that everything can be refactored to logarithms plus
>> arithmetic.
>> Does that assumption hold? I could imagine that expressions containing
>> irreducible integrals might not be normalizable in that fashion.

Repeating the unanswered questions:

Does the paper assume that everything is normalizable to log/exp?

I haven't read the paper again, but I don't see why we would assume that
everything that one could express in a computer algebra system would be
analytic;  or entire, if that's the right word. 

If yes, does this assumption hold in general?
As I responded previously, the paper, as well as 99% of the books talk about
functions of a (single) complex variable, and are therefore not of much help
for functions with additional complex parameters. 

If the assumption does not hold in general, how large is the class of
problems where it does hold, as opposed to all problems that might be
relevant to somebody doing symbolic math?

Well, if you are doing homework problems in an undergraduate or maybe
graduate class in complex variables, it might be useful to have a computer
program that did some useful things.  It also turns out that there are strong
connections to "special functions" that could also be made easier if the
programs were systematically clean.
 

>>> When you say things about sqrt(), does it generalize to cuberoot?  If it
>>> does not, you are in trouble, or will be down the road.
>>>
>>> What is the principal value of  (1)^(1/6) ?
>
> Well, there are 6 possible values.  

Heh. I didn't write the question, and I knew the answer :-)

 > You could pick (same as sqrt rule?) the positive one, namely 1.
> That doesn't strike me as a good choice,

I think picking *any* principal root would be problematic, because one
would miss equalities (think x^12 = x^15).

I would pick one of the roots such that its powers cycled through all the
other ones,  if I had to pick just one...
 
But that wasn't my point anyway. I was thinking about calculating for
all principal roots in parallel, and not choosing at all until it turns
out that some choice is inconsistent with other assumptions.

This would be, in my opinion, an excellent tactic. 

 > since powers of 1 do not generate
> the other roots.

What's the definition of "generate"? That you can get all principal
roots by taking a power of the chosen value?
yes.  But I think you are mistaken in thinking there are 6 principal roots.
There are maybe 4? 

Not that I think that property is *that* important, you can always use
polar representation and generate additively (that's more in line with
the approach in your paper anyway).

You can do all kinds of things if you know what you are doing.
The CAS is supposed to do the right thing for people who don't know
what they are doing.
 

>>> You think you can use sqrt because the quadratic formula says
>>> -b+-sqrt(b^2....)
>>> etc.
>>> So you think you know what sqrt means.
>>
>> Not sure what assumptions you assume.
>>
> No assumptions whatsoever.

You're making assumptions about my knowledge of math if you say "so you
think you know xxx".
I was wondering about these.

True, I am assuming you met up with the quadratic formula.  In high school. 

>>> But in that formula you can switch the values +- and the formula
>>> is still valid.
>>
>> Not sure what you mean with that - switching the signs means I still get
>> the same set of expressions.
>
> That's why the formula works. switching the sign on sqrt just exchanges the
> roots.

The point now being...?
As long as you keep the formula together  (both roots)  it doesn't matter which sign you pick.
However, if you separate them and ask which is (say) positive,  now it matters.
 

>>> How many other formulas do you expect to fiddle with where that is true?
>>>
>>> Certainly not this one:    sqrt(y^2) = abs(y).
>>
>> That could still be handled by doing case distinctions.
>
> If you plot abs(y)  you get a V-shaped curve, with a singularity at 0.
> neither square root of y^2 has such a plot.

Yeah, you need both plots.
And you need to match them with abs() using a case distinction. Which
happen to be the same as the one abs() is making (otherwise the equation
wouldn't hold).

huh?  abs(x) is not analytic.  It is really a bad idea to introduce such functions
if they are not necessary.
 

>> This is an interesting case though, since it tells us that we need a
>> quantor: Are we interested in "there exists a branch where the
>> expression holds" or in "the expression holds in all branches"?
>> I think we need the former when determining all solutions to an
>> equation, and the latter when verifying an assumption.
>
> I'm not familiar with the term quantor,

Oh right, it's "quantifier" in English.

 > but it makes sense to me to
> have 2 separate questions here.

Agreeing on that one then.

>>> So if you go off and do the wrong thing, it is probably prudent to
>>> understand that you are doing the wrong thing.
>>
>> Actually the "wrong thing" could be the right thing in specific
>> circumstances (experimental physics is full of this kind of stuff),
>
> perhaps that is why some people advise against learning
> math from a physicist.

Heh. I can understand that sentiment.

(I think the same sentiment works for learning programming...)

RJF 

Kalevi Suominen

unread,
Dec 16, 2014, 12:24:01 PM12/16/14
to sy...@googlegroups.com


On Saturday, December 6, 2014 10:01:38 PM UTC+2, Aaron Meurer wrote:
Something that I'm not sure about with representing functions as
multivalued is, how do you represent arbitrary Riemann surfaces.

A practical way of representing a Riemann surface is by means of coordinate
functions analytic (or meromorphic) on the.surface.  Usually two functions
suffice. These functions are algebraically or analytically related.

A point  p  of the surface is represented by the pair of (extended) complex
values  (x,y)  of the functions at  p. The Riemann surface is then the set of all
such pairs. In other words, it is essentially the graph of the relation between the
two coordinate functions. (Sometimes additional functions are needed to resolve
singular points.)

For example, the Riemann surface of  sqrt(1 - x^2)  consists of all pairs  (x,y)
satisfying x^2 + y^2 = 1. Similarly, the Riemann surface of  log  is the set of
pairs  (x,y)  such that  x = exp(y). (It can be identified with the set of polar numbers
via the mapping (r,theta) -> (r*exp(i*theta), log(r) + i*theta).)

Another question is computational. How do you compute the surfaces in
general (say even for a limited class of expressions, like algebraic
functions),

The Riemann surface of an algebraic function is obtained as follows. First,
one computes the minimal polynomial  p(y)  of the function over the field  C(x)
of complex rational functions. After multiplying  p  by the lcm of the denominators
of its coefficients one gets a complex polynomial  P(x,y)  of two variables.
The Riemann surface is then the set of pairs satisfying  P(x,y) = 0.
(There may be some singular points. They can be found by taking the resultant
with respect to  y of  P and its derivative P_y, if necessary.)
 
and how do you make cuts in a consistent manner?

Branch cuts should not be needed as the functions are single-valued on the
Riemann surface.

Kalevi Suominen

Joachim Durchholz

unread,
Dec 16, 2014, 12:50:49 PM12/16/14
to sy...@googlegroups.com
Am 16.12.2014 um 01:52 schrieb Richard Fateman:
>
> On Saturday, December 13, 2014 6:08:58 AM UTC-8, Joachim Durchholz wrote:
>>
>> But that wasn't my point anyway. I was thinking about calculating for
>> all principal roots in parallel, and not choosing at all until it turns
>> out that some choice is inconsistent with other assumptions.
>
> This would be, in my opinion, an excellent tactic.

The problem with it that it is prone to exponential blowup.
We'd want to exclude combinations as early as possible, but avoid
checking for that more often than necessary (because that could slow
SymPy to a crawl). I don't know of any algorithm to ensure that; I don't
even know a coding strategy for arriving there.

> You can do all kinds of things if you know what you are doing.
> The CAS is supposed to do the right thing for people who don't know
> what they are doing.

In practice, those people will need to know what the CAS is doing, and
they need enouth math skills to properly interpret (and hopefully
double-check) the answers, so I think that's not actually the case, not
totally anyway.
I see the advantage of a CAS in that it can do the clerical work, and
quickly and without making silly mistakes.

> True, I am assuming you met up with the quadratic formula. In high school.

Heh. While my background is certainly not up to par with that of many
others here (I'm more the program design type), I certainly know the
standard results about multiple roots. (A few other areas of math as
well, but none of that at the pro level.)

>>>>> But in that formula you can switch the values +- and the formula
>>>>> is still valid.
>>>>
>>>> Not sure what you mean with that - switching the signs means I still
>> get
>>>> the same set of expressions.
>>>
>>> That's why the formula works. switching the sign on sqrt just exchanges
>> the
>>> roots.
>>
>> The point now being...?
>>
> As long as you keep the formula together (both roots) it doesn't matter
> which sign you pick.
> However, if you separate them and ask which is (say) positive, now it
> matters.

Ah ok.
That's not what I'd do though, a set of assumptions can't be split up
without changing its semantics, because you lose the AND resp. OR connector.

>>>>> How many other formulas do you expect to fiddle with where that is
>> true?
>>>>>
>>>>> Certainly not this one: sqrt(y^2) = abs(y).
>>>>
>>>> That could still be handled by doing case distinctions.
>>>
>>> If you plot abs(y) you get a V-shaped curve, with a singularity at 0.
>>> neither square root of y^2 has such a plot.
>>
>> Yeah, you need both plots.
>> And you need to match them with abs() using a case distinction. Which
>> happen to be the same as the one abs() is making (otherwise the equation
>> wouldn't hold).
>
> huh? abs(x) is not analytic. It is really a bad idea to introduce such
> functions
> if they are not necessary.

Ah, I thought you meant the real-valued function because you used the
word "graph".
True, for complex-valued functions things are different.

OTOH non-analytic functions are important, often because the domain is
the real numbers where analytic isn't relevant, less often because the
domain is complex numbers and really need that non-analytic function
anyway (rare because for those situations one would probably use vectors
instead of complex numbers, but then there might the odd problem where
analyticness isn't a given and you still want that special
multiplication rule).

>>> perhaps that is why some people advise against learning
>>> math from a physicist.
>>
>> Heh. I can understand that sentiment.
>
> (I think the same sentiment works for learning programming...)

Sure. You shouldn't learn programming from a mathematician, statistics
expert, or (worst of them all) experimental physicists.
Well, at least that's common wisdom. In practice, I doubt that the data
masses gathered at sites like CERN could be handled by piling layers of
throwaway code on each other.
A more relevant caveat against learning programming from nonprogrammers
is that the list of things you learn is usually tailored towards the
field of application, and too narrow to become a good programmer outside
of that field. Of course that isn't applicable if you're going to work
just in that field.

Regards,
Jo

Alan Bromborsky

unread,
Dec 16, 2014, 1:01:59 PM12/16/14
to sy...@googlegroups.com
Do you wish to also include functions of hyperbolic numbers -

http://en.wikipedia.org/wiki/Split-complex_number

Chris Smith

unread,
Jan 9, 2015, 12:28:01 PM1/9/15
to sy...@googlegroups.com
I added an issue regarding the principle root issue at https://github.com/sympy/sympy/issues/8789
Reply all
Reply to author
Forward
0 new messages