15,917,652 members
1.00/5 (1 vote)
See more:
Hello everyone, I am a complete novice to programming. I am facing a big trouble writing a programming for a fixed point iteration given

FORTRAN
```P= g(Po)
g(x) = x-sin (pi.x), pi as in 22/7.
Po = 0.95
TOL = 10**-6
NO = 20
TOL if (Pi-Po)<=10**-6

Steps
1. Set i=1
2. While i <No,  do step 3-6
3. Set P=g(Po)
4. Test if |P-Po| < TOL
OUTPUT (P); (Procedure completed successfully )
STOP
5. Set i = i+1
6. Set P = Po
7 output (method failed after no iteration)
"NO", NO; (Procedure completed Successfully)
STOP```

SIMPLY FORTRAN is the FORTRAN software I was able to download. Please how can I
Write the algorithm for the above problem. Thank you

What I have tried:

I've tried using Video tutorials but nothing seems to be working. SIMPLY FORTRAN is the name of the software I was able to download, tried downloading FORTRAN 90, or 77 but nothing. Please If you have such software and willing to share with me. Please I'd be very glad.
Posted
Updated 8-Feb-18 10:39am
v2
Comments
OriginalGriff 9-Feb-18 3:36am
If you are a complete novice to computing, why are you trying to start with FORTRAN? It's a very old language, and is largely dead in the "real world" (though there are some die hard physicists using it I understand).
Starting with a "legacy code" language as your first is not a good idea!

Have you considered starting with a more modern, cleaner language like C#? The support tools are brilliant, and the educational resources are massive and generally available.
Abdullahi Ibrahim 10-Feb-18 6:46am
Thank you for your response but I have not tried C#, The instruction stated that either QBASIC or FORTRAN be used. I have a short time. It's an assignment that needs to be submitted before deadline 13/02/17, and I have 3 of it. HELP!!!
Abdullahi Ibrahim 10-Feb-18 8:29am
Well, Asking for help doesn't imply asking anyone to help me get my assignment done. I've watched over 10 videos, all came with different procedures tried them but none worked, all the Algorithm I've written were reading error. About my course material, it was discussing Fixed point iteration when it jumped to using computer programs to evaluate equations and the professor gave it out as an assignment, so there was nothing like "Hello World". I believe this platform is meant to provide guidance, so, I believe a programmer in the house can write a program to evaluate an equation (preferably equation that involves using Newton Raphson Method) like what I have in my assignment, then I can follow his step by step procedure in doing my assignments. Thanks 🙏🏾
OriginalGriff 10-Feb-18 8:34am
"I believe a programmer in the house can write a program to evaluate an equation (preferably equation that involves using Newton Raphson Method) like what I have in my assignment, then I can follow his step by step procedure in doing my assignments."
And there is the problem: we aren't here to do your homework. If your professor hasn't taught you what you need to know, then go talk to him and find out what is going on. But don't expect any site to be willing to give you a passing grade without you actually doing the work!
Abdullahi Ibrahim 10-Feb-18 9:55am
this is what i have done using SIMPLY FORTRAN, and its failing, guide me, Thanks

!Program for Fixed-Point Algorithm
!Program Fixed-Point_Algorithm

P = p0 - sine(pi*p0)
implicit none
integer :: p, g, p0, pi, TOL, NO, i

p0 = 0.95
pi = 4*ATN(1.0)
NO = 20
TOL = 10**-6
TOL if (p-p0) <= 10**-6

while i < NO
set p = p0-sin (pi*p0),
if (p-p0) < TOL
OUTPUT(p)
PRINT *, p write(*,*) "Procedure completed succesfully"

else set i = i+1
P=p0
output (p) write(*,*) "method failed after No Iterations"
"NO= ", NO; write(*,*) "Procedure completed successfully"

Program stop Fixed-Point_Algorithm

## Solution 2

Well, i later talked to guys from another site and they recommended i stop using simply Fortran and try QB64, watched videos on it and behold, i became a victor. Here is the solution Using QBasic. ENJOY!

```CLS
i = 1: po = 0.95: tol = 10 ^ -6: no = 20: CONST pi = 4 * ATN1
PRINT , , " "; "COURSE CODE ASSIGNMENT"
PRINT , "       "; "By CANDIDATE NAME"
PRINT "i", "po", "p", "ABS(p-po)"
2 IF i < no THEN
p = po - SIN(pi * po)
PRINT i,
PRINT po,
PRINT p,
PRINT ABS(p - po)
IF ABS(p - po) < tol THEN
PRINT (p); "Procedure completed successfully"
END IF
i = i + 1: po = p
GOTO 2
ELSE
PRINT "method failed after 20 iterations*"
END IF```

Comments
Maciej Los 14-Feb-18 2:24am
Congrats! You solved your own problem. Now, you should accept your answer as a solution to remove your question from unanswered list (use green button).
5!
Richard Deeming 15-Feb-18 14:23pm
So you've moved from a language that's been mostly dead for 40+ years to a language that's been mostly dead for 20+ years? :)

If you want to use a modern language which is still supported, look at .NET, .NET Core, or Java.

On Windows, Visual Studio Community edition[^] is free for open-source developers and small companies.

Or, if you want a cross-platform solution, Visual Studio Code[^] is pretty good.

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

Top Experts
Last 24hrsThis month
 CPallini 50 OriginalGriff 35 Rick York 30 Ștefan-Mihai MOGA 30 Dave Kreskowiak 25
 Pete O'Hanlon 700 OriginalGriff 483 Dave Kreskowiak 405 Richard MacCutchan 310 merano99 235

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