From: SourceForge.net <no...@so...> - 2009-01-10 23:53:05
|
Bugs item #2135806, was opened at 2008-09-29 13:02 Message generated for change (Comment added) made by crategus You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2135806&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Barton Willis (willisbl) Assigned to: Nobody/Anonymous (nobody) Summary: noun / verb confusion for real/imag part Initial Comment: I think (%o4) should be (conjugate(z)+z)/2: (%i4) subst(lambda([s], (s + conjugate(s))/2), 'realpart, realpart(z)); (%o4) realpart(z) For the sub to happen, we need to nounify: (%i5) subst(lambda([s], (s + conjugate(s))/2), nounify(realpart), realpart(z)); (%o5) (conjugate(z)+z)/2 For other functions (say cos), the nounify isn't needed: (%i7) subst(lambda([s], 42), 'cos, cos(x)); (%o7) 42 So, I think the nounify(realpart) shouldn't be needed in (%i5). ---------------------------------------------------------------------- >Comment By: Dieter Kaiser (crategus) Date: 2009-01-11 00:53 Message: The reason for the different behavior is that the functions realpart() and imagpart() have not the property ALIAS like the functions sin() or cos(). The parser returns for the input 'realpart the symbol $realpart. For fully implemented simplifying functions the parser returns e.g. for the input cos the symbol %cos because of the property ALIAS. Unfortunately, the Lisp function risplit-noun introduces the symbols %realpart and %imagpart and realpart(z) simplifies to the expression ((%realpart) z). The function subst() does not work because of the different symbols. The call nounify(realpart) changes the verb form $realpart to the noun form %realpart and now it works again. This behavior can be changed when we do not use the symbol %realpart but change the function risplit-noun like: (defun risplit-noun (l) (cons (list '($realpart) l) (list '($imagpart) l))) A noun which is declared to be complex now gives the expression: (($REALPART SIMP) $Z) The original code does a simplify, but I think this is not possible for the whole expression (we loop endlessly) and not necessary for the argument l. We get the correct expression from the simplifier. We have to change the symbols %realpart and %imagpart at about 5 places in the whole code. The testsuite has no problems with this changes. With this change the example will work as expected: (%i25) subst(lambda([s], (s + conjugate(s))/2), 'realpart, realpart(z)); (%o25) (conjugate(z)+z)/2 Remark: With the original code and the changed code we get: 'realpart(x+%i*y); 'realpart(x+%i*y) /* intern ((%realpart) .... ) */ In this case the parser returns the symbol %realpart. Because realpart() is not a simplifying function Maxima can not further simplify this expression e.g. rectform('realpart(1)); realpart(1) So what do you think? Should we change %realpart to $realpart in risplit-noun. Perhaps later we can introduce a simplifying function realpart(). Dieter Kaiser ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2135806&group_id=4933 |