Re: Kernel Problem
- To: mathgroup at smc.vnet.net
- Subject: [mg54943] Re: Kernel Problem
- From: Peter Pein <petsie at arcor.de>
- Date: Mon, 7 Mar 2005 02:10:27 -0500 (EST)
- References: <d0denl$lfr$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Dana DeLouis wrote: > Hello. I'd like to ask a question. The function below shuts down my > Kernel. Is it just me, or is this reproducible on other Windows machines. > Thanks for any feedback. > > Needs["NumberTheory`NumberTheoryFunctions`"] > > Information[QuadraticRepresentation] > > "QuadraticRepresentation[d, n] gives {x, y}, where x^2 + d y^2 = n for \ > positive d and odd n." > > QuadraticRepresentation[12, 9] > > (Problem, and the Kernel shuts down!) > > TIA > Dana DeLouis > Simply define your own function: In[1]:= QuadRep[d_, n_, sel_:{First, #1 & }] := If[Length[#]<2,{},#]&@ Flatten[ Extract[#1, (Position[#1, sel[[1]][#1], 1, 1] & )[sel[[2]] /@ #1]] & [Block[{x, y, Null}, {x, y} /. {ToRules[Reduce[{x^2 + d*y^2 == n && x>=0&&y>=0}, {x, y},Integers]]}]], 1] In[2]:= QuadRep[12,9] Out[2]= {3,0} from the Mathematica documentation: In[3]:= QuadRep[3,13*31*61*Prime[10^7]] Out[3]= {778,1212545} or select the solution with the smaller of {x,y} becoming maximal: In[4]:= QuadRep[3,13*31*61*Prime[10^7],{Max,Min}] Out[4]= {1118614,1026239} This is just a quick hack and might need further verification. -- Peter Pein Berlin