Ask Your Question
-2

Translation

asked 2011-04-02 11:37:46 -0500

Sagud gravatar image

updated 2011-04-12 07:30:11 -0500

benjaminfjones gravatar image

y = x /. NSolve[LegendreP[i, x] == 0, x]; z = (2 (1 - y^2))/((i + 1)^2 LegendreP[i + 1, y]^2);

and

NumberForm[N[!( *SubsuperscriptBox[([Integral]), (-1), (1)](f[ x] [DifferentialD]x))], 12]

Edit: I think the OP means $$\int_{-1}^1 f(x)\;dx$$

Please help me translate this into SAGE. Thank You!!

edit retag flag offensive close merge delete

Comments

For those of us who don't know Mathematica syntax, could you also explain what you're trying to do in words?

John Palmieri gravatar imageJohn Palmieri ( 2011-04-02 12:09:48 -0500 )edit

Can you rewrite your Mathematica code in InputForm so that it can be easily read and copied? That said, the code that you've posted does not seem to do anything. Can you post a working example?

Simon gravatar imageSimon ( 2011-04-02 13:10:40 -0500 )edit

@Sagud: Posting Mma Box structure is no good. It is basically unreadable. In Mma, select the text you want to copy, right click and go "Copy As > Input Text". You can edit your post and paste in the code using a code markup. Make it readable and people might be more inclined to help.

Simon gravatar imageSimon ( 2011-04-03 16:05:21 -0500 )edit

Incidentally, you can edit your original post and put it there!

kcrisman gravatar imagekcrisman ( 2011-04-04 04:58:15 -0500 )edit

Somehow the original question has become mangled. All I see is the integral of f(x) from -1 to 1.

benjaminfjones gravatar imagebenjaminfjones ( 2011-04-06 11:38:16 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2011-04-02 16:23:28 -0500

kcrisman gravatar image

updated 2011-04-02 16:34:38 -0500

There is no direct equivalent in Sage to this, but I'll try to give a few ideas for how to do what you want.

Most directly, this will help:

sage: solve(legendre_P(9,x),x)[0].rhs().n()
-0.968160239507626 + 2.33721339925049e-18*I
sage: solve(legendre_P(9,x),x)[0].rhs().n(prec=100)    
-0.96816023950762608983557620291 + 2.7752069983964298759432951970e-32*I

Assuming that's right. solve only gives symbolic solutions in this case, so we get at the numerical approximation this way; for high-accuracy numerical solutions immediately, use find_root.

sage: find_root(legendre_P(9,x),-1,-.9)
-0.96816023950880892

Unfortunately, I have to do legendre_P(9,x) and not

sage: j = var('j')
sage: F = legendre_P(j,x)

because we do not have it wrapped in a way that allows that, though presumably we could do so. Our special and other functions can use upgrading from that standpoint. In Maxima one might be able to do that directly, though.

Finally, if your last question is asking how to numerically approximate integrals, there are lots of good ways to do this. If you have a symbolic integral with endpoints, using .n() should work to approximate it; a function worth checking out is numerical_integral.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-04-02 11:37:46 -0500

Seen: 242 times

Last updated: Apr 12 '11