Tip of the Day : Beals Conjecture - A Search for Counterexamples Using SQL Server

Welcome to SQL Server Helper !!!

This site is intended for those who are beginning to use SQL Server as part of their day-to-day activities.  You will find in this site a collection of useful functions, triggers, stored procedures and tips and tricks related to SQL Server.

Should you have any comments or questions regarding this site or if you want to ask SQL Server-related questions, e-mail us here.

We hope we are able to help and we are glad to help!!!

SQL Server Tip of the Day - September 18, 2020

Beals Conjecture - A Search for Counterexamples Using SQL Server

According to Wikipedia, Beal's conjecture is a conjecture in number theory proposed by Andrew Beal in 1993.  While investigating generalizations of Fermat's last theorem in 1993, Beal formulated the following conjecture:

If

Ax + By = Cz

where A, B, C, x, y and z are positive integers with x, y, z > 2, then A, B, and C have a common prime factor.

For a proof or counterexample published in a refereed journal, Beal initially offered a prize of $ 5,000 in 1997, rising to $50,000 over ten years, and now has been raised to $1,000,000 (as of June 6, 2013).

In finding a counterexample, with the help of the [dbo].[spt_values] table in the master database, a simple query can be used to identify different possible values for the six variables that will satisfy the equation.

DECLARE @MaxBase      INT
DECLARE @MaxPower     INT

SET @MaxBase  = 10
SET @MaxPower = 10

SELECT A.[Number] AS A, B.[Number] AS B, C.[Number] AS C, x.[Number] AS x, y.[Number] AS y, z.[Number] AS z
FROM (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 1 AND @MaxBase) A
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 1 AND @MaxBase) B
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 1 AND @MaxBase) C
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 3 AND @MaxPower) x
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values]
      WHERE [type] = 'P' AND [number] BETWEEN 3 AND @MaxPower) y
      CROSS JOIN
     (SELECT CAST([Number] AS FLOAT) AS [Number]
      FROM [master].[dbo].[spt_values] 
      WHERE [type] = 'P' AND [number] BETWEEN 3 AND @MaxPower) z
WHERE POWER(A.[Number], x.[Number]) + POWER(B.[Number], y.[Number]) = POWER(C.[Number], z.[Number])
ORDER BY A.[Number], B.[Number], C.[Number]

Here's the first ten values for the six variables that satisfy the equation:

A    B    C    x    y    z
---  ---  ---  ---  ---  ---
2    2    2    4    4    5
2    2    2    8    8    9
2    2    2    3    3    4
2    2    2    7    7    8
2    2    2    6    6    7
2    2    2    5    5    6
2    2    2    9    9    10
2    2    4    5    5    3
2    2    4    7    7    4
2    2    4    9    9    5

Unfortunately, no counterexample was identified using this query. Also, as the value of the x, y and z variables grow bigger, the result becomes incorrect. As an example, increasing the value of the @MaxPower to 20 yields the following incorrect results:

A    B    C    x    y    z
---  ---  ---  ---  ---  ---
1    7    7    3    20    20
1    7    7    4    20    20
1    7    7    5    20    20
1    7    7    6    20    20
1    7    7    7    20    20
1    7    7    8    20    20
1    7    7    9    20    20
1    7    7    10   20    20
1    7    7    11   20    20
1    7    7    12   20    20

SQL Server 2012

SQL Server 2008

User-Defined Functions

Date Functions

A collection of useful user-defined functions that deal with dates.

String Functions

A collection of useful user-defined functions that deal with strings (varchar/char/nvarchar/nchar).

Tree Functions

A collection of useful user-defined functions that deal with tree or hierarchical design structures.

Table-Valued Functions

A collection of useful table-valued user-defined functions that can be used to join with other tables.

SQL Server Built-in Functions

A reference to all built-in functions available within SQL Server grouped into categories.

Tips and Tricks

A collection of useful SQL Server-related tips and tricks:

SQL Server Error Messages

A list of SQL Server error messages and for certain error messages, discusses ways on how to solve the error or work around them:

Frequently Asked Questions