Search
 
 
  Engleski
 
 
 
Open in this window (click to change)
Forum@DeGiorgi: Početna
Forum za podršku nastavi na PMF-MO
Login Registracija FAQ Smajlići Članstvo Pretražnik Forum@DeGiorgi: Početna

iz Fortrana u Wolfram Mathematicu

Moja sarma
 
Započnite novu temu   Odgovorite na temu   printer-friendly view    Forum@DeGiorgi: Početna -> Ostalo - ozbiljno -> Matematika (općenito)
Prethodna tema :: Sljedeća tema  
Autor/ica Poruka
quo
Forumaš(ica)
Forumaš(ica)


Pridružen/a: 11. 03. 2004. (01:32:52)
Postovi: (8)16
Sarma = la pohva - posuda
= 0 - 0
Lokacija: NZ

PostPostano: 20:38 sri, 19. 1. 2005    Naslov: iz Fortrana u Wolfram Mathematicu Citirajte i odgovorite

Moli bi vas matematičare s PMF-a (ok, ne morate baš biti sa PMF-a :D ) da mi pomognu portati sljedeći kod koji je u Fortranu u Wolfram Mathematicu. Jako bih vam bio zahvalan kad bi to mogli napraviti što prije.

Hvala.

Sljedi kod:

INTEGER i, j, n, nmax, choice, index
REAL*8x
REAL*8a(0 : 20), f(0 : 20), fs(0 : 20), fn(0 : 20), root(20)
REAL*8m(20, 20)

Open(1, file = 'algoritam.out')

Do 100 i = 1, 24
100 Print*
nmax = 20
i = 1
m(i, i) = 0
Do 110 i = 2, nmax
m(i, 1) = i * (i - 1) / 2
Do 120 j = 2, i
m(i, j) = m(i - 1, j - 1) * (i - j) + m(i - 1, j)
120 Continue
110 Continue

115 Index = 0

Write (*, 101)
101 Format (/5x, 'power N: ', $)
Read (*, *)n
Write(*, 102)
102 Format (/5x, 'coefficients: '/)
Do 140 i = n, 0, -1
Write (*, 103)i
103 Format (5x, 'a(', i2, ') = ', $)
Read (*, *)a(i)
140 Continue

f(n) = a(0)
Do 150 i = 1, n - 1
f(i) = a(n - i)
Do 150 j = 0, i - 1
f(i) = f(i) + m(n - j, i - j) * a(n - j)
150 Continue

Index = 0
fn(1) = f(1) - n
fs(1) = fn(1)
Do 170 i = 2, n
fn(i) = -(n - i + 1) * fn(i - 1) + f(i)
fs(i) = fn(i)
170 Continue

x = -1
125 x = x + 1

fn(1) = fs(1) + n
if(n.le.1) goto 135
Do 170 i = 2, n
fn(i) = (n - i + 1) * fs(i - 1) + fs(i)
170 Continue
135 Continue

Do 180 i = 1, n
fs(i) = fn(i)
180 Continue

If(fs(n).eq.0) then
index = index + 1
root(index) = x
Write (*, 104)index, root(index)
Write (1, 104)index, root(index)
104 Format(5x, 'Solution (', i2, ')', 5x, f10.0)
n = n - 1

If(n.eq.0) goto 155
fn(1) = fs(1) - n
If(n.le.1) goto 135
Do 210 i = 2, n
fn(i) = -(n - i + 1) * fn(i - 1) + fs(i)
210 Continue
Goto 135
endif

If (n.eq.0) goto 155
Do 220 i = 1, n
If (fn(i).lt.0) goto 145
220 Continue
Goto 155
145 Continue
Do 230 i = 1, n
fs(i) = fn(i)
230 Continue
Goto 325
195 Write (*, 108)
108 Format (//5x, 'Continue? (YES - 1, NO - 2) ', $)
Read (*, *)choice
If(choice.eq.1) goto 115

205 Continue
End

još jednom fala unaprijed :roll:

e da, jedno pitanje za sve vas ...
šta radi taj algoritam i po kojoj teoriji :)
Moli bi vas matematičare s PMF-a (ok, ne morate baš biti sa PMF-a Very Happy ) da mi pomognu portati sljedeći kod koji je u Fortranu u Wolfram Mathematicu. Jako bih vam bio zahvalan kad bi to mogli napraviti što prije.

Hvala.

Sljedi kod:

INTEGER i, j, n, nmax, choice, index
REAL*8x
REAL*8a(0 : 20), f(0 : 20), fs(0 : 20), fn(0 : 20), root(20)
REAL*8m(20, 20)

Open(1, file = 'algoritam.out')

Do 100 i = 1, 24
100 Print*
nmax = 20
i = 1
m(i, i) = 0
Do 110 i = 2, nmax
m(i, 1) = i * (i - 1) / 2
Do 120 j = 2, i
m(i, j) = m(i - 1, j - 1) * (i - j) + m(i - 1, j)
120 Continue
110 Continue

115 Index = 0

Write (*, 101)
101 Format (/5x, 'power N: ', $)
Read (*, *)n
Write(*, 102)
102 Format (/5x, 'coefficients: '/)
Do 140 i = n, 0, -1
Write (*, 103)i
103 Format (5x, 'a(', i2, ') = ', $)
Read (*, *)a(i)
140 Continue

f(n) = a(0)
Do 150 i = 1, n - 1
f(i) = a(n - i)
Do 150 j = 0, i - 1
f(i) = f(i) + m(n - j, i - j) * a(n - j)
150 Continue

Index = 0
fn(1) = f(1) - n
fs(1) = fn(1)
Do 170 i = 2, n
fn(i) = -(n - i + 1) * fn(i - 1) + f(i)
fs(i) = fn(i)
170 Continue

x = -1
125 x = x + 1

fn(1) = fs(1) + n
if(n.le.1) goto 135
Do 170 i = 2, n
fn(i) = (n - i + 1) * fs(i - 1) + fs(i)
170 Continue
135 Continue

Do 180 i = 1, n
fs(i) = fn(i)
180 Continue

If(fs(n).eq.0) then
index = index + 1
root(index) = x
Write (*, 104)index, root(index)
Write (1, 104)index, root(index)
104 Format(5x, 'Solution (', i2, ')', 5x, f10.0)
n = n - 1

If(n.eq.0) goto 155
fn(1) = fs(1) - n
If(n.le.1) goto 135
Do 210 i = 2, n
fn(i) = -(n - i + 1) * fn(i - 1) + fs(i)
210 Continue
Goto 135
endif

If (n.eq.0) goto 155
Do 220 i = 1, n
If (fn(i).lt.0) goto 145
220 Continue
Goto 155
145 Continue
Do 230 i = 1, n
fs(i) = fn(i)
230 Continue
Goto 325
195 Write (*, 108)
108 Format (//5x, 'Continue? (YES - 1, NO - 2) ', $)
Read (*, *)choice
If(choice.eq.1) goto 115

205 Continue
End

još jednom fala unaprijed Rolling Eyes

e da, jedno pitanje za sve vas ...
šta radi taj algoritam i po kojoj teoriji Smile



_________________
quo - the only one
[Vrh]
Korisnički profil Pošaljite privatnu poruku Pošaljite e-mail
Prethodni postovi:   
Započnite novu temu   Odgovorite na temu   printer-friendly view    Forum@DeGiorgi: Početna -> Ostalo - ozbiljno -> Matematika (općenito) Vremenska zona: GMT + 01:00.
Stranica 1 / 1.

 
Forum(o)Bir:  
Ne možete otvarati nove teme.
Ne možete odgovarati na postove.
Ne možete uređivati Vaše postove.
Ne možete izbrisati Vaše postove.
Ne možete glasovati u anketama.
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2002 phpBB Group
Theme created by Vjacheslav Trushkin
HR (Cro) by Ančica Sečan