Post Reply 
problems with integration
01-10-2015, 02:16 PM (This post was last modified: 01-10-2015 03:29 PM by Snorre.)
Post: #46
RE: problems with integration
(01-10-2015 10:30 AM)resolved Wrote:  sorry but I am new to all this jargon, but to help me avoid creating this kind of problem in the future, how do I know or how can I tell when I am working with a function versus an expression???? what I gather is "f" is a function but "f(x)" is an expression?? and how should they be used differently????

It may be a bit long offtopic post, but I'll try to explain:

"f" is a function, i.e. a variable which contains a mapping rule, e.g. "x->x²".
"f(x)" is an expression, it evaluates to the value (a mapping) of f when applied on an argument x, e.g. (x->x²)(x). Its result is x² where the current value (if any) of variable x will be inserted.
I used different colors to visualize distinct(!) variables (despite having the same name).

In the first case "x" is locally bound, which means it is independent of any global variable "x". It doesn't matter if it was renamed to "y" or whatsoever ("x->x²" and "foo->foo²" are totally equivalent) and will be substituted by whatever you put within the parentheses of "f(...)".
In the second case "x" is a free variable and is something very different from "x" within the function definition. It will be substituted immediately by whatever value it currently has. If it has no value, it will be simply substituted by 'x'.

So, if you define a function "g(x):=f-1" (which means "g:=(x->f-1)") and call "g(x)" (which is an expression) you're actually evaluating "(x->f-1)(x)" which results in "x->x²-1".
I don't know the Prime's internals, but in principle this can be examined step by step (from outer to inner):
(1) "x" has no value, so it gets substituted just by 'x'. Thus your expression "(x->f-1)(x)" evaluates to "(x->f-1)(x)".
(2) This expression is further evaluated (applied): parameter "x" is substituted by the argument 'x', so that the result becomes "f-1". As you can see our black 'x' vanished since the parameter "x" didn't occur in the right hand side of the mapping.
(3) The (global) variable "f" is substituted by its value (our mapping "x->x²"), so we get "(x->x²)-1".
(4) Now the CAS does some functional magic: it is capable of operating on mappings, e.g. subtracting a number "1" from the mapping "x->x²", which results in a mapping "x->(x²-1)", our final result.
Even if you initially set x to a value, it won't appear here, because local "x" is different from global "x".

As the Prime doesn't have colored variables, you may clarify this to yourself by renaming. For example if "x:=v", "f(x):=x²", "g(y)=f-1", and "z:=w", then "g(z)" will still evaluate to "x->x²+1".

Simply put: The arrow "->" makes the difference.
An expression is just a term whose variables will be replaced by their content immediately.
A function is a variable containing a mapping rule. The mapping rule itself can be seen as a single term too, but whose variables (wether local or global) won't get evaluated immediately (so recursive definitions become possible).
If you apply "f(...)" you're actually evaluating an expression (the right side of "->" in the mapping rule) where all (local) parameters (as defined left of "->") become substituted by their corresponding arguments (what you put within the parentheses of your call) and then all global variables (even if given as arguments) become substituted by their current values.

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


Messages In This Thread
problems with integration - resolved - 11-28-2014, 05:04 AM
RE: problems with integration - parisse - 11-28-2014, 07:33 AM
RE: problems with integration - resolved - 11-28-2014, 01:26 PM
RE: problems with integration - parisse - 11-28-2014, 02:33 PM
RE: problems with integration - akmon - 11-28-2014, 10:30 PM
RE: problems with integration - resolved - 11-29-2014, 11:42 AM
RE: problems with integration - Gilles - 11-29-2014, 09:00 PM
RE: problems with integration - akmon - 11-29-2014, 01:32 PM
RE: problems with integration - peacecalc - 11-29-2014, 08:12 PM
RE: problems with integration - parisse - 11-30-2014, 07:10 AM
RE: problems with integration - resolved - 11-30-2014, 12:22 PM
RE: problems with integration - akmon - 11-30-2014, 12:28 PM
RE: problems with integration - resolved - 12-01-2014, 06:00 AM
RE: problems with integration - Han - 12-01-2014, 03:45 PM
RE: problems with integration - resolved - 12-06-2014, 01:39 PM
RE: problems with integration - Han - 12-06-2014, 03:35 PM
RE: problems with integration - resolved - 12-06-2014, 03:37 PM
RE: problems with integration - Han - 12-06-2014, 03:46 PM
RE: problems with integration - resolved - 12-06-2014, 04:07 PM
RE: problems with integration - resolved - 12-07-2014, 12:07 PM
RE: problems with integration - Han - 12-08-2014, 02:19 AM
RE: problems with integration - Claudio L. - 01-07-2015, 03:48 PM
RE: problems with integration - Han - 12-08-2014, 03:57 PM
RE: problems with integration - resolved - 01-03-2015, 11:45 AM
RE: problems with integration - resolved - 01-06-2015, 01:55 AM
RE: problems with integration - Han - 01-06-2015, 01:09 PM
RE: problems with integration - resolved - 01-07-2015, 03:57 AM
RE: problems with integration - resolved - 01-08-2015, 12:40 AM
RE: problems with integration - Han - 01-07-2015, 05:11 AM
RE: problems with integration - Snorre - 01-07-2015, 08:57 AM
RE: problems with integration - resolved - 01-09-2015, 04:13 AM
RE: problems with integration - parisse - 01-09-2015, 07:21 AM
RE: problems with integration - parisse - 01-09-2015, 12:40 PM
RE: problems with integration - resolved - 01-10-2015, 10:30 AM
RE: problems with integration - rprosperi - 01-10-2015, 01:34 PM
RE: problems with integration - Snorre - 01-10-2015 02:16 PM
RE: problems with integration - Han - 01-10-2015, 02:19 PM
RE: problems with integration - parisse - 01-10-2015, 03:17 PM
RE: problems with integration - Snorre - 01-10-2015, 03:58 PM
RE: problems with integration - parisse - 01-10-2015, 07:58 PM
RE: problems with integration - jte - 01-12-2015, 06:18 AM



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