1 | initial version |
Hello, @chazzs! By commenting the first line and uncommenting the third as you suggested, gives the following error message:
n xn yn
-----------------------
0 0.0 1.000000
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/tmp/ipykernel_2545862/3479229349.py in <module>
12 yn = yn+k1*h
13 xn = xn+h
---> 14 print("{:3.0f}{:7.1f}{:12.6f}".format(i,xn,yn))
TypeError: unsupported format string passed to sage.symbolic.expression.Expression.__format__
(It is important that you include backtraces and error messages in your post so it is easier for us to address the problem.)
In simple terms, this message says that you are trying to convert a _symbolic expression_ to a _float_ expression. Unfortunately, SageMath currently does not support this conversion. I reported this a couple of years ago on this same forum. Here is the (still) open ticket and my original question.
Basically, f(x,y) = (x - y) / (y + 1)
is a symbolic way of defining functions (i.e., symbolic functions), while the def
way is more general. Until this problem is solved, you should stick with def
is you want to use the value of a function in a formatted string.
Hope this helps!