solve error

1 view
Skip to first unread message

geir egeland

unread,
Sep 17, 2009, 7:24:56 AM9/17/09
to sage-s...@googlegroups.com
Hi,
I am trying to solve the following equation:
sage: f(x)=((1-0.15)/(1-0.15+(0.15/(1-x*0.15)^22)))^3-x
sage: solve(f,x)

This gives me the following error, which doesn't make much sense to me.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/geg/<ipython console> in <module>()

/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
    478     """
    479     try: 
--> 480         return f.solve(*args,**kwds)
    481     except AttributeError:
    482         from sage.symbolic.ring import is_SymbolicVariable

/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.solve (sage/symbolic/expression.cpp:22150)()

/Applications/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in __call__(self, *args, **kwds)
   1380 
   1381     def __call__(self, *args, **kwds):
-> 1382         return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
   1383     
   1384     def help(self):

/Applications/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in function_call(self, function, args, kwds)
   1288                                        [s.name() for s in args],
   1289                                        ['%s=%s'%(key,value.name()) for key, value in kwds.items()])
-> 1290         return self.new(s)
   1291 
   1292     def _function_call_string(self, function, args, kwds):

/Applications/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in new(self, code)
   1084 
   1085     def new(self, code):
-> 1086         return self(code)
   1087 
   1088     ###################################################################

/Applications/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in __call__(self, x, name)
   1019             
   1020         if isinstance(x, basestring):
-> 1021             return cls(self, x, name=name)
   1022         try:
   1023             return self._coerce_from_special_method(x)

/Applications/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
   1423             except (TypeError, KeyboardInterrupt, RuntimeError, ValueError), x:
   1424                 self._session_number = -1
-> 1425                 raise TypeError, x
   1426         self._session_number = parent._session_number
   1427 

TypeError: Error executing code in Maxima
CODE:
sage14 : to_poly_solve(sage10,sage13)$
Maxima ERROR:
Assuming that 2.572052771128644e-55*x^66-1.131703219296603e-52*x^65+2.452023641809308e-50*x^64-3.487322512795459e-48*x^63+3.661688638435233e-46*x^62-3.02699594110646e-44*x^61+2.05163058230549e-42*x^60-1.172360332745994e-40*x^59+5.764104969334469e-39*x^58-2.476430283121475e-37*x^57+9.410435075861606e-36*x^56-3.193844631807575e-34*x^55+9.758969708300927e-33*x^54-2.702483919221794e-31*x^53+6.820554653274052e-30*x^52-1.576305964312226e-28*x^51+3.34965017416348e-27*x^50-6.567941517967608e-26*x^49+1.191959756964492e-24*x^48-2.007511169624407e-23*x^47+3.145100832411571e-22*x^46-4.592845660029597e-21*x^45+6.262971354585815e-20*x^44-7.987557669616691e-19*x^43+9.540693883153281e-18*x^42-1.068557714913174e-16*x^41+1.123355546447224e-15*x^40-1.10948695945426e-14*x^39+1.030237890922699e-13*x^38-8.999779277056846e-13*x^37+7.399818516783484e-12*x^36-5.72889175516733e-11*x^35+4.177316905347902e-10*x^34-2.8692681784864726e-9*x^33+1.8565852938761138e-8*x^32-1.1316329440808763e-7*x^31+6.496411389445956e-7*x^30-3.5115737808419006e-6*x^29+1.786590236047529e-5*x^28-8.551201844988561e-5*x^27+3.848041527553564e-4*x^26-.001626814924957227*x^25+.006455619830316614*x^24-.02402094856854791*x^23+.08370962213783728*x^22-.2728329566931009*x^21+.8303702781628282*x^20-2.355707893620063*x^19+6.216678118439924*x^18-15.22550497577382*x^17+34.51506024624435*x^16-72.20248123719546*x^15+138.897086824694*x^14-244.7350019836468*x^13+393.1470391342294*x^12-572.7129912818109*x^11+751.8090164270538*x^10-882.7296150886173*x^9+918.7738209313588*x^8-838.4801227519146*x^7+661.7724868308338*x^6-443.7020662052342*x^5+246.62875545*x^4-109.676271375*x^3+36.8577*x^2-8.415*x+1.0 # 0
`allroots': not a polynomial:
errexp1
#0: to_poly_solve(e=.6141249999999999/(0.15/(1-0.15*x)^22+0.85)^3-x = 0,vars=x)(topoly_solver.mac line 15)

I can solve this equation using Mathematica, but would prefer to use sage. Any ideas ?

regards,
Geir Egeland
phone +47 906 40 507
PhD Candidate
University of Stavanger




x x

unread,
Sep 17, 2009, 8:47:45 AM9/17/09
to sage-s...@googlegroups.com
> I am trying to solve the following equation:
> sage: f(x)=((1-0.15)/(1-0.15+(0.15/(1-x*0.15)^22)))^3-x

Hi,

When writing 15/100 instead 0.15 it outputs:

[x == 0.302350301169,
x == (0.67362336338 + 0.678659962463*I),
x == (0.67362336338 - 0.678659962463*I)]

Although solve only accepts from the SymbolicRing (i don't know what
this is b.t.w.) i suspect it solves over extensions of the rational
numbers.

Or maybe it decides to use numerical methods when the coefficients of
the input equation are real numbers, and in this example the numerical
methods give rise to a bug.

Or maybe something else? ;-)

Thanks,

Niels

kcrisman

unread,
Sep 17, 2009, 9:31:18 AM9/17/09
to sage-support
Dear Niels and Geir,

Because we use Maxima as our backend for such things, there are some
compromises we have to accept. One that is currently being worked on
is precisely this issue.

In particular, one subroutine within the Sage solve is the Maxima
to_poly_solve, which uses a routine in Maxima called algsys, which
does indeed return floating-point answers when it cannot return exact
answers. (I suspect that this was not known by whoever added this
functionality. However, it is only recently that we've been getting
reports like this.)

See http://groups.google.com/group/sage-devel/browse_thread/thread/e797a9904baaa4a6/77a322b8a84b054a?show_docid=77a322b8a84b054a
as well.

- kcrisman
Reply all
Reply to author
Forward
0 new messages