We have discussed this a bit at the beginning of the summer. It has to
do mainly with the assumptions on the various objects.  Verify that
all subs/replace/atoms/free_symbols methods work first as these are
quite important for correctly working simplifications. Then we should
"just" start adding the appropriate hardcoded assumptions.

On 29 August 2013 11:48, Prasoon Shukla <[email protected]> wrote:
> Sorry for the late reply. I'm buried neck deep in academics. Anyway, setting
> the hashable_content method clears things up.
>
> The problem now is this:
>
> We have the expression sin(theta) * cos(phi)
>
> Here are the relations for substitution:
>
> tan(theta) = sqrt(x**2 + y**2) /z
> tha(phi) = y/x
>
> Substituting this back, we get
> x / (x**2 + y**2 + z**2)
>
> Except that SymPy is returning a huge expression - that does simplify to the
> above expression, manually. Running simplify() on the expression returns the
> same expression with no simplification.
>
> This means that things are at least working correctly - the maths and the
> code. I am proceeding with the debugging.
>
>
> On Wednesday, August 28, 2013 6:59:15 PM UTC+5:30, Prasoon Shukla wrote:
>>
>> I have ran into a caching problem while working on my project for the
>> vector calcculus module. This occurred while I was debugging the express
>> method on vector (this isn't really relevant though).
>>
>> So, I have a symbol theta and another symbol phi.
>>
>> >>> cs.theta
>> cs.theta
>>
>> >>> cs.phi
>> cs.phi
>>
>> cs is an instance of the CoordSysSph class (again, not really relevant to
>> the problem at hand).
>>
>> The problem:
>> >>> sin(cs.theta) * sin(cs.phi)
>> sin(cs.theta) ** 2
>>
>> Well, in the definition for the cacheit decorator, the dicitionary
>> func_cache_it_cache exists. Now, when sin(cs.theta) is called, a key, value
>> pair gets added to the dictionary:
>>
>> ((sin, <class 'sympy.core.function.FunctionClass'>), (cs.theta, <class
>> 'sympy.vector.vector.BaseScalar'>))  : sin(cs.theta)
>>
>> Now, when SymPy needs to calculate sin(cs.phi), the cacheit decorator is
>> called again. The lookup key for sin(cs.phi) is generated as:
>> ((sin, <class 'sympy.core.function.FunctionClass'>), (cs.phi, <class
>> 'sympy.vector.vector.BaseScalar'>))
>>
>> At this point, the func_cache_it_cache does not have the key correspondind
>> to sin(cs.phi), as it shouldn't. But, here's the catch: running the has_key
>> method on func_cache_it_cache for this second key (for sin(cs.phi)) returns
>> True. That means, the cache returns sin(cs.theta). And that is what is
>> causing the problem.
>>
>> What can I possibly do here? For the time being, I am going to proceed
>> with the debugging. When there is a solution for this problem, we can go
>> ahead and fix this.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to