- #1
Antonija
- 18
- 0
Homework Statement
I'm doing aproximation of derivative called five-point stencil. For every value of x, in interval [a,b], in step of 0.1 i need to calculate derivative.
Homework Equations
[/B]
The equation is like this:
Code:
Five-point stencil:
(-f(x + 2h) + 8f(x + h) - 8f(x - h) + f(x - 2h))/(12*h)
---> (-first+8*sec-8*third+fourth)/12*h
I want to calculate every of theese, so first, sec, third... expression and then at the end calc
ulate derivative.
The Attempt at a Solution
Code:
variables = 'x'
x=a+2*h
do while(x<=b)
variablesvalues=x
x=x+delta
call recog_variables (func, variables)
first(i)=evaluate(variablesvalues)
print*,'to je',first(i)
i=i+1
call destroyfunc()
end do
x=a+h !without this, program works, prints first(i), but it doesn't print sec(i).
do while(x<=b)
variablesvalues=x
x=x+delta
call recog_variables (func, variables)
sec(i)=evaluate(variablesvalues)
print*,'to je',sec(i)
i=i+1
call destroyfunc()
end do
But, in my case, when I try to initialize x after loop, i get this:
Code:
*** glibc detected *** ./test.exe: free(): invalid next size (fast): 0x000000000115c070 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x76a16)[0x7f6466aa0a16]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7f6466aa57bc]
./test.exe[0x407cbf]
./test.exe[0x407e73]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd)[0x7f6466a48ead]
./test.exe[0x401309]
======= Memory map: ========
00400000-00409000 r-xp 00000000 08:02 4988214 /home/antonija/Racunalna/test.exe
00609000-0060a000 rw-p 00009000 08:02 4988214 /home/antonija/Racunalna/test.exe
01159000-0117a000 rw-p 00000000 00:00 0 [heap]
7f6460000000-7f6460021000 rw-p 00000000 00:00 0
7f6460021000-7f6464000000 ---p 00000000 00:00 0
7f6466a2a000-7f6466bac000 r-xp 00000000 08:02 1573554 /lib/x86_64-linux-gnu/libc-2.13.so
7f6466bac000-7f6466dac000 ---p 00182000 08:02 1573554 /lib/x86_64-linux-gnu/libc-2.13.so
7f6466dac000-7f6466db0000 r--p 00182000 08:02 1573554 /lib/x86_64-linux-gnu/libc-2.13.so
7f6466db0000-7f6466db1000 rw-p 00186000 08:02 1573554 /lib/x86_64-linux-gnu/libc-2.13.so
7f6466db1000-7f6466db6000 rw-p 00000000 00:00 0
7f6466db6000-7f6466deb000 r-xp 00000000 08:02 4731999 /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f6466deb000-7f6466fea000 ---p 00035000 08:02 4731999 /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f6466fea000-7f6466feb000 rw-p 00034000 08:02 4731999 /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f6466feb000-7f6467000000 r-xp 00000000 08:02 1572868 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6467000000-7f6467200000 ---p 00015000 08:02 1572868 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6467200000-7f6467201000 rw-p 00015000 08:02 1572868 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f6467201000-7f6467282000 r-xp 00000000 08:02 1573552 /lib/x86_64-linux-gnu/libm-2.13.so
7f6467282000-7f6467481000 ---p 00081000 08:02 1573552 /lib/x86_64-linux-gnu/libm-2.13.so
7f6467481000-7f6467482000 r--p 00080000 08:02 1573552 /lib/x86_64-linux-gnu/libm-2.13.so
7f6467482000-7f6467483000 rw-p 00081000 08:02 1573552 /lib/x86_64-linux-gnu/libm-2.13.so
7f6467483000-7f6467597000 r-xp 00000000 08:02 4732002 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f6467597000-7f6467797000 ---p 00114000 08:02 4732002 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f6467797000-7f6467799000 rw-p 00114000 08:02 4732002 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f6467799000-7f64677b9000 r-xp 00000000 08:02 1573559 /lib/x86_64-linux-gnu/ld-2.13.so
7f64679a0000-7f64679a4000 rw-p 00000000 00:00 0
7f64679b6000-7f64679b8000 rw-p 00000000 00:00 0
7f64679b8000-7f64679b9000 r--p 0001f000 08:02 1573559 /lib/x86_64-linux-gnu/ld-2.13.so
7f64679b9000-7f64679ba000 rw-p 00020000 08:02 1573559 /lib/x86_64-linux-gnu/ld-2.13.so
7f64679ba000-7f64679bb000 rw-p 00000000 00:00 0
7fff7cd1b000-7fff7cd3c000 rw-p 00000000 00:00 0 [stack]
7fff7cd79000-7fff7cd7a000 r-xp 00000000 00:00 0 [vdso]
blackffff600000-blackffff601000 r-xp 00000000 00:00 0 [vsyscall]
Program received signal SIGABRT: Process abort signal.