MATLAB Examples

# Sharpening module

Section 7.2 from Numerically solving polynomial systems with Bertini, by Daniel J. Bates, Jonathan D. Haunstein, Andrew J. Sommese and Charles W. Wampler (SIAM 2013).

The sharpening module can be used to sharpen solutions after a homotopy run. Here we solve the system

$y=x^{10}, \quad y=10^{-10},$

which has ten nonsingular isolated solutions :

$\left(\omega^k/10, 10^{-10}\right),$

where $\omega = \exp\left(i\pi/5\right)$ is the tenth root of unity.

poly_system = BertiniLab('function_def',{'y-x^10'; 'y-1e-10'},'variable_group',{'x','y'});
poly_system = solve(poly_system);

% Display the tally of singular and nonsingular solutions
s = poly_system.solve_summary;
istart = strfind(s,'NOTE: nonsingular');
iend = strfind(s,'Finite Multiplicity')-1;
disp(s(istart:iend))
NOTE: nonsingular vs singular is based on condition number and identical endpoints

| Number of real solns	|  Number of non-real solns	|  Total
------------------------------------------------------------------------------------------
Non-singular	|	0		|		0		|   0
Singular	|	2		|		8		|   10
------------------------------------------------------------------------------------------
Total		|	2		|		8		|   10

As the above summary indicates, all 10 solutions appear to be singular. However, the condition numbers are all high:

sols = poly_system.match_solutions('singular_solutions');
condnum = [solution_info.condition_number].';
xsols = double(sols.x); ysols = double(sols.y);
fprintf('%17s %32s %22s\n','x','y','condition number')
fprintf('%15.4g + %7.4gi %15.4g + %5.4gi %15.4g\n',[real(xsols) imag(xsols) real(ysols) imag(ysols) condnum].')
x                                y       condition number
0.1 + -3.458e-17i           1e-10 + -4.686e-23i        3.23e+08
0.0809 + 0.05878i           1e-10 + 1.553e-22i       2.996e+08
0.0309 + 0.09511i           1e-10 + 3.352e-22i       5.089e+08
-0.0309 + 0.09511i           1e-10 + 3.979e-22i        1.05e+09
-0.0809 + 0.05878i           1e-10 + 2.821e-22i       1.762e+09
-0.1 + 3.32e-17i           1e-10 + 3.083e-23i       1.732e+09
-0.0809 + -0.05878i           1e-10 + -2.202e-22i       1.009e+09
-0.0309 + -0.09511i           1e-10 + -3.505e-22i       4.892e+08
0.0309 + -0.09511i           1e-10 + -3.488e-22i       3.009e+08
0.0809 + -0.05878i           1e-10 + -2.209e-22i       3.239e+08

Now Bertini can be told to reprocess the file using the configuration setting SharpenOnly and a higher condition number threshold.

Since only the configuration needs changing, we can modify the existing BertiniLab object.

poly_system.config = struct('SharpenOnly',1,'CondNumThreshold',1e12);

In this module, Bertini prompts the user for input. If the command

poly_system = poly_system.solve

is used, the user will be prompted for a response:

Sharpening options:
1. Sharpen all endpoints
2. Sharpen endpoints listed in a file
3. Manually input endpoints to sharpen
4. Recreate output (i.e., run the post-processor)
5. Change the number of sharpening digits (currently 14 digits)
6. Change the sharpening method (currently Newton's method)
7. Quit

If the user chooses option 4, Bertini runs the post-processor with the new condition number threshold.

This can be automated by feeding Bertini the responses to the prompts. One way to do this is to give a cell array with a string for each response (in this case, '4') as the third argument.

poly_system.interactive_choices = {'4'};
poly_system = poly_system.solve;
%
% fid = fopen('interactive_choices','w');
% fprintf(fid,'4\n');
% fclose(fid);
% [~,result] = system([poly_system.program_name,' input < interactive_choices']);

% Display the tally of singular and nonsingular solutions
result = poly_system.solve_summary;
istart = strfind(result,'NOTE: nonsingular');
iend = strfind(result,'Finite Multiplicity')-1;
disp(result(istart:iend))
NOTE: nonsingular vs singular is based on condition number and identical endpoints

| Number of real solns	|  Number of non-real solns	|  Total
------------------------------------------------------------------------------------------
Non-singular	|	2		|		8		|   10
Singular	|	0		|		0		|   0
------------------------------------------------------------------------------------------
Total		|	2		|		8		|   10

Now Bertini recognizes that all the solutions are nonsingular.