Comp Sci Help with FORTRAN error message

  • Thread starter Thread starter Daniel1992
  • Start date Start date
  • Tags Tags
    Error Fortran
AI Thread Summary
The FORTRAN error message indicates an invalid character in the expression, specifically related to the use of the exponentiation operator. The correct operator for exponentiation in FORTRAN is '**', not '^'. Additionally, constants like Pi and e must be defined elsewhere in the program for proper use. The user acknowledged the mistake and expressed gratitude for the clarification. Understanding these syntax rules is essential for successful coding in FORTRAN.
Daniel1992
Messages
21
Reaction score
0

Homework Statement



I get the follwing error message in the FORTRAN program I am trying to code.

P(i)=(1/(sigma*sqrt(2*Pi)))*e^(-(x-xbar)^2/(2*sigma^2))
----------------------------1
Error: Invalid character in name at (1)

I assume this means there is something it doesn't like about 2*Pi but I can't work out what it is.

Any help would be appreciated.
 
Physics news on Phys.org
1 Pi should be defined elsewhere in your program, as should the constant e.
2. the character ^ is not used for exponentiation. The double * is the proper operator, thus x*x = x**2.
 
Well that was abvious :rolleyes:

forgot that '**' is used to creates powers.

Thanks for that :)
 
Back
Top