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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:42:55+00:00 2026-05-22T17:42:55+00:00

here is my formula: y = b*exp(-((x-c)^2)/2(d^2)) if x < c, else y =

  • 0

here is my formula:

y = b*exp(-((x-c)^2)/2(d^2)) if x < c, else y = b*exp(-(x-c)^2/2g^2);

this is how i coded it:

        for (double x = 0; x <= 7D; x += .01D)
        {
            b = 6.0410638; c = 2.1344769; d = 0.59183047; g = 0.77384504;
            if (x < c)
                y = b * Math.Exp(-Math.Pow((x - c), 2)) / (2 * Math.Pow(d, 2D));
            else
                y = b * Math.Exp(-Math.Pow((x - c), 2)) / (2 * Math.Pow(g, 2D));
            qResults.Rows.Add(x, y);
        }

the output:

    0.0529826172
0.05528786
0.05768187
0.0601675063
0.0627477
0.06542546
0.06820385
0.07108601
0.074075155
0.0771745443
0.08038754
0.08371756
0.08716809
0.0907426849
0.0944449753
0.0982786641
0.102247514
0.106355369
0.110606134
0.115003787
0.119552381
0.124256022
0.1291189
0.13414526
0.139339417
0.144705743
0.150248691
0.155972764
0.16188252
0.167982608
0.1742777
0.180772528
0.187471911
0.1943807
0.201503783
0.2088461
0.2164127
0.224208578
0.232238829
0.2405086
0.24902302
0.257787317
0.2668067

is there a problem with my syntax?

the output should be:

0.009332048
0.009915393
0.010532198
0.011184179
0.011873133
0.012600931
0.013369526
0.014180954
0.015037339
0.015940891
0.016893914
0.017898806
0.01895806
0.020074273
0.021250142
0.022488471
0.023792173
0.025164271
0.026607905
0.028126332
0.029722928
0.031401194
0.033164757
0.035017372
0.036962928
0.039005447
0.041149089
0.043398156
0.045757092
0.048230485
0.050823073
0.053539744
0.05638554
0.059365657
0.062485449
0.065750429
0.069166271
0.072738815
0.076474061
0.08037818
0.084457508
0.088718551
0.093167983
0.097812651
0.102659571
0.107715931
0.112989091
0.118486582
0.124216105
0.130185532
0.136402905
0.142876432
0.149614489
0.156625615
0.163918513
0.171502045
0.17938523
0.187577239
0.196087395
0.204925165
0.21410016
0.223622125
0.233500937
0.2437466
0.254369235
0.265379079
0.276786473
0.288601856
0.30083576
0.313498797
0.326601652
0.340155077
0.354169874
0.368656891
0.383627009
0.39909113
0.415060167
0.431545027
0.448556606
0.466105768
0.484203337
0.502860078
0.522086688
0.541893773
0.562291841
0.583291279
0.604902341
0.627135126
0.649999569
0.673505413
0.697662199
0.722479244
0.747965622
0.774130146
0.800981347
0.828527458
0.856776387
0.885735705
0.915412619
0.945813957
0.976946142
1.008815173
1.041426608
1.074785537
1.108896564
1.143763787
1.179390775
1.21578055
  • 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-22T17:42:57+00:00Added an answer on May 22, 2026 at 5:42 pm

    Based on your formula, the code should be:

        for (double x = 0; x <= 7D; x += .01D)
        {
            b = 6.0410638; c = 2.1344769; d = 0.59183047; g = 0.77384504;
            if (x < c)
                y = b * Math.Exp(-Math.Pow(x - c, 2) / (2 * Math.Pow(d, 2D)));
            else
                y = b * Math.Exp(-Math.Pow(x - c, 2) / (2 * Math.Pow(g, 2D)));
            qResults.Rows.Add(x, y);
        }
    

    Basically, the Math.Exp function should be applied to the result of the division, not just to the result of -Math.Pow(x - c, 2)

    Also, it’s not very clear based on the formula and your code example whether you need to divide by 2 in the exponent computation, then multiply the result by d^2, or actually divide by 2 * d^2 as you are doing in the implementation.

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

Sidebar

Related Questions

I am creating a string that is a formula. Like in here (this is
This polygon could be shaped like a C I tried the formula located here
Here's a coding problem for those that like this kind of thing. Let's see
I have a standard formula for calculating loan amortization schedule. Here is the formula:
I'm working on converting a mathematical formula into a program. This formula is called
What's the rationale behind the formula used in the hive_trend_mapper.py program of this Hadoop
I don't even know if this question belongs here or to another StackExchange site,
This is quite difficult to explain so I have attached an excel file here:
Basic question here, just got curious about coding a simple formula out, and wanted
This questions concerns the use of the formula field in a static mapping block

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.