Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
2.75/5 (4 votes)
See more:
Im not really sure about that is it same pattern i wrote in c# as in this image?
code:
C#
-Math.Cos(x1) * Math.Cos(x2) * Math.Pow(Math.E, Math.Pow(-(x1 - Math.PI), 2) - Math.Pow((x2 - Math.PI),2));


Right pattern:
http://s18.postimage.org/btxjslcaf/wzor.png[^]

Thank u you for help
Posted
Updated 13-May-12 18:50pm
v2

1 solution

Acutally made error in putting the "-" inside the Math.Pow(-(x1 - Math.PI), 2), and the approach is not the best. I would also not use the Pow for square because of perfomance, and would use the Exp function:

v
ar VALUE = - Math.Cos(x1) * Math.Cos(x2) * Math.Exp(-(x1 -nu) *(x1 - Math.PI) -(x2 -nu) * (x2 -Math.PI));
 
Share this answer
 
v2
Comments
Maciej Los 13-May-12 11:59am    
Does the pattern (from image) is: cos(x1)*cos(x2)-(((-x1-Pi)^2)-(-x2-Pi)^2))
VJ Reddy 13-May-12 12:15pm    
Good answer. 5!
Clifford Nelson 13-May-12 12:16pm    
You missed a piece of the equation:
-cos(x1)*cos(x2)(e ^(-(x1-Pi)^2)-(x2-Pi)^2))
Maciej Los 13-May-12 12:34pm    
I'm a blind man ;)
Of course, 5!
Shahin Khorshidnia 14-May-12 0:49am    
"Acutally made error in putting the - inside the Math.Pow(-(x1 - Math.PI), 2), and the approach is not the best."... What kind of error?!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900