Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6901155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:38:15+00:00 2026-05-27T07:38:15+00:00

I am trying to quickly solve the following problem: f[r_] := Sum[(((-1)^n (2 r

  • 0

I am trying to quickly solve the following problem:

f[r_] := Sum[(((-1)^n (2 r - 2 n - 7)!!)/(2^n n! (r - 2 n - 1)!))
             * x^(r - 2*n - 1), 
         {n, 0, r/2}]; 

Nw := Transpose[Table[f[j], {i, 1}, {j, 5, 200, 1}]]; 

X1 = Integrate[Nw . Transpose[Nw], {x, -1, 1}]

I can get the answer quickly with this code:

$starttime = AbsoluteTime[]; Quiet[LaunchKernels[]]; 
DIM = 50; 
Print["$Version = ", $Version, "  |||  ", 
      "Number of Kernels : ", Length[Kernels[]]]; 

Nw = Transpose[Table[f[j], {i, 1}, {j, 5, DIM, 1}]]; 
nw2 = Nw.Transpose[Nw]; 
Round[First[AbsoluteTiming[nw3 = ParallelMap[Expand, nw2]; ]]] 

intrule = (pol_Plus)?(PolynomialQ[#1, x]&) :> 
      (Select[pol, !FreeQ[#1, x] & ] /. 
         x^(n_.) /; n > -1 :> ((-1)^n + 1)/(n + 1)) + 2*(pol /. x -> 0)]); 

Round[First[AbsoluteTiming[X1 = ParallelTable[row /. intrule, {row, nw3}]; ]]]

X1 
Print["overall time needed in seconds: ", Round[AbsoluteTime[] - $starttime]]; 

But how can I manage this code if I need to solve the following problem, where a and b are known constants?

       X1 = a Integrate[Nw.Transpose[Nw], {x, -1, 0.235}]
          + b Integrate[Nw.Transpose[Nw], {x,  0.235,1}]; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:38:16+00:00Added an answer on May 27, 2026 at 7:38 am

    Here’s a simple function to do definite integrals of polynomials

    polyIntegrate[expr_List, {x_, x0_, x1_}] := polyIntegrate[#, {x, x0, x1}]&/@expr
    polyIntegrate[expr_, {x_, x0_, x1_}] := Check[Total[# 
      Table[(x1^(1 + n) - x0^(1 + n))/(1 + n), {n, 0, Length[#] - 1}]
      ]&[CoefficientList[expr, x]], $Failed, {General::poly}]
    

    On its range of applicability, this is about 100 times faster than using Integrate. This should be fast enough for your problem. If not, then it could be parallelized.

    f[r_] := Sum[(((-1)^n*(2*r - 2*n - 7)!!)/(2^n*n!*(r - 2*n - 1)!))*
       x^(r - 2*n - 1), {n, 0, r/2}];
    Nw = Transpose[Table[f[j], {i, 1}, {j, 5, 50, 1}]];
    
    a*polyIntegrate[Nw.Transpose[Nw], {x, -1, 0.235}] + 
       b*polyIntegrate[Nw.Transpose[Nw], {x, 0.235, 1}] // Timing // Short
    
    (* Returns: {7.9405,{{0.0097638 a+0.00293462 b,<<44>>,
                 -0.0000123978 a+0.0000123978 b},<<44>>,{<<1>>}}} *)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a shortcut for mvn test so I can quickly get
I am currently trying to solve this problem in MySQL. I have MySQLdb installed.
Trying to get my css / C# functions to look like this: body {
What I'm trying to do is create a class that I can quickly attach
I won't go into the details of the problem I'm trying to solve, but
I was trying to just quickly integrate the Windows Media Player via COM to
In SQL Server 2008, I'm trying to quickly get a row count on a
Based on this question which was closed rather quickly: Trying to create a program
EDIT Here is the problem I am trying to solve: I have a string
I'm trying to quickly get a buggy .Net client library for a third party

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.