Post Reply 
Plot derivative of a function
06-07-2014, 01:12 PM
Post: #25
RE: Plot derivative of a function
(06-05-2014 04:25 AM)cyrille de brébisson Wrote:  Problem is, it is not wrong!

Well, from a math point of view, I'd say it is wrong. From a computer science point of view, it's allowed, though perhaps not advisable in this case. I think the double meaning of x here may have caused confusion about what was going on. I'd at least suggest it not be used in documentation.

If a student writes something on paper, I expect them to write it using proper math notation. If a student types something into their calculator, all I'll see is the answer.

Quote:What you have is 2 variables, with the same name but a different scope.
This is not a problem in computer sciences where such a construct
{
int i=0;
{
int i=1;
}
}
happends often, and where we know what to look for (but still causes bugs every once in a while)...

I recall in my first college programing class back in the 80's. The professor was emphasizing the importance of using locally defined variables and I wrote something like:

Code:

Program CircArea(output);

const 
  PI = 3.14;

function area(r : real) : real;
const
  PI = PI;  { <-- notice this }
begin
  area := PI*r*r;
end;
...

He didn't like the PI = PI statement, but I thought it made perfect sense. I figured the PI on the left was local to the area() function while the PI on the right was Global. My intent was that within the function, only local constants (PI) and variables (r) were used.

It seems silly now, but at the time I thought I was so clever. :-)

-wes
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Plot derivative of a function - swisscow - 05-31-2014, 02:47 PM
RE: Plot derivative of a function - dg1969 - 05-31-2014, 03:09 PM
RE: Plot derivative of a function - dg1969 - 05-31-2014, 04:20 PM
RE: Plot derivative of a function - Maro - 05-31-2014, 07:10 PM
RE: Plot derivative of a function - Maro - 06-04-2014, 08:26 AM
RE: Plot derivative of a function - Maro - 06-04-2014, 03:04 PM
RE: Plot derivative of a function - Maro - 06-05-2014, 08:00 AM
RE: Plot derivative of a function - DrD - 06-05-2014, 10:24 AM
RE: Plot derivative of a function - Wes Loewer - 06-07-2014 01:12 PM
RE: Plot derivative of a function - Angus - 06-05-2014, 10:39 AM
RE: Plot derivative of a function - HP67 - 06-06-2014, 08:31 AM
RE: Plot derivative of a function - HP67 - 06-07-2014, 06:32 PM
RE: Plot derivative of a function - Angus - 06-06-2014, 08:33 AM
RE: Plot derivative of a function - jte - 06-10-2014, 09:19 PM



User(s) browsing this thread: 2 Guest(s)