Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Goal: create testusite with correct solutions: I have samples.sage:

eq0a =1.754223168770020-1.189676139503717*x-0.908314931206405*y+0.686617674306035*x^2-0.725234915502369*x*y-1.352818138897419*y^2 == 0
eq0b =1.463137484435483-0.511046565137804*x-0.297304930165410*y-1.671951361931860*x^2-0.100823741406202*x*y-1.717722679488361*y^2 == 0
eq1a =1.333662021786013-0.908314931206405*x+0.686617674306035*y-0.725234915502369*x^2-1.352818138897419*x*y-0.511046565137804*y^2 == 0
eq1b =0.418361927859167-0.297304930165410*x-1.671951361931860*y-0.100823741406202*x^2-1.717722679488361*x*y+1.363417739048600*y^2 == 0
eq2a =0.054290627837304-0.626953722909093*x-1.718449720181525*y+1.862912494689226*x^2-1.980401362292469*x*y+0.330725008621812*y^2 == 0
eq2b =-0.894123614194686-0.083563295193017*x+0.953402206301689*y+1.470303879119456*x^2+0.665378382429481*x*y+0.444558157585561*y^2 == 0

After

solutions = solve([eq0a, eq0b], x, y)
sage: print(solutions)

I have

[
[x == 0.03137993762993763, y == 0.8340287436254057],
[x == 0.4135661133371494, y == 0.657632522917497],
[x == (-0.01014352680353612 + 0.8819542016100413*I), y == (-1.361968819165564 + 0.06838174575693547*I)],
[x == (-0.01014352680353612 - 0.8819542016100413*I), y == (-1.361968819165564 - 0.06838174575693547*I)]
]

Now I want output.txt with coefficients and roots:

0
1.754223168770020
-1.189676139503717
-0.908314931206405
0.686617674306035
-0.725234915502369
-1.352818138897419
real roots=2
0.03137993762993763
0.8340287436254057
0.4135661133371494
0.657632522917497
1
......

How do it ? how output numbers to text file with Sage?