# Translation

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$$

edit retag close merge delete

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

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?

@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.

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

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

Sort by » oldest newest most voted

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).rhs().n()
-0.968160239507626 + 2.33721339925049e-18*I
sage: solve(legendre_P(9,x),x).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.

more