
(require (quote calc-ext))

(defun calc-Need-calc-poly nil (byte-code "À‡" [nil] 1))

(defun calcFunc-pcont (expr &optional var) (byte-code ":?†
 @Ç>ƒx :ƒ/ @È>?…, @É=ƒ) Ê8Ë=‚, Ì!‚2 Ë=ƒ9 Ê‚u :…J @É=…J Í8ËYƒS Î!‚u :?†] @Ï>ƒd ‚u Ð	\"†m 	?ƒt Ê‚u ‚k@Ñ=ƒ� ÒÓÊ8	\"ÓÍ8	\"\"‚k@Ô=ƒ¨ ÕÓÊ8	\"ÓÍ8	\"\"‚k@Ö=…Ä Í8:ƒ¿ Í8@×=‚Ä Í8ËYƒÕ ØÓÊ8	\"Í8\"‚k@Ù>ƒå ÓÊ8	\"‚k	:ƒÚ	\"ƒGS8Û!Ü!ƒ	Ý!‚
*‚Ê)‚k@Þ>ƒbÓÊ8	\"Ê=ƒ+Ê‚^ÓÍ8	\"ß!…K@à=ƒGá!‚Kß!ƒXÝâ\"!‚]â\"))‚k	ƒj‚kÊ‡" [expr var t p lead cont c2 (bigpos bigneg frac float cplx polar hms date mod var) (bigpos bigneg) float 1 0 math-zerop 2 math-trunc (bigpos bigneg frac float cplx polar hms date sdev intv mod) equal * math-mul calcFunc-pcont / math-div ^ bigpos math-pow (neg polar) math-is-polynomial math-poly-gcd-list math-guess-if-neg math-neg (+ - cplx sdev) math-negp - math-posp math-poly-gcd] 26))

(defun calcFunc-pprim (expr &optional var) (byte-code "Ã	
\"ÄÅ\"ƒ 	‚ Æ	
#)‡" [cont expr var calcFunc-pcont math-equal-int 1 math-poly-div-exact] 6))

(defun math-div-poly-const (expr c) (byte-code "Ã!Ä>ƒ @ÅÆ8	\"ÅÇ8	\"E‚ È	\"‡" [expr c t car-safe (+ -) math-div-poly-const 1 2 math-div] 7))

(defun calcFunc-pdeg (expr &optional var) (byte-code ":ƒ\" @Â>?… @Ã=ƒ Ä8Å=‚ Æ!‚% Å=ƒ, Ç‚A 	ƒ> È	\"†; ÉÊ\"‚A Ë!‡" [expr var (bigpos bigneg) float 1 0 math-zerop (neg (var inf var-inf)) math-polynomial-p math-reject-arg "Expected a polynomial" math-poly-degree] 5))

(defun math-poly-degree (expr) (byte-code ":?†
 @Â>ƒ Ã!Ä=ƒ Å‚ Æ‚ˆ @Ç=ƒ, ÈÅ8!‚ˆ @É=ƒA ÈÅ8!ÈÊ8!\\‚ˆ @Ë=ƒV ÈÅ8!ÈÊ8!Z‚ˆ @Ì=…b ÍÊ8!ƒr ÉÈÅ8!Ê8\"‚ˆ @Î>ƒ‡ ÈÅ8!ÈÊ8!]‚ˆ Å‡" [expr t (bigpos bigneg frac float cplx polar hms date mod var) car-safe var 1 0 neg math-poly-degree * 2 / ^ natnump (+ -)] 14))

(defun calcFunc-plead (expr var) (byte-code "Ä!Å=ƒ ÆÇÈ8	\"ÇÉ8	\"\"‚€ Ä!Ê=ƒ2 ËÇÈ8	\"ÇÉ8	\"\"‚€ Ä!Ì=…? ÍÉ8!ƒP ÎÇÈ8	\"É8\"‚€ :?†Z @Ï>ƒl Ð	\"ƒh È‚i ‚€ Ñ	\"Aƒ~ GS8‚ È)‡" [expr var t p car-safe * math-mul calcFunc-plead 1 2 / math-div ^ math-natnump math-pow (bigpos bigneg frac float cplx polar hms date mod var) equal math-is-polynomial] 16))

(setq math-poly-modulus 1)

(defun calcFunc-pgcd (pn pd) (byte-code "Å!…
 ÆÇ\"ˆÅ	!… Æ	Ç\"ˆÃÄ	\"È	\"*‡" [pn pd calc-prefer-frac t math-poly-modulus math-any-floats math-reject-arg "Coefficients must be rational" math-poly-gcd] 8))

(defun calcFunc-pdiv (pn pd &optional base) (byte-code "ÁÂ\"È#A‰ˆ@+‡" [calc-prefer-frac t math-poly-modulus pn pd res base calc-poly-div-remainder math-poly-div] 5))

(defun calcFunc-prem (pn pd &optional base) (byte-code "ÁÂ\"Æ#A*‡" [calc-prefer-frac t math-poly-modulus pn pd base math-poly-div] 5))

(defun calcFunc-pdivrem (pn pd &optional base) (byte-code "ÁÂ\"Ç#È@AE+‡" [calc-prefer-frac t math-poly-modulus pn pd res base math-poly-div vec] 5))

(defun calcFunc-pdivide (pn pd &optional base) (byte-code "ÁÂ\"Ç#È@ÉA\"\"+‡" [calc-prefer-frac t math-poly-modulus pn pd res base math-poly-div math-add math-div] 7))

(defun math-mul-thru (lhs rhs) (byte-code "Â!Ã>ƒ @ÄÅ8	\"ÄÆ8	\"E‚8 Â	!Ç>ƒ4 	@ÄÅ	8\"ÄÆ	8\"E‚8 È	\"‡" [lhs rhs car-safe (+ -) math-mul-thru 1 2 (+ -) math-mul] 11))

(defun math-div-thru (num den) (byte-code "Â!Ã>ƒ @ÄÅ8	\"ÄÆ8	\"E‚ Ç	\"‡" [num den car-safe (+ -) math-div-thru 1 2 math-div] 7))

(defun math-sort-terms (expr) (byte-code "Á!Â>ƒ ÃÄÅ!Æ\"!‚ ‡" [expr car-safe (+ -) math-list-to-sum sort math-sum-to-list (lambda (a b) (byte-code "Â@	@\"‡" [a b math-beforep] 3))] 6))

(defun math-list-to-sum (lst) (byte-code "Aƒ @Aƒ Á‚ ÂÃA!@@E‚, @Aƒ) Ä@@!‚, @@‡" [lst - + math-list-to-sum math-neg] 4))

(defun math-sum-to-list (tree &optional neg) (byte-code "Ã!Ä=ƒ ÅÆÇ8	\"ÆÈ8	\"\"‚7 Ã!É=ƒ3 ÅÆÇ8	\"ÆÈ8	?\"\"‚7 	BC‡" [tree neg t car-safe + nconc math-sum-to-list 1 2 -] 11))

(defun math-poly-modulus (expr &optional expr2) (byte-code "Â!† 	… Â	!† Ã‡" [expr expr2 math-poly-modulus-rec 1] 3))

(defun math-poly-modulus-rec (expr) (byte-code "Á!Â=… Ã8:ƒ Ã8@Ä=‚ Ã8ÅYƒ) ÂÆÃ8E‚> Á!Ç>…> ÈÆ8!†> ÈÃ8!‡" [expr car-safe mod 2 bigpos 0 1 (+ - * /) math-poly-modulus-rec] 6))

(defun math-poly-div (u v &optional math-poly-div-base) (byte-code "ƒ Ã	
\"‚ ÃÄ	!Ä
!\"‡" [math-poly-div-base u v math-do-poly-div calcFunc-expand] 6))

(setq math-poly-div-base nil)

(defun math-poly-div-exact (u v &optional base) (byte-code "Ä	
#AÅ=ƒ @‚ ÆÇ	
EÈ\")‡" [res u v base math-poly-div 0 math-reject-arg vec "Argument is not a polynomial"] 5))

(defun math-do-poly-div (u v) (byte-code "Ê!ƒ Ê	!ƒ Ë	\"ÌB‚ ÌB‚Ã Ê	!ƒR 	Í=ƒ+ ‚M Î!Ï>ƒI ÐÑÍ8	\"ÑÒ8	\"Â@Ó=$‚M Ë	\"ÌB‚Ã Ô	\"ÌUƒa ÌB‚Ã Õ!…j Õ	!ƒx ÖË	\"!ÌB‚Ã †� Æ	\"ÂÂÂ	?†š ×	ÂØ$‰?ƒ£ ÌB‚Â ×ÂØ$Ù\"‰	ˆÚ	@\"Ú	A\"B,‡" [u v nil math-poly-modulus t base math-poly-div-base vp up res math-constp math-div 0 1 car-safe (+ -) math-add-or-sub math-poly-div-exact 2 - math-compare math-atomic-factorp math-simplify math-is-polynomial gen math-poly-div-coefs math-build-polynomial-expr] 23))

(defun math-poly-div-rec (u v) (byte-code "Ê!ƒ Ë	\"‚À Ê	!ƒB 	Ì=ƒ ‚? Í!Î>ƒ; ÏÐÌ8	\"ÐÑ8	\"Â@Ò=$‚? Ë	\"‚À Ó	\"ÔUƒO ‚À Õ!…X Õ	!ƒd ÖË	\"!‚À ƒo Ë	\"‚À Ä	\"ÂÂÂ	?†� ×	ÂØ$‰?ƒ™ Ë	\"‚¿ ×ÂØ$Ù\"‰	ˆÚÛ	@\"ËÛ	A\"	\"\",‡" [u v nil math-poly-modulus math-poly-div-base t base vp up res math-constp math-div 1 car-safe (+ -) math-add-or-sub math-poly-div-rec 2 - math-compare 0 math-atomic-factorp math-simplify math-is-polynomial gen math-poly-div-coefs math-add math-build-polynomial-expr] 26))

(defun math-poly-div-coefs (u v) (byte-code "?ƒ ÊÁË\"‚Ð 
GGWƒ Á
B‚Ð 
AƒÇ ÁÌ
!Ì!ÍÎ@!@\"†B Ï!?…K B‰ˆAA‰…n ÐÑ@Ò@\"\"\"ˆ‚L ˆA‰ˆ+… Áˆ‚) ˆ…¯ @:ƒ« @@Ó>?…¨ @@Ô=ƒ¤ Õ@8Ö=‚¨ Ï@!‚¯ @Ö=…º A‰ˆ‚€ ˆ×ØÎ\"!B+‚Ð Í
@@\"CÁB‡" [v nil u q urev vrev qk up vp t math-reject-arg "Division by zero" reverse math-poly-div-rec math-simplify math-zerop setcar math-sub math-mul-thru (bigpos bigneg) float 1 0 nreverse mapcar] 15))

(defun math-poly-pseudo-div (u v) (byte-code "?ƒ	 Á‚¾ 
GGWƒ 
‚¾ 
A† Aƒ½ È
!È!Á‰ˆAA‰…R ÉÊË@@\"Ë@@\"\"\"ˆ‚0 ˆA‰ˆ)…w …s ÉË@@\"\"ˆA‰ˆ‚] ˆ‚) ˆ…§ @:ƒ£ @@Ì>?…  @@Í=ƒœ Î@8Ï=‚  Ð@!‚§ @Ï=…² A‰ˆ‚x ˆÑÒÓ\"!+‚¾ Á‡" [v nil u urev vrev up vp t reverse setcar math-sub math-mul-thru (bigpos bigneg) float 1 0 math-zerop nreverse mapcar math-simplify] 13))

(defun math-poly-gcd (u v) (byte-code "Å	\"ÆUƒ ‚­ Ç!ƒH :ƒ5 @È>?…2 @É=ƒ/ Ê8Æ=‚2 Ë!‚8 Æ=ƒ? 	‚E ÌÍ	!\"‚­ Ç	!ƒƒ 	:ƒp 	@Î>?…m 	@É=ƒj Ê	8Æ=‚m Ë	!‚s 	Æ=ƒz 	‚€ Ì	Í!\"‚­ Ï	\"ƒ¤ ÐÑÒÓÔÄÕ$Ô	ÄÕ$\"\"!!‚¬ ÌÍ!Í!\")‡" [u v t base nil math-compare 0 math-constp (bigpos bigneg) float 1 math-zerop calcFunc-gcd calcFunc-pcont (bigpos bigneg) math-poly-gcd-base math-simplify calcFunc-expand math-build-polynomial-expr math-poly-gcd-coefs math-is-polynomial gen] 21))

(defun math-poly-div-list (lst a) (byte-code "Â=ƒ
 	‚ Ã=ƒ Ä	\"‚ ÅÆ	\"‡" [a lst 1 -1 math-mul-list mapcar (lambda (x) (byte-code "Â	\"‡" [x a math-poly-div-exact] 3))] 4))

(defun math-mul-list (lst a) (byte-code "Â=ƒ
 	‚\" Ã=ƒ ÄÅ	\"‚\" Æ=?…\" ÄÇ	\"‡" [a lst 1 -1 mapcar math-neg 0 (lambda (x) (byte-code "Â	\"‡" [x a math-mul] 3))] 4))

(defun math-poly-gcd-list (lst) (byte-code "Â>†	 Ã>ƒ Ä!‚B @A‰…  	Â=?…5 @Å=†1 Æ	@\"‰ˆ‚ ˆ…? Ä!‰ˆ	)‡" [lst gcd 1 -1 math-poly-gcd-frac-list 0 math-poly-gcd] 5))

(defun math-poly-gcd-frac-list (lst) (byte-code "… Â@!Ã=?… A‰ˆ‚  ˆƒF Ä@8A‰…= Â@!Ã=…9 Å	Ä@8\"‰ˆ‚  ˆÃÆ	E)‚G Æ‡" [lst denom car-safe frac 2 calcFunc-lcm 1] 7))

(defun math-poly-gcd-coefs (u v) (byte-code "ÊË	!Ë
!\"ÌÌÍÎÎÎÎ		…| 
…| 	@:ƒJ 	@@Ï>?…G 	@@Ð=ƒC Ì	@8Í=‚G Ñ	@!‚N 	@Í=…| 
@:ƒx 
@@Ò>?…u 
@@Ð=ƒq Ì
@8Í=‚u Ñ
@!‚| 
@Í=…� 	A
AT‰ˆ‚ ˆÌ=†Ÿ Ó	\"Ó
\"‰ˆ	G
GZ‰ˆÍW…¾ 	
[‰ˆÔ	
\"‰ˆA…
ÓÕÖ\"\"\"	GS	8ÌXƒú ÕÖ\"ÖÌZ\"\"‚×Ö\"ÖS\"\"‰ˆ‚  ˆƒC‚!ØÓ
Ë
!\"\"‰ˆÙ
GS
8!…4Ø
Ú\"‰ˆS‰ÍY…GÍ
B‰ˆ‚5ˆ
.‡" [d u v g h z hh r delta ghd math-poly-gcd math-poly-gcd-list 1 0 nil (bigpos bigneg) float math-zerop (bigpos bigneg) math-poly-div-list math-poly-pseudo-div math-mul math-pow math-poly-div-exact math-mul-list math-guess-if-neg -1] 25))

(defun math-atomic-factorp (expr) (byte-code "Ã!Ä=ƒ ÅÆ8!… ÅÇ8!‚5 Ã!È>ƒ$ Á‚5 Ã!É>ƒ4 ÅÆ8!‚5 Â‡" [expr nil t car-safe * math-atomic-factorp 1 2 (+ - /) (^ neg)] 8))

(defun math-poly-div-base (a b) (byte-code "ÄÄÅ
!‰… Å!‰… ÆÇ�*‡" [a-base b-base a b nil math-total-polynomial-base return (byte-code "…* Ã@@
\"	…  Ä@8Ä	8Y…  ÅÆ@@\")ˆA‰ˆ‚  ‡" [a-base maybe b-base assoc 1 throw return] 5)] 4))

(defun math-poly-gcd-base (a b) (byte-code "ÄÄÅ
!‰… Å!‰… ÆÇ�*‡" [a-base b-base a b nil math-total-polynomial-base return (byte-code "… 	…G Â@8Â	@8Vƒ- Ã@@	\"ƒ& ÄÅ@@\"‚* A‰‚C Ã	@@\"ƒ? ÄÅ	@@\"‚C 	A‰ˆ‚  ‡" [a-base b-base 1 assoc throw return] 7)] 4))

(defun math-sort-poly-base-list (lst) (byte-code "ÁÂ\"‡" [lst sort (lambda (a b) (byte-code "Â8Â	8V† Â8Â	8U… Ã@	@\"‡" [a b 1 math-beforep] 3))] 3))

(defun math-total-polynomial-base (expr) (byte-code "ÁÃ
Ä\"ˆÅ!)‡" [mpb-total-base nil expr math-polynomial-base math-polynomial-p1 math-sort-poly-base-list] 3))

(defun math-polynomial-p1 (subexpr) (byte-code "Æ	\"†0 @Ç>†0 @È=… ÉÊ8!†0 Ë\"…/ D	B‰*ˆÅ‡" [subexpr mpb-total-base math-poly-base-variable exponent mpb-top-expr nil assoc (+ - * / neg) ^ natnump 2 math-polynomial-p] 5))

(defun calcFunc-factors (expr &optional var) (byte-code "	ƒ Â‚	 ÃÂÂ	† È!‰ˆÉÊË�†\" !ÌÍ!ƒ2 ‚9 ÎÎÏED!)+‡" [math-factored-vars var t nil math-to-list calc-prefer-frac expr res math-polynomial-base math-factor-finish factor (byte-code "Á!‡" [var math-factor-expr-try] 2) math-simplify math-vectorp vec 1] 8))

(defun calcFunc-factor (expr &optional var) (byte-code "ÁÁÄÇÈƒ ÄÉÊ�† )‚ Ë!!!+‡" [math-factored-vars nil math-to-list calc-prefer-frac t var expr math-simplify math-factor-finish factor (byte-code "Á!‡" [var math-factor-expr-try] 2) math-factor-expr] 4))

(defun math-factor-finish (x) (byte-code ":?†
 @Á>ƒ ‚( @Â=ƒ  ÃÄ8!‚( @ÅÃA\"B‡" [x (bigpos bigneg frac float cplx polar hms date mod var) calcFunc-Fac-Prot math-factor-finish 1 mapcar] 5))

(defun math-factor-protect (x) (byte-code "Á!Â>ƒ ÃD‚ ‡" [x car-safe (+ -) calcFunc-Fac-Prot] 3))

(defun math-factor-expr (expr) (byte-code "Á=ƒ
 
‚D Å
!Æ>† ÇÅ
!\"ƒ& 
@ÈÉ
A\"B‚D Å
!Ê>ƒC ËÌ�ƒ> É!‚? 
*‚D 
‡" [math-factored-vars t expr calc-tweak-eqn-table y car-safe (* / ^ neg) assq mapcar math-factor-expr (+ -) factor (byte-code "Á!‡" [expr math-factor-expr-part] 2)] 7))

(defun math-factor-expr-part (x) (byte-code "Ã!Ä>ƒ A‰… Å@!ˆ‚ ‚E :?†$ @Æ>?…E Ç	\"?…E È
\"ÉV…E C	B‰…E Ê!‡" [x math-factored-vars expr car-safe (+ - * / ^ neg) math-factor-expr-part (bigpos bigneg frac float cplx polar hms date sdev intv mod vec) assoc math-factor-contains 1 math-factor-expr-try] 6))

(defun math-factor-expr-try (x) (byte-code "Ç!È=ƒ0 ÉÊ�ÉË�	† 
…, ÌÉÍ	†\" Î8Î
†* Ï8#\"*‚R ÐÑÒ$Å!ÓA…Q Ô!‰…Q ÌÉ\"+‡" [expr res1 res2 p x math-poly-modulus res car-safe * factor (byte-code "Â8Ã	!)‡" [expr x 1 math-factor-expr-try] 2) (byte-code "Â8Ã	!)‡" [expr x 2 math-factor-expr-try] 2) throw math-accum-factors 1 2 math-is-polynomial 30 gen nil math-factor-poly-coefs] 9))

(defun math-accum-factors (fac pow facs) (byte-code "ƒÑ Å	!ƒ* 	A‰…% ÆÇ	@8ÈÉ	@8\"
#‰ˆ‚
 ˆ
‚Î Ê	!Ë=…7 ÌÉ	8!…F ÈÉ	8\"Ç	8‰ˆ	Ç=ƒQ 
‚Î Å
!†i 
Ç=ƒa Í‚g ÎÎ
ÇED‰ˆ
A‰…{ Ï	Ç@8\"?…ƒ Ðˆ‚l ˆƒ™ Ñ@AAÉ@8\\\"ˆ
‚Í 
A…° ÇÇ
88:?†° ÇÇ
88@Ò>ƒÄ ÎÇ
8Î	E
AABBB‚Í ÎÎ	E
ABB)‚Ø ÓÔ	\"
\"‡" [math-to-list fac facs pow found math-vectorp math-accum-factors 1 * 2 car-safe ^ natnump (vec) vec equal nil setcar (bigpos bigneg frac) math-mul math-pow] 14))

(defun math-factor-poly-coefs (p &optional square-free) (byte-code "ÍÍ
A?ƒ 
@† Ü‚Ÿ
@:ƒ: 
@@Ý>?…7 
@@Þ=ƒ3 ß
@8Ü=‚7 à
@!‚> 
@Ü=ƒ£ Ü
…r 
@:ƒn 
@@á>?…k 
@@Þ=ƒg ß
@8Ü=‚k à
@!‚r 
@Ü=…€ T
A‰ˆ‚C ˆ
Aƒ� â
\"‰‚— ãä
@!!‰ˆåæ
!#)‚Ÿ?…Á ßçè
!é
GS
8!ƒ» ê‚¼ ß\"‰=?ƒÒ åßâë
\"ì\"#‚Ÿ
AA?ƒò íæãä
@!!!çæãäß
8!!!\"\"‚Ÿ
…;@:?†@@î>†;@@ï=…;ß@8:?†&ß@8@ð>…;ñ@8:?†;ñ@8@ò>…HA‰ˆ‚õ ˆ)ƒ¤óôÉ
BEõ\"ö!÷=…™GøU…™ùñ8!…™ßñ8		A‰	…•å	@ß#‰ˆ‚}ˆ*† ú
\")‚Ÿ
ß=ƒMË=†¾ûü
ý
!‰\"‰þ\"ƒ˜ÍÿÍ
Ë#)‰ƒ‘@�@ 
GS
8!ƒáê‚âßßß8ñ8…t@@@AåƒA�A \"�B \"‰ˆííç�C ñ\"\"çç\"\"\"ç\"\")‚c�A !�B \"‰ˆíç\"ç\"\")ß#A‰*ˆ‚óˆåßçú�D ß8\"\"\"#‰-‚•ú
\"‚Jè
!�@ 
GS
8!ƒ­ê‚®ß�D \"Í�E 
\"@�E 	\"@�F �G �H ßý!ê$!‰!?…ü	\"B�E \"@�E 	\"@‰ˆ‚ÐˆGåâË\"Tß#‰ˆ…=åâ@Ë\"	#SA‰ˆ‚ ˆåç\"ß	#.‚Ÿü
ý
!\"‰G
GUƒ—@‰ˆA…€�I ñ
8\"@
B‰ˆ‚cˆâ
!‰…”�C ñ
8\"‚Ÿ�J Í�K \"*‡" [t1 t2 p z square-free x pp res facs vec math-poly-modulus t calc-symbolic-mode nil roots csign expr unfac scale coef0 coef1 den cabs t1s uu v w temp 0 (bigpos bigneg) float 1 math-zerop (bigpos bigneg) math-factor-poly-coefs math-sort-terms math-factor-expr math-accum-factors math-factor-protect math-mul math-poly-gcd-list math-guess-if-neg -1 math-poly-div-list cont math-add (bigpos bigneg frac) mod (bigpos bigneg) 2 (bigpos bigneg) math-rewrite calcFunc-thecoefs (var FactorRules var-FactorRules) car-safe calcFunc-thefactors 3 math-vectorp math-build-polynomial-expr equal math-poly-gcd-coefs math-poly-deriv-coefs (1) math-poly-all-roots math-negp math-lcm-denoms math-div math-pow math-mul-list math-poly-div-coefs math-poly-zerop math-poly-simplify math-poly-mix nthcdr math-reject-arg "*Modulo factorization not yet implemented"] 77))

(defun math-poly-deriv-coefs (p) (byte-code "ÄÂA‰… Å@\"	BT‰ˆ‚ ˆÆ	!*‡" [n dp nil p 1 math-mul nreverse] 4))

(defun math-factor-contains (x a) (byte-code "Ã	\"ƒ Ä‚N Å!Æ>ƒ/ ÇA‰…) 
È@	\"\\‰ˆ‚ ˆ
)‚N Å!É=…< ÊË8!ƒM ÌÈÄ8	\"Ë8\"‚N Ç‡" [x a sum equal 1 car-safe (+ - * / neg) 0 math-factor-contains ^ natnump 2 *] 10))

(defun calcFunc-nrat (expr) (byte-code "Ê!… Ë!‰ˆÌ!† ÍÎ!	\"ƒ& @ÏÐA\"B‚€ ÃÑ!ÒÓÔ@!!!ÒÓÔA!!!Õ\"Ö=†w ×\"×\"	AØ=…v 	AØ=…v @	@‰*ˆÒÙ\"!-‡" [expr calc-tweak-eqn-table calc-prefer-frac t res num den g num2 den2 math-any-floats calcFunc-pfrac math-vectorp assq car-safe mapcar calcFunc-nrat math-to-ratpoly math-simplify math-sort-terms calcFunc-expand math-poly-gcd 1 math-poly-div 0 math-div] 20))

(defun math-to-ratpoly (expr) (byte-code "Â	!Ã@!ÃA!B)‡" [res expr math-to-ratpoly-rec math-simplify] 5))

(defun math-to-ratpoly-rec (expr) (byte-code ":?†
 @Ç>ƒ ÈB‚ä@É>ƒÐ ÊÈ8!ÊË8!Ì	A
A\"ƒ< @	@
@E	AB‚Ì 	AÈ=ƒT @Í	@
A\"
@E
AB‚Ì 
AÈ=ƒl @	@Í
@	A\"E	AB‚Ì Î	A
A\"È=?… Ï	A\"È=?…� ÏÍ	@
A\"\"AÐ=…œ AÐ=ƒ´ @@Í
@@\"EÍ@
A\"B‚Ê @Í	@
A\"Í
@	A\"EÍ	A
A\"B*)*‚ä@Ñ=ƒÊÈ8!ÊË8!ÍÎ	@
A\"Î	A
@\"\"È=ƒÍ	@
@\"Í	A
A\"B‚ÒÍ	@
@\"\"ÒÍ	A
A\"\"B+‚ä@Ó=ƒ…ÊÈ8!ÊË8!	AÈ=…=
AÈ=ƒH	@
@B‚�ÍÎ	@
@\"Î	A
A\"\"È=ƒmÍ	@
A\"Í	A
@\"B‚€ÒÍ	@
A\"\"ÒÍ	A
@\"\"B)*‚ä@Ô=…‘ÕË8!ƒÉÊÈ8!Ë8ÐVƒ´Ö	@Ë8\"Ö	AË8\"B‚ÅÖ	AË8[\"Ö	@Ë8[\"B)‚ä@×=ƒáÊÈ8!Ø	@!	AB)‚äÈB‡" [expr r1 r2 g d1 d2 t (bigpos bigneg frac float cplx polar hms date mod var) 1 (+ -) math-to-ratpoly-rec 2 equal math-mul math-poly-gcd math-poly-div 0 * math-poly-div-exact / ^ integerp math-pow neg math-neg] 46))

(defun math-ratpoly-p (expr &optional var) (byte-code "Æ	\"ƒ Ç‚× :?† @È>ƒ É‚× @Ê>ƒB ËÇ8	\"Ä
…> ËÌ8	\"‰…> 
]*‚× @Í=ƒh ËÇ8	\"Ä
…d ËÌ8	\"‰…d 
\\*‚× @Î=ƒx ËÇ8	\"‚× @Ï=ƒž ËÇ8	\"Ä
…š ËÌ8	\"‰…š 
Z*‚× @Ð=…ª ÑÌ8!ƒÂ ËÇ8	\"
…¾ Í
Ì8\")‚× 	?ƒË Ç‚× Ò	\"ƒÖ Ä‚× É‡" [expr var p1 p2 nil t equal 1 (bigpos bigneg frac float cplx polar hms date mod var) 0 (+ -) math-ratpoly-p 2 * neg / ^ integerp math-poly-depends] 14))

(defun calcFunc-apart (expr &optional var) (byte-code ":?†
 @Ê>ƒ ‚› @Ë=ƒ) ÌÍÎ8	\"ÍÏ8	\"\"‚› @Ð=ƒA ÑÍÎ8	\"ÍÏ8	\"\"‚› Ò	\"?ƒP ÓÔ\"‚› ÂÕ!@AÖ\"@A		†x ×!‰ˆÌ	…� Ø	\"…� Ù		#†˜ Ú	\"\".‡" [expr var t calc-prefer-frac rat num den qr q r (bigpos bigneg frac float cplx polar hms date mod var) + math-add calcFunc-apart 1 2 - math-sub math-ratpoly-p math-reject-arg "Expected a rational function" math-to-ratpoly math-poly-div math-polynomial-base math-expr-contains math-partial-fractions math-div] 18))

(defun math-padded-polynomial (expr var deg) (byte-code "Ä	
#ÅÆGZÇ\"\")‡" [p expr var deg math-is-polynomial append make-list 0] 6))

(defun math-partial-fractions (r den var) (byte-code "Õ	
\"Ö	
\"Æ×ÆØS×\"	Ù
GÚU…, ÚÛ88Û=?…wA‰…Ú@8ÖÛ@8
\"ÆÆÆ×V…×‰ˆ×V…¨ ÜÝÞ	$×B	A	Sßàá
\"\"\"SU…  áÛ@8\"B‰ˆ‚_ ˆÛA‰…Ö =†Ò àáÛ@8Ú@8\"\"‰ˆ‚¯ ˆà\"‰*ˆßàáÛ@8Ú@8Z\"\"\"S‰ˆ‚O -ˆ‚0 ˆâãä
#BåãæçA\"B!\"‰ˆè!…w×Æé!‰ˆ…q@BA‰ˆ@…hêé!
\"ßâ@\"\"Æ‰ˆA‰ˆ‚6ˆë!*.‡" [fden den var tdeg fp dlist nil eqns lz tz calc-matrix-mode rpt deg dnum dvar deg2 fpp mult r res num calcFunc-factors math-polynomial-p 0 make-list scalar 2 1 append (vec) (1) math-add math-mul math-pow math-div vec math-padded-polynomial math-transpose mapcar (lambda (x) (byte-code "ÃÄ	
#B‡" [x var tdeg vec math-padded-polynomial] 5)) math-vectorp nreverse math-build-polynomial-expr math-normalize] 29))

(defun math-expand-term (expr) (byte-code "Ä!Å=… ÄÆ8!Ç>ƒ2 ÈÅÆÆ88É8EÅÉÆ88É8EÁÆ8@Ê=$‚ú Ä!Å=…A ÄÉ8!Ë>ƒd ÈÅÆ8ÆÉ88EÅÆ8ÉÉ88EÁÉ8@Ê=$‚ú Ä!Ì=…s ÄÆ8!Í>ƒ– ÈÌÆÆ88É8EÌÉÆ88É8EÁÆ8@Ê=$‚ú Ä!Î=…ö ÄÆ8!Ï>…ö ÐÉ8!…ö É8ÑVƒâ 
ÒV†Á 
ÓW…Î ÔÆ8É8ÁÃ$†ß ÅÆ8ÎÆ8É8SEE‚ö É8ÑW…ö ÌÆÎÆ8É8[EE†ú ‡" [expr nil mmt-many t car-safe * 1 (+ -) math-add-or-sub 2 - (+ -) / (+ -) ^ (+ -) integerp 0 500000 -500000 math-expand-power] 19))

(defun calcFunc-expand (expr &optional many) (byte-code "ÂÃÄ	#!‡" [expr many math-normalize math-map-tree math-expand-term] 5))

(defun math-expand-power (x n &optional var else-nil) (byte-code "Í!…ªÎ	!Ï>…ªÃÃÎ	!Ð>…8 	@Ñ=ƒ) ÒÓ	8!‚, Ó	8
BÔ	8‰ˆ‚ ˆ	
B‰ˆ…{ 
…m Õ@\"†b Ö@
\"@B‰ˆA‰ˆ‚F ˆ…z ×Ø\"
B‰)ˆ
GÓUƒ¿ ÙÙX…¸ ÚÛÜ\"ÛÝÔ
8EÝ
@ZEEEET‰ˆ‚‰ ˆ*‚©ÓUƒÙ
Ã
		…ÚÝ	@ÓEE	‰
ˆ
A‰
…ÚÛÓÛ	@
@EEE‰ˆ‚å ˆ	A‰	ˆ‚Î ˆ+‚©ÞU…©Ù
ÃÃ
		…¥ÚÝ	@ÞEE	‰
ˆ
A‰
…šÚÚÛÞÛÝ	@ÓE
@EEEÛÞÛ	@Ý
@ÓEEEE
‰ˆA‰…–ÚÛßÛ	@Û
@@EEEE‰ˆ‚rˆ‚?ˆ	A‰	ˆ‚(ˆ,*†·?…·Ý	E‡" [n x terms nil cterms var p i accum p1 p2 p3 else-nil natnump car-safe (+ -) (+ -) - math-neg 2 1 math-expr-contains delq apply calcFunc-add 0 + * calcFunc-choose ^ 3 6] 20))

(defun calcFunc-expandpow (x n) (byte-code "ÂÃ	\"!‡" [x n math-normalize math-expand-power] 4))
