rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

ratnump(taylor(1,x,0,1)) => true #676

Closed rtoy closed 2 months ago

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-03 07:32:57 Created by macrakis on 2002-10-15 18:37:55 Original: https://sourceforge.net/p/maxima/bugs/157


tay: taylor(1,x,0,1) => 1+... or tay: taylor(x^5,x,0,1) => 1+...

ratnump(tay) => true numberp(tay) => true

Since taylor series represent approximations, I don't think it's correct to characterize 1+... as a number.

The fix is simple:

(DEFMFUN $RATNUMP (X) (OR (INTEGERP X) (RATNUMP X) (AND ($RATP X) (not (memq 'trunc (cdar x))) (INTEGERP (CADR X)) (INTEGERP (CDDR X)))))

Similarly for Integerp:

(DEFMFUN $INTEGERP (X) (OR (INTEGERP X) (AND ($RATP X) (not (memq 'trunc (cdar x))) (INTEGERP (CADR X)) (EQUAL (CDDR X) 1))))

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-03 07:32:59 Created by macrakis on 2004-03-04 19:16:01 Original: https://sourceforge.net/p/maxima/bugs/157/#6101


Logged In: YES user_id=588346

I notice that Taylor uses $ratnump internally. These cases will have to be looked at to see if the change causes problems.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-03 07:33:02 Created by robert_dodier on 2006-04-09 20:30:59 Original: https://sourceforge.net/p/maxima/bugs/157/#0323


rtoy commented 2 months ago

Imported from SourceForge on 2024-07-03 07:33:06 Created by dgildea on 2008-08-24 16:14:51 Original: https://sourceforge.net/p/maxima/bugs/157/#c24c


Logged In: YES user_id=1797506 Originator: NO

Fix applied in simp.lisp rev 1.58:

(%i17) tay: taylor(x^5,x,0,1) ; (%o17) +0 (%i18) ratnump(tay); (%o18) false (%i19) numberp(tay); (%o19) false (%i20) integerp(tay); (%o20) false

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-03 07:33:10 Created by dgildea on 2008-08-24 16:14:51 Original: https://sourceforge.net/p/maxima/bugs/157/#68df