2023-05-19 14:35:34 +0100 | received badge | ● Notable Question (source) |
2019-10-20 05:42:51 +0100 | commented answer | Taylor expansion crashing (python3) Ok in the terminal; I begin to understand. In fact my need is to make the Taylor expansion of an user-defined symbolic expression quite deep inside a script I'm writing. Something like that I guess: The problem is that |
2019-10-19 17:23:05 +0100 | received badge | ● Editor (source) |
2019-10-19 16:22:27 +0100 | asked a question | Taylor expansion crashing (python3) I type the following in the sage terminal : That causes me quite a crash I do not understand. I tried with some variations, like or Both are working well. EDIT : This one
I guess it is due to the Sage's preparser. Any idea ? Why does the Taylor expansion of that particular function crashes from order 3 ? If it is important, I'm using a home-compiled version of Sage with python3 : ┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 8.9, Release Date: 2019-09-29 │ │ Using Python 3.7.3. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ Here is the trace : ┌─────────────────────────────────┐ │ SageMath version 8.9, Release Date: 2019-09-29 │ │ Using Python 3.7.3. Type "help()" for help. │ └─────────────────────────────────┘ sage: f = (x+1)**(0.1)+exp(x) sage: f.taylor(x,0,3)RuntimeError Traceback (most recent call last) /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/interface.py in __init__(self, parent, value, is_name, name) 707 try: --> 708 self._name = parent._create(value, name=name) 709 except (TypeError, RuntimeError, ValueError) as x: /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/maxima_lib.py in _create(self, value, name) 605 else: --> 606 self.set(name, value) 607 except RuntimeError as error: /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/maxima_lib.py in set(self, var, value) 514 cmd = '%s : %s$'%(var, value.rstrip(';')) --> 515 self.eval(cmd) 516 /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/maxima_lib.py in _eval_line(self, line, locals, reformat, **kwds) 460 if statement: --> 461 maxima_eval("#$%s$" % statement) 462 if not reformat: /home/moky/.Sage/local/lib/python3.7/site-packages/sage/libs/ecl.pyx in sage.libs.ecl.EclObject.__call__ (build/cythonized/sage/libs/ecl.c:7793)() 805 lispargs = EclObject(list(args)) --> 806 return ecl_wrap(ecl_safe_apply(self.obj,(<eclobject>lispargs).obj)) 807 /home/moky/.Sage/local/lib/python3.7/site-packages/sage/libs/ecl.pyx in sage.libs.ecl.ecl_safe_apply (build/cythonized/sage/libs/ecl.c:5455)() 377 s = si_coerce_to_base_string(ecl_values(1)) --> 378 raise RuntimeError("ECL says: {}".format( 379 char_to_str(ecl_base_string_pointer_safe(s)))) RuntimeError: ECL says: In function GCD, the value of the first argument is 0.91 which is not of the expected type INTEGER During handling of the above exception, another exception occurred: TypeError Traceback (most recent call last) <ipython-input-2-ed48eb8006d1> in <module>() ----> 1 f.taylor(x,Integer(0),Integer(3)) /home/moky/.Sage/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.taylor (build/cythonized/sage/symbolic/expression.cpp:27942)() 4581 except Exception: 4582 raise NotImplementedError("Wrong arguments passed to taylor. See taylor? for more details.") -> 4583 l = self._maxima_().taylor(B) 4584 return self.parent()(l) 4585 /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/interface.py in __call__(self, args, *kwds) 668 669 def __call__(self, args, *kwds): --> 670 return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds) 671 672 def help(self): /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/interface.py in function_call(self, function, args, kwds) 589 [s.name() for s in args], 590 ['%s=%s'%(key,value.name()) for key, value in kwds.items()]) --> 591 return self.new(s) 592 593 def _function_call_string(self, function, args, kwds): /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/interface.py in new(self, code) 358 359 def new(self, code): --> 360 return self(code) 361 362 ################################################################### /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/interface.py in __call__(self, x, name) 286 287 if isinstance(x, string_types): --> 288 return cls(self, x, name=name) 289 try: 290 # Special methods do not and should not have an option to /home/moky/.Sage/local/lib/python3.7/site-packages/sage/interfaces/interface.py in __init__(self, parent, value, is_name, name) 708 self._name = parent._create(value, name=name) 709 except (TypeError, RuntimeError, ValueError) as x: --> 710 raise TypeError(x) 711 712 def _latex_(self): TypeError: ECL says: In function GCD, the value of the first argument is 0.91 which is not of the expected type INTEGER |
2019-09-29 19:44:33 +0100 | received badge | ● Popular Question (source) |
2017-06-16 16:59:03 +0100 | commented answer | Undeterministic numerical approximation Thanks for the answer. Since I am only interested in the firsts decimals (these are coordinates of of points on a A4 paper, in centimeters), I didn't though to increase the precision. I'l have to tests that. |
2017-06-15 08:16:06 +0100 | received badge | ● Student (source) |
2017-06-15 04:32:32 +0100 | asked a question | Undeterministic numerical approximation Let the following expression of
I noticed that evaluating that for the value I guess that this is a "cancellation error" : the last term ( I'm only interested in the first 3 or 4 decimals.
|