On Feb 23, 2011, at 4:38 PM, Kate MacInnis wrote:

>> Thanks for working on this.  I feel pretty strongly that it should be done, 
>> because we are always
>> running into problems because of it.  If it were not done automatically, it 
>> would not be a problem
>> because we could just write some expand function that does it manually 
>> whenever we need it
>> done (the reverse is not possible with automatic simplification).
> 
> That's what I was thinking.  I'm hoping that the solution to some of
> the infinite recursions is just finding the right place for a
> judicious expand.

Yes, I think you are right.  It will depend on the exact nature of the failure, 
but you may need to write a custom expand (or else make another hint to 
expand()) to distribute only a number, i.e., expand() may be too much.  Or it 
may not; it really depends on the nature of the failure.

Another thing that I just remembered is that it is a good idea to make this fix 
because it is currently possible to "trick" sympy into giving an unexpanded 
expression in some cases.  For example,

In [55]: 2*(x - y)*(y - z)
Out[55]: (y - z)⋅(-2⋅y + 2⋅x)

In [56]: 2*((x - y)*(y - z))
Out[56]: 2⋅(x - y)⋅(y - z)

I don't know if you can use this workaround in your application.  It is kind of 
hackish, subtle, and volatile (it's also technically possible using Mul(2, x + 
y, evaluate=False), but that also has the same problems).  Anyway, my point is 
that you could probably uncover the same test failures by sending an expression 
like [56] to the functions, so in some sense the auto-distribution is just 
"masking bugs".

> 
> 
>> What do you need the behavior for, our of curiosity?
> 
> I'm working on an application to give my students (generally College
> Algebra through lightweight applied Calculus) more practice problems,
> with immediate feedback.  I decided it was necessary after spending an
> hour with one student who wanted help with integrating exponentials,
> and most of what I did after the first ten minutes was just "okay, now
> do e**(5x)... now do e**(17x)"
> 
> Of course, sympy is almost overkill for this, but it will make writing
> questions and especially comparing a student's response to the correct
> answer easier.  But one of the main things I would want to have is a
> factoring practice (it's shocking how many Cal I students don't know
> how to factor well enough to be useful) I need to be able to sympify
> something like 2*(x+3)*(x+5) and have it be recognized as equal to
> 2*(x+5)*(x+3), without using expand.  (I certainly don't want them to
> be told it's correct if they just enter the original polynomial.)  I
> think if I can fix this one sticking point, and give it a spiffy gui,
> it will be perfect.
> 
> My back-up plan, if I can't fix things properly, is to strip out the
> parts I won't need, and use a sort of sympy-lite.  I'd rather get it
> working properly and have something to contribute back, though.

Yes, thank you for contributing back.  SymPy is what it is because people 
contribute their changes back to the project instead of just keeping them for 
themselves.

Aaron Meurer

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to