Documentation

This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

`numlib`::`cornacchia`

Cornachia's algorithm

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

```numlib::cornacchia(`a`, `b`, `m`)
```

Description

`numlib::cornacchia(a, b, m)` returns all pairs of positive and relatively prime integers x, y that solve the equation ax2 + by2 = m.

The arguments `a`, `b`, `m` must be pairwise relatively prime.

Examples

Example 1

We compute the solutions to 3 x2 + 5 y2 = 74533332452454382449233:

`numlib::cornacchia(3, 5, 74533332452454382449233)`

Example 2

For non-prime `m`, there may be many solutions:

`numlib::cornacchia(1, 4, 5*13*17*29*73)`

Parameters

 `a` A positive integer `b` A positive integer `m` A positive integer

Return Values

`numlib::cornacchia` returns a set each element of which is a list of two positive integers.