4748495051525354
Set roots = quad.solve(); System.out.printf(" %s = %s%n", x, roots); Expression x1 = parser.parse("(5 + sqrt(13)) / 2"); Expression x2 = parser.parse("(5 - sqrt(13)) / 2"); Expression expected = new FiniteSet(x1, x2); assertEquals(expected, roots); }
7677787980818283
System.out.printf("%s : %s = ?%n", quad, x); Set roots = quad.solve(); System.out.printf(" %s = %s%n", x, roots); Expression expected = new FiniteSet(Naturals.one(), Rationals.getInstance().create(-1, 2)); assertEquals(expected, roots); }
93949596979899100
Set roots = quad.solve(); System.out.printf(" %s = %s%n", x, roots); Expression x1 = parser.parse("16 + sqrt(266)"); Expression x2 = parser.parse("16 - sqrt(266)"); Expression expected = new FiniteSet(x1, x2); assertEquals(expected, roots); }
110111112113114115116117
Set roots = quad.solve(); System.out.printf(" %s = %s%n", x, roots); Expression x1 = parser.parse("(sqrt(15 + 144sqrt(3)) - sqrt(15)) / 6"); Expression x2 = parser.parse("(-sqrt(15) - sqrt(15 + 144sqrt(3))) / 6"); Expression expected = new FiniteSet(x1, x2); assertEquals(expected, roots); }
39404142434445
System.out.printf("%s : %s = ?%n", req, x); Set roots = req.solve(); System.out.printf(" %s = %s%n", x, roots); assertEquals(roots, new FiniteSet(Naturals.getInstance().create(17))); }
51525354555657
System.out.printf("%s : %s = ?%n", req, x); Set roots = req.solve(); System.out.printf(" %s = %s%n", x, roots); assertEquals(roots, new FiniteSet(Naturals.getInstance().create(26))); }
63646566676869
System.out.printf("%s : %s = ?%n", req, x); Set roots = req.solve(); System.out.printf(" %s = %s%n", x, roots); assertEquals(roots, new FiniteSet(Naturals.getInstance().create(0))); }
91929394959697
// for (Equality s : req.getSteps()) { // System.out.printf(" %s%n", s); // } assertEquals(roots, new FiniteSet(Naturals.one())); }
155156157158159160161162163164165
if (satisfies(e)) { checked.add(e); } } return new FiniteSet(checked); } else if (result instanceof EmptySet) { return result; } else { throw new IllegalStateException("Set type not yet supported: " + result); }
163164165166167168169
return Precedence.Multiplication; } @Override public Set domain() { return new CartesianProduct(Reals.getInstance(), new Difference(Reals.getInstance(), new FiniteSet(Naturals.zero()))); }