This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gams:difference_between_the_-operator_and_the_power_function [2008/04/02 17:49] Franz Nelissen |
gams:difference_between_the_-operator_and_the_power_function [2008/07/26 05:49] (current) support |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== What is the difference between the ** operator and the power function? ====== | ====== What is the difference between the ** operator and the power function? ====== | ||
- | The power function ''power(x,y)'' is an integer power and thus the exponent y must be an integer. | + | The power function ''power(x,y)'' is an integer power and thus the exponent ''y'' must be an integer. |
- | This is not required for the %%**%% operator. %%x**y%% is a real power and gets evaluated as exp(y*log(x)). | + | This is not required for the %%**%% operator. %%x**y%% is a real power and gets evaluated as ''exp(y * log(x))''. The real power is not defined for a negative base (e.g. http://www.cppreference.com/stdmath/pow.html) - ''x'' must be a positive number (or ''y >= 0'', if ''x = 0'') to avoid an execution error. So: |
- | However, with the %%**%% operator x must be a positive number (or y >= 0, if x = 0) to avoid an execution error. So: | + | |
<code> | <code> | ||
scalar test; | scalar test; | ||
Line 11: | Line 10: | ||
display test; | display test; | ||
</code> | </code> | ||
- | will give you an error: | + | will return an error: |
<code> | <code> | ||
**** Exec Error at line 2: rPower: FUNC DOMAIN: x**y, x < 0 | **** Exec Error at line 2: rPower: FUNC DOMAIN: x**y, x < 0 |