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 817459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:59:51+00:00 2026-05-15T01:59:51+00:00

I am developing functional domain specific embedded language within C++ to translate formulas into

  • 0

I am developing functional domain specific embedded language within C++ to translate formulas into working code as concisely and accurately as possible.

I posted a prototype in the comments, it is about two hundred lines long.

Right now my language looks something like this (well, actually is going to look like):

// implies two nested loops j=0:N, i=0,j
(range(i) < j < N)[T(i,j) = (T(i,j) - T(j,i))/e(i+j)];

// implies summation over above expression
sum(range(i) < j < N))[(T(i,j) - T(j,i))/e(i+j)];

I am looking for possible syntax improvements/extensions or just different ideas about expressing mathematical formulas as clearly and precisely as possible (in any language, not just C++).

Can you give me some syntax examples relating to my question which can be accomplished in your language of choice which consider useful. In particular, if you have some ideas about how to translate the above code segments, I would be happy to hear them.

Thank you.

Just to clarify and give an actual formula, my short-term goal is to express the following

alt textalt text

expression concisely where values in <> are already computed as 4-dimensional arrays.

  • 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-15T01:59:52+00:00Added an answer on May 15, 2026 at 1:59 am

    If you’re going to be writing this for the ab-initio world (which I’m guessing from your MP2 equation) you want to make it very easy and clear to express things as close to the mathematical definition that you can.

    For one, I wouldn’t have the complicated range function. Have it define a loop, but if you want nested loops, specify them both:

    So instead of

    (range(i) < j < N)[T(i,j) = (T(i,j) - T(j,i))/e(i+j)];

    use

    loop(j,0,N)[loop(i,0,j)[T(i,j) = (T(i,j) - T(j,i))/e(i+j)]]

    And for things like sum and product, make the syntax “inherit” from the fact that it’s a loop.

    So instead of

    sum(range(i) < j < N))[(T(i,j) - T(j,i))/e(i+j)];

    use

    sum(j,0,n)[loop(i,0,j)[(T(i,j) - T(j,i))/e(i+j)]]

    or if you need a double sum

    sum(j,0,n)[sum(i,0,j)[(T(i,j) - T(j,i))/e(i+j)]]

    Since it looks like you’re trying to represent quantum mechanical operators, then try to make your language constructs match the operator on a 1-1 basis as closely as possible. That way it’s easy to translate (and clear about what’s being translated).

    EDITED TO ADD

    since you’re doing quantum chemistry, then it’s fairly easy (at least as syntax goes). You define operators that always work on what’s to the right of them and then the only other thing you need are parenthesis to group where an operator stops.

    Einstein notation is fun where you don’t specify the indices or bounds and they’re implied because of convention, however that doesn’t make clear code and it’s harder to think about.

    For sums, even if the bounds implied, they’re always easy to figure out based on the context, so you should always make people specify them.

    sum(i,0,n)sum(j,0,i)sum(a,-j,j)sum(b,-i,i)….

    Since each operator works to the right, its variables are known, so j can know about i, a can know about i and j and b can know about i,j, and a.

    From my experience with quantum chemists (I am one too!) they don’t like complicated syntax that differs much from what they write. They are happy to separate double and triple sums and integrals into a collection of singles because those are just shorthand anyway.

    Symmetry isn’t going to be that hard either. It’s just a collection of swaps and adds or multiplies. I’d do something where you specify the operation which contains a list of the elements that are the same and can be swapped:

    c2v(sigma_x,a,b)a+b

    This says that a and b are can be considered identical particles under a c2v operation. That means that any equation with a and b (such as the a+b after it) should be transformed into a linear combination of the c2v transformations. the sigma_x is the operation in c2v that you want applied to your function, (a+b). If I remember correctly, that’s 1/sqrt(2)((a+b)+(b+a)). But I don’t have my symmetry book here, so that could be wrong.

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

Sidebar

Ask A Question

Stats

  • Questions 470k
  • Answers 470k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer (Adding a second answer because it's on a completely different… May 16, 2026 at 2:57 am
  • Editorial Team
    Editorial Team added an answer Usual approach for handling HTTP requests synchronously is to spawn… May 16, 2026 at 2:57 am
  • Editorial Team
    Editorial Team added an answer Because the user's day may not start and end at… May 16, 2026 at 2:57 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.