Skip to content
Snippets Groups Projects
Commit 3c11face authored by Lucas Christesen Ahler's avatar Lucas Christesen Ahler
Browse files

Latex exercise

parent 2c9c4aab
No related branches found
No related tags found
No related merge requests found
CFLAGS = -Wall -O1 -std=gnu11
LDLIBS = -lm
ms.pdf: ms.tex exp-gpl.tex Makefile
pdflatex $<
pdflatex $<
# bibtex $< Hvis bibtex bruges
# pdflatex $<
out.data.txt: main
./$< > ./$@
exp-gpl.tex: out.data.txt
echo '\
set terminal latex rotate;\
set output "$@";\
set size 0.8,0.9;\
set key top left;\
set tics out;\
set xlabel "x";\
set ylabel "Exp(x)";\
set title "Exponential functions";\
plot\
"$<" using 1:2 with line title "Exp from math.h",\
"$<" using 1:3 with line title "Homemade exp";\
' | gnuplot
.PHONEY: clean
clean:
$(RM) exp-gpl.tex ms.aux ms.log ms.pdf main out.data.txt
\ No newline at end of file
#include<math.h>
#include<stdio.h>
double ex(double x){
if(x<0)return 1/ex(-x);
if(x>1./8)return pow(ex(x/2),2);
return 1+x*(1+x/2*(1+x/3*(1+x/4*(1+x/5*(1+x/6*(1+x/7*(1+x/8*(1+x/9*(1+x/10)))))))));
}
int main() {
for(double x=1./16;x<8;x+=1./16) {
printf("%g %g %g\n",x,exp(x),ex(x));
}
return 0;
}
\ No newline at end of file
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment