-1

The assignment is to construct a two-column table that starts at x= -4 and ends with x= 5 with one unit increments between consecutive x values. It should have column headings ‘x’ and ‘f(x)’. I can't find anything helpful on html.table(), which is what we're supposed to use.

This what I have so far. I just have no idea what to put into the html.table function.

x = var('x')
f(x) = (5 * x^2) - (9 * x) + 4
html.table()
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
PsylentKnight
  • 149
  • 14

2 Answers2

2

You might want to have a look at sage's reference documentation page on html.table

It contains the following valuable information :

table(x, header=False)

Print a nested list as a HTML table. Strings of html will be parsed for math inside dollar and double-dollar signs. 2D graphics will be displayed in the cells. Expressions will be latexed.

INPUT:

  x – a list of lists (i.e., a list of table rows)
  header – a row of headers. If True, then the first row of the table is taken to be the header.

There is also an example for sin (instead of f) with x in 0..3 instead of -4..5, that you can probably adapt pretty easily :

html.table([(x,sin(x)) for x in [0..3]], header = ["$x$", "$\sin(x)$"])
Community
  • 1
  • 1
Cimbali
  • 11,012
  • 1
  • 39
  • 68
  • Thanks, that got it done. I had actually found that documentation page, but I didn't think that that was what I needed because of all the html. Are those bits just supposed to be the html equivalent of the sage syntax? – PsylentKnight Jan 22 '15 at 21:01
1

@Cimbali has a great answer. For completeness, I'll point out that you should be able to get this information with

html.table?

or, in fact,

table?

since I would say we want to advocate the more general table function, which has a lot of good potential for you.

kcrisman
  • 4,374
  • 20
  • 41