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

  • Home
  • SEARCH
  • 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 7959807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:37:52+00:00 2026-06-04T04:37:52+00:00

For example if I was defining the following function exprod[n_] := Expand[Product[x + i,

  • 0

For example if I was defining the following function

exprod[n_] := Expand[Product[x + i, {i, 1, n}]]

Then why is the underscore after the variable n, necessary in the function definition? Where does this style come from or is it specific only to the Mathematica programming language?

  • 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-06-04T04:37:53+00:00Added an answer on June 4, 2026 at 4:37 am

    The underscore comes from pattern matching.

    The x_ matches anything and this anything is bound to the name x in the body of the function.

    l[x_ * y_] := l[x] + l[y];
    

    Then in l[2*z] first the expression 2*z is matched against the
    pattern x_ * y_ . Then x is bound to 2 and y is bound to z.
    Then the expression l[x] + l[y] is evaluated, and the result becomes
    l[2]+l[z].

    Now say we want to define the value of l on e to be 1.
    Do we write l[e] := 1 or l[e_] := 1?

    One says that l to (literally) the variable e must be 1.
    The other says that l to something gives 1.

    http://reference.wolfram.com/mathematica/tutorial/Introduction-Patterns.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following XML example we could imagine a schema defining Root as containing
ORIGINAL POST: I'm probably defining my route incorrectly but I'm following along with this
What is a simple example of decorating a class by defining the decorator as
I've a WSDL defining a web service named CalendarService : <soap:address location=http://example.com/calendar/> The WSDL
Example: I have a selector like this, which I give to another method as
Example: public bool Save(MyObj instance) { if (instance.IsNew) { this.repository.Create(instance); } else { this.repository.Update(instance);
I'm following the W3Schools tutorial on AJAX, and it provides an example of using
I currently have the following javascript code (loosely modeled after how a similar objective
I am defining monday and friday using the following: @monday = Date.today.at_beginning_of_week @friday =
The following is a snippet from a xaml defining a DataGrid in a Control,

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.