Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero terms in simplification #34

Closed
vvs- opened this issue Jun 16, 2017 · 8 comments
Closed

Zero terms in simplification #34

vvs- opened this issue Jun 16, 2017 · 8 comments

Comments

@vvs-
Copy link

vvs- commented Jun 16, 2017

This is more a CAS issue but still.

Try e.g.

x^2-1
factor
simplify
@hanna-kn
Copy link
Contributor

This is what I get with the latest git version (where factorization/simplification has been improved):

> x^2-1

  (x^2) - 1 = x^2 - 1

> factor

  x^2 - 1 = (x - 1)(x + 1)

> simplify

  (x - 1)(x + 1) = x^2 - 1

I assume that you get a different result.

@vvs-
Copy link
Author

vvs- commented Jun 16, 2017

Yes, but I have the latest git too 😄

It appears to depend on assumptions setting. Is that expected?

@hanna-kn
Copy link
Contributor

hanna-kn commented Jun 16, 2017

I assume you get x^2 + 0x - 1 when simplifying (x - 1)(x + 1) because there are no assumptions for the type of x.

I do not remember the original reasoning for this behaviour, but there are some values for x where 0*x does not equal zero (e.g. if x is a matrix). (The problem is that for matrices x^2 - 1 does not equal (x - 1)(x + 1).)

@hanna-kn
Copy link
Contributor

hanna-kn commented Jun 16, 2017

But matrix^2+0×matrix=matrix^2, so the current behaviour should not be necessary for matrices. I do not understand why (matrix - 1)(matrix + 1) currently gives such a strange result (it might be a bug).

Edit: matrix^2+0*matrix only equals matrix^2 if numbers of rows and columns are equal.

@vvs-
Copy link
Author

vvs- commented Jun 16, 2017

Current behavior formally breaks invariant, so factor ≠ simplify. Though, this is just an optimization issue, because it adds a zero term, so nothing really serious.

As for matrices, I don't understand what is the meaning of matrix minus scalar? I admit that I never used matrices in Qalculate!

@hanna-kn
Copy link
Contributor

hanna-kn commented Jun 16, 2017

I never use matrices myself. There is no meaning of matrix minus scalar (at least not in Qalculate! where matrix - scalar = matrix - scalar). If you know that x does not represent a matrix you should at least set assumptions to not matrix (default assumption is real number), to avoid unexpected oddness.

The ability to combine all types (units, numbers, matrices, etc.) in one expression, even if it might be meaningless, has it quirks.

@vvs-
Copy link
Author

vvs- commented Jun 16, 2017

Yes, polynomials over matrices are very odd at least. Especially with scalars and non-square matrices as its terms.

But the point is that the zero term in polynomials seems to be meaningless in case of matrices anyway. So, I believe that there is no reason to make it a special case. Otherwise it appears all of a sudden without any particular reason.

@hanna-kn
Copy link
Contributor

The best option might be to simply remove the possibility that x is a matrix and make number the first option for assumption type. There are more cases where x as matrix is broken and at the moment it has no real use.

hanna-kn added a commit that referenced this issue Jan 15, 2018
… and electric constants, and introduce completion only only names to enable completion of greek letters from the roman letter names (qalculate-gtk issue #34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants