enter image description here

when solving the equation, it displays the wrong answer: 2.9848, but should be: 1.9873 The following is the code:

Double x = 0.4 * Math.Pow(10.0, 4); Double y = -0.875; Double z = -0.475 * Math.Pow(10.0, -3); Double stepen = 1 + 2 * Math.Pow(Math.Sin(y), 2); Double cosinus = Math.Abs(Math.Cos(x) - Math.Cos(y)); Double vozvedenie_v_stepen = cosinus * stepen; Double Z = 1 + z + (Math.Pow(z, 2)/2) + (Math.Pow(z, 3)/3) + (Math.Pow(z, 4)/4); Double full_formula = vozvedenie_v_stepen * Z; Console.WriteLine(Math.Round(full_formula, 4)); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); 

Where did I incorrectly decide?

Closed due to the fact that off-topic participants Anton Shchyrov , AseN , Kromster , user194374, pavel December 31, '16 at 11:48 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Anton Shchyrov, Kromster, Community spirit, pavel
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Unfortunately, they did not teach me at the university. I am learning to program myself. - GhostBasenji
  • that's good, programming without debugging does not happen, success to you in the coming year. - Bulson
  • 3
    @Bulson does not need to go down to beginners. In this question, it is clear that the person made efforts trying to solve the problem. And if you know something that the novice doesn’t know, then it’s best to calmly share, otherwise the usefulness of this comment is zero. - Vadim Ovchinnikov
  • @Bulson, sorry for causing your displeasure, and the fact that I caused you to be criticized by other members of the community. I just did not pay attention to the debugging of the type "Set breakpoints, run in steps, watch the values ​​of local variables." After your comments I will look more attentively. - GhostBasenji
  • 2
    @Bulson I, for example, clean self-taught, and no one taught how to debug. I learned a lot about C #, but I learned how to debug when I got a second job. Before this, Console.WriteLine debugged :) - Vadim Ovchinnikov

1 answer 1

Instead

Double vozvedenie_v_stepen = cosinus * stepen;

Must be

 Double vozvedenie_v_stepen = Math.Pow(cosinus, stepen);