# Numerical approximations edit

g(x)=x^2-sqrt(2)
solve(g(x)==0,x)

[x == -2^(1/4), x == 2^(1/4)]


What's the best/quickest way to get numerical approximations of these values of x? Thanks.

edit retag close merge delete

Sort by » oldest newest most voted

Try taking the right hand side of each solution.

sage: A =    solve(g(x)==0,x)
sage: [a.rhs().n() for a in A]
[-1.18920711500272, 1.18920711500272]


where n() is short for numerical_approx(). There are other ways of approaching this as well, such as via the solution_dict=True keyword to solve().

more

With my background neither is particularly straight-forward but I am happy to learn about both methods. Thanks.

more

In your case, since g can be seen as a polynomial, you can also look at its roots in the real double field (floating-point approximations with 53 bits of precision):

sage: g.polynomial(RDF).roots()
[(-1.189207115002721, 1), (1.189207115002721, 1)]

more

I see two ordered pairs, I think, but if that's so I don't understand why the y-values are 1 and not 0.

( 2015-06-05 14:49:09 +0200 )edit

OK. "The first of the pair is the root, the second of the pair is its multiplicity."

( 2015-06-05 17:07:38 +0200 )edit
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.15394295752048492, "perplexity": 2519.188432213213}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-17/segments/1618039601956.95/warc/CC-MAIN-20210423041014-20210423071014-00247.warc.gz"}