Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran and Matlab operator priorities

Status
Not open for further replies.

xrayspex1

Technical User
Jun 10, 2008
9
SI
i've been comparing 4th order Runge-Kutta method i wrote in F90 and in Matlab R2006 and stumbled upon a bizzare thing: is it possible that the two programs have different arithmetic operator priorities????

look at the attached picture: if i use parenthesis to specify the computation order explicitly, then both solutions (rk4 in F90 and in Matlab) coincide(more or less).

but if i remove the parenthesis, Fortran solution stays the same, but Matlab understands the problem in a completely different way:

the code f = 0.1 * t ^ 3 ^ sin(y^2) is understood like this:

Matlab: f = 0.1 * (t ^ 3) ^ sin(y^2)
F90: f = 0.1 * t ^ (3 ^ sin(y^2))

should i be surprised?

F90vsM.png
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top