sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.45k stars 481 forks source link

Make desolve deduce the variable if you don't state it #8616

Open a7d8ed48-9a19-4926-9ac2-3349347d1ebf opened 14 years ago

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago

Provides autodetect dependent and independent variables in desolve(), desolve_laplace()

Additionally as module which helps to solve first problem provides unified interface for standard python types and sage specific types. Treats everything as symbolic expression which allows to check its type, take operator and operands and extract subexpressions by given types.

http://groups.google.com/group/sage-devel/browse_thread/thread/f2ba2198dc5b79ed

http://groups.google.com/group/sage-devel/browse_thread/thread/e04cbc547095f2ac

CC: @robert-marik @novoselt

Component: symbolics

Keywords: symbolic, type, subexpression

Author: Yuri Karadzhov

Issue created by migration from https://trac.sagemath.org/ticket/8616

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago

symbolic sage module

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago

Attachment: trac_8616_symbolic_sage.patch.gz

symbolic sage module

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago
comment:2

Attachment: trac_8616_symbolic_sage.2.patch.gz

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago

Description changed:

--- 
+++ 
@@ -2,4 +2,8 @@
 Treats everything as symbolic expression which allows to check its type, take
 operator and operands and extract subexpressions by given types.

+Provides autodetect dependent and independent variables in desolve()
+
 http://groups.google.com/group/sage-devel/browse_thread/thread/f2ba2198dc5b79ed
+
+http://groups.google.com/group/sage-devel/browse_thread/thread/e04cbc547095f2ac
34f90a52-c114-47db-a93b-3f83978622c0 commented 14 years ago

Changed upstream from Reported upstream. Developers acknowledge bug. to none

34f90a52-c114-47db-a93b-3f83978622c0 commented 14 years ago
comment:5

Hm I have the following error after installing the patch

ImportError: No module named mtype
Error importing ipy_profile_sage - perhaps you should run %upgrade?
WARNING: Loading of ipy_profile_sage failed.

And there is no mtype.* file in sage/symmbolic in my Sage 4.3.4

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago

Attachment: trac_8616_symbolic_sage_correct.patch.gz

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago

Attachment: trac_8616_symbolic_sage_correct2.patch.gz

more precise autodetect of independent variable

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago

Description changed:

--- 
+++ 
@@ -2,7 +2,7 @@
 Treats everything as symbolic expression which allows to check its type, take
 operator and operands and extract subexpressions by given types.

-Provides autodetect dependent and independent variables in desolve()
+Provides autodetect dependent and independent variables in desolve(), desolve_laplace()

 http://groups.google.com/group/sage-devel/browse_thread/thread/f2ba2198dc5b79ed
a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago

Description changed:

--- 
+++ 
@@ -1,8 +1,8 @@
-Provides unified interface for standard python types and sage specific types.
+Provides autodetect dependent and independent variables in desolve(), desolve_laplace()
+
+Additionally as module which helps to solve first problem provides unified interface for standard python types and sage specific types.
 Treats everything as symbolic expression which allows to check its type, take
 operator and operands and extract subexpressions by given types.
-
-Provides autodetect dependent and independent variables in desolve(), desolve_laplace()

 http://groups.google.com/group/sage-devel/browse_thread/thread/f2ba2198dc5b79ed
robertwb commented 14 years ago
comment:10

Thank you for working on desolve, that module is in need of a lot of help. I'm really not seeing what mtype has to do with it though (and what does "mtype" mean? wtype, stype, ... are equally obscure). Also _ for a wildcard is very non-standard notation, perhaps "*.integer" would be better.

In any case, my main issue with this patch is that a huge list of isinstance statements is not the way to implement this--it's brittle and requires the module to know about everything in Sage. If we need an mtype (operator, ...), it should be done OO style, with tests just for a few of the builtin types (and even then it could be cleaner, using their names.

a7d8ed48-9a19-4926-9ac2-3349347d1ebf commented 14 years ago
comment:11

Replying to @robertwb:

Thank you for working on desolve, that module is in need of a lot of help. I'm really not seeing what mtype has to do with it though (and what does "mtype" mean? wtype, stype, ... are equally obscure). Also _ for a wildcard is very non-standard notation, perhaps "*.integer" would be better.

_ wildcard is used in scala. * is used for multiply operator. desolve module is really bad it is beter to completly rewrite it, but sage doesn't have enough functions to start doing it. mtype is the firs step. It helps to deal with symbolical expression.

In any case, my main issue with this patch is that a huge list of isinstance statements is not the way to implement this--it's brittle and requires the module to know about everything in Sage. If we need an mtype (operator, ...), it should be done OO style, with tests just for a few of the builtin types (and even then it could be cleaner, using their names.

I absolutely agree with you. It is much better to have class hierarchy or at least some common interface which can help to define type. And wraps or mixins should be used for Python types. But I did mtype class to concentrate attention on existing problem - sage is almost useless for complex symbolical computations (it is my opinion as well as opinion of my colleagues) It is hard for people who are new to python. You shouldn't use mtype, but it is good to do smth about this problem in sage.

I made sketch to solve some simple de problems I write some common functions in mtype, which can be easily rewritten to extract only diff operators. So just use it if you want to.

I finished with sage for this year, now I need to do smth real. I'm sorry I can't afford to spend some more time to finish this improvements.

kcrisman commented 13 years ago
comment:12

Changing title to more accurately reflect what it's about.