MATLAB Examples

# Intersections of straight lines

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

Find the zeros of the function

$f(x,y) = \left( x^2-1, y^2-4 \right),$

which are four isolated solutions (the intersections of two pairs of parallel lines).

To formulate the polynomial system, we use cell arrays of strings. In the function definition, you must be careful to use a semicolon between equations so the result is a column vector. If there is more than one column, BertiniLab expects the first column to be the equation names.

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

The summary of this run, which by default Bertini sends to the screen, is captured in poly_system.solve_summary:

disp(poly_system.solve_summary) 
 Bertini(TM) v1.4 (October 23, 2013) D.J. Bates, J.D. Hauenstein, A.J. Sommese, C.W. Wampler (using GMP v5.1.3, MPFR v3.1.2) NOTE: You have requested to use adaptive path tracking. Please make sure that you have setup the following tolerances appropriately: CoeffBound: 7.727433000000e+00, DegreeBound: 2.000000000000e+00 AMPSafetyDigits1: 1, AMPSafetyDigits2: 1, AMPMaxPrec: 1024 Tracking path 0 of 4 Finite Solution Summary NOTE: nonsingular vs singular is based on condition number and identical endpoints | Number of real solns | Number of non-real solns | Total ------------------------------------------------------------------------------------------ Non-singular | 4 | 0 | 4 Singular | 0 | 0 | 0 ------------------------------------------------------------------------------------------ Total | 4 | 0 | 4 Finite Multiplicity Summary Multiplicity | Number of real solns | Number of non-real solns ------------------------------------------------------------------------------------------ 1 | 4 | 0 ------------------------------------------------------------------------------------------ The following files may be of interest to you: main_data: A human-readable version of the solutions - main output file. raw_solutions: A list of the solutions with the corresponding path numbers. raw_data: Similar to the previous, but with the points in Bertini's homogeneous coordinates along with more information about the solutions. real_finite_solutions: A list of all real finite solutions. finite_solutions: A list of all finite solutions. nonsingular_solutions: A list of all nonsingular solutions. singular_solutions: A list of all singular solutions. ------------------------------------------------------------------------------------------ Paths Tracked: 4 

All the solutions are stored in raw_solutions, but since they are real they are also stored in real_finite_solutions:

sols = poly_system.match_solutions('real_finite_solutions'); disp('x, y =') disp([real(double(sols.x)) real(double(sols.y))]) 
x, y = 1.0000 2.0000 1.0000 -2.0000 -1.0000 2.0000 -1.0000 -2.0000