Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7731855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:35:06+00:00 2026-06-01T06:35:06+00:00

I tried to write a Taylor series expansion for exp(x)/sin(x) using fortran, but when

  • 0

I tried to write a Taylor series expansion for exp(x)/sin(x) using fortran, but when I tested my implementatin for small numbers(N=3 and X=1.0) and add them manually, the results are not matching what I expect. On by hand I calculated 4.444.., and with the program I found 7.54113. Could you please check my code and tell me if i got anything wrong.

Here is the expansion formula for e^x/sin(x) in wolframalpha: http://www.wolframalpha.com/input/?i=e%5Ex%2Fsin%28x%29

 PROGRAM Taylor
 IMPLICIT NONE


 INTEGER ::Count1,Count2,N=3
 REAL:: X=1.0,Sum=0.0
 COMPLEX ::i=(0.0,0.1)
 INTEGER:: FACT

  DO Count1=1,N,1
    DO Count2=0,N,1
       Sum=Sum+EXP(i*X*(-1+2*Count1))*(X**Count2)/FACT(Count2)
    END DO

 END DO

 PRINT*,Sum

 END PROGRAM Taylor  

 INTEGER FUNCTION FACT(n)
   IMPLICIT NONE
   INTEGER, INTENT(IN) :: n
   INTEGER :: i, Ans
   Ans = 1
   DO i = 1, n
     Ans = Ans * i
   END DO
   FACT = Ans
END FUNCTION FACT
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:35:07+00:00Added an answer on June 1, 2026 at 6:35 am

    The Wolfram article has the expansion formula stated using q = e**(ix) so there is a complex term. Therefore “sum” should be declared complex.

    As already stated, the factorial function is simplistic. Be careful of overflow.

    It is best to place your procedures into a module and “use” that module from the main program. Use as many compiler debugging options as possible. For example, gfortran, when the appropriate warning option is used, warns about the type of “sum”: “Warning: Possible change of value in conversion from COMPLEX(4) to REAL(4)”. If you are using gfortran try: -O2 -fimplicit-none -Wall -Wline-truncation -Wcharacter-truncation -Wsurprising -Waliasing -Wimplicit-interface -Wunused-parameter -fwhole-file -fcheck=all -std=f2008 -pedantic -fbacktrace

    Since you can do this problem by hand, try outputting each step with a write statement and comparing to your hand calculation. You will probably quickly see where the calculation diverges. If it isn’t clear why the calculation is different, break it down into pieces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to write code using strrev() . I included <string.h> but still I'm
I tried to write a Neural Network system, but even running through simple AND/OR/NOR
I tried to write a program that uses threads, but couldn't understand the o/p.
I have tried to write a basic merge sort in PHP involving a small
I tried to write a simple google map application to display simple map but
When i tried to write a daemon under linux using C, i was told
I have recently tried to write an application in c# using EWS to read
I tried to write an ant with JUnit test, but get below result: unittest:
I tried to write the following inner join query using an Oracle database: SELECT
I tried to write an YUV422 to RGB24 converter, but the result of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.