I really need help in trying to understand what the "dat:table" is in this procedure,
and how to translate it to Java.

procedure Taylor(var dat: table ; cd: integer; h: real);

begin
for i:=2 to cd + 1 do
begin
dat[i,1] := dat[i,1] + (i-1)*h;
x := dat[i-1,1]; y := dat[i-1,2];
result := h * (x*exp(ln(y)/3)) +
(sqr(h)/2) * ((sqr(x)/3) * exp(-ln(y)/3 + exp(ln(y)/3)) +
((h*h*h)/6) * (-(x*x*x/9)/y) + x *exp(-ln(y)/3)) +
(sqr(h) *sqr(h)/24) * (((sqr(x)*sqr(x)/9) * exp((-5/3)*ln(y))) -
((2/3) * sqr(x)/y + exp(-ln(y)/3) );

dat[i,2] := dat[i-1,2] + result;
end;
end;

Is the table an array? i need to write a complete program using this algorithm.

Any help would be much appreciated

Recommended Answers

All 3 Replies

procedure Taylor(var dat: table ; cd: integer; h: real);

begin
for i:=2 to cd + 1 do
begin
dat[i,1] := dat[i,1] + (i-1)*h;
x := dat[i-1,1]; y := dat[i-1,2];
result := h * (x*exp(ln(y)/3)) +
(sqr(h)/2) * ((sqr(x)/3) * exp(-ln(y)/3 + exp(ln(y)/3)) +
((h*h*h)/6) * (-(x*x*x/9)/y) + x *exp(-ln(y)/3)) +
(sqr(h) *sqr(h)/24) * (((sqr(x)*sqr(x)/9) * exp((-5/3)*ln(y))) -
((2/3) * sqr(x)/y + exp(-ln(y)/3) );

dat[i,2] := dat[i-1,2] + result;
end;
end;

Use code tags next time. I've never seen the table variable type, but then again I don't program in pascal much. Trying to create a variable as a "table" raises an error on my compiler(FPC, without ObjFPC support). It is possible whoever wrote that piece of code(I assume you did not because you don't understand it) made a record or data type and is using that... Or it could be in a unit you are using. You should post more of the program(especially parts where the original author uses the keywords uses, record, or type).

I haven't used/seen table before, but I think that is a type defined by the author.
Probably

type
   table = array[1..100, 1..100] of real; //for example

So in java you will have something like

double[][] table = null;

Ionut

I really need help in trying to understand what the "dat:table" is in this procedure,
and how to translate it to Java.

procedure Taylor(var dat: table ; cd: integer; h: real);

begin
for i:=2 to cd + 1 do
begin
dat[i,1] := dat[i,1] + (i-1)*h;
x := dat[i-1,1]; y := dat[i-1,2];
result := h * (x*exp(ln(y)/3)) +
(sqr(h)/2) * ((sqr(x)/3) * exp(-ln(y)/3 + exp(ln(y)/3)) +
((h*h*h)/6) * (-(x*x*x/9)/y) + x *exp(-ln(y)/3)) +
(sqr(h) *sqr(h)/24) * (((sqr(x)*sqr(x)/9) * exp((-5/3)*ln(y))) -
((2/3) * sqr(x)/y + exp(-ln(y)/3) );

dat[i,2] := dat[i-1,2] + result;
end;
end;

Is the table an array? i need to write a complete program using this algorithm.

Any help would be much appreciated

Hi,try to send the whole source code ,if you send it ,then maybe we can help you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.