       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`"]
>
>
>  "QuadraticRepresentation[d, n] gives {x, y}, where x^2 + d y^2 = n for \
> positive d and odd n."
>
>
> (Problem, and the Kernel shuts down!)
>
> TIA
> Dana DeLouis
>

In:=
QuadRep[d_, n_, sel_:{First, #1 & }] :=
If[Length[#]<2,{},#]&@
Flatten[
Extract[#1, (Position[#1, sel[][#1], 1, 1] & )[sel[] /@ #1]] &
[Block[{x, y, Null}, {x, y} /.
{ToRules[Reduce[{x^2 + d*y^2 == n && x>=0&&y>=0},
{x, y},Integers]]}]],
1]
Out= {3,0}

from the Mathematica documentation:
Out= {778,1212545}

or select the solution with the smaller of {x,y} becoming maximal:
Out= {1118614,1026239}

This is just a quick hack and might need further verification.

--
Peter Pein
Berlin

```

• Prev by Date: Help on iteration
• Next by Date: Re: Re: Re: Re: Re: Re: Bug in Import?
• Previous by thread: Re: Kernel Problem
• Next by thread: Setting the ResultFormat in a ASP.NET WebApplication.