I am very much confused and frustrated at this point and would just like to understand what I'm doing wrong... This program is supposed to calculate a truncated value of sine using it's series expansion beginning at i = 1. At values under 20 degrees it compares almost exactly with the intrinsic sine function, but after that it's as much as .06-.23 off! This is my first course in programming in general, and I've been very good at Fortran thus far, but there's something I'm missing in this case... This is the program I have been trying to fix:(adsbygoogle = window.adsbygoogle || []).push({});

program series

implicit none

real :: n_factorial, sin_x, x, v1, sum_1, n_1

integer :: n, i

write (*,*) 'enter n'

read (*,*) n

write (*,*) 'enter x in degrees'

read (*,*) x

n_factorial = 1

sin_x = 0

x = ((x*3.1415926535898)/180)

v1 = sin(x)

DO i = 1, n

n_1 = (2*i) - 1

n_factorial = n_factorial * n_1

sum_1 = (((-1)**(i-1)) * ((x**((2*i) - 1))/(n_factorial)))

sin_x = sin_x + sum_1

END DO

write (*,*) sin_x

write (*,*) ' '

write (*,*) v1

end program series

This is my first time posting on this site, and posting in general, I would infinitely appreciate the help in figuring out what's wrong!

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Truncated Sin Series in FORTRAN

**Physics Forums | Science Articles, Homework Help, Discussion**