Getting error (rPower: FUNC DOMAIN: x**y, x < 0)

Problems with syntax of GAMS
Post Reply
freesix
User
User
Posts: 3
Joined: 6 years ago

Getting error (rPower: FUNC DOMAIN: x**y, x < 0)

Post by freesix »

Hi,

When trying to run the below line, I'm getting "rPower: FUNC DOMAIN: x**y, x < 0"

al(i,j,k)$st(k) = (q.l(i,j,k)*((1/hh(i))+(1/hc(j))))/(dt.l(i,j,k)*dt.l(i,j,k+1)*(dt.l(i,j,k)+dt.l(i,j,k+1))/2)**0.33333 ;

==

I follow this link (https://support.gams.com/gams:differenc ... r_function) and tried to replace the above line with the following below line but still not working, now getting (pow(x,i) is not integer)

al(i,j,k)$st(k) = power((q.l(i,j,k)*((1/hh(i))+(1/hc(j))))/(dt.l(i,j,k)*dt.l(i,j,k+1)*(dt.l(i,j,k)+dt.l(i,j,k+1))/2),0.33333) ;


Can you please help as I'm new to Gams?
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: Getting error (rPower: FUNC DOMAIN: x**y, x < 0)

Post by cladelpino »

First line of your linked support page:

The power function power(x,y) is an integer power and thus the exponent y must be an integer.

Looks to me like your exponent (0.3333) is not an integer....
This is the cause of your second error.

The first error is caused by the "base" (x) not being positive. This is a mathematical (ie not a programatical) error because, well... a negative number, raised to a non integer power is not a real number.

So, you should keep your original formulation (using **) and worry about how to handle negative cases.
freesix
User
User
Posts: 3
Joined: 6 years ago

Re: Getting error (rPower: FUNC DOMAIN: x**y, x < 0)

Post by freesix »

Thanks.

Okay, I keep the original function.

How do I turn the base (x) to be positive please?
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: Getting error (rPower: FUNC DOMAIN: x**y, x < 0)

Post by cladelpino »

What do you think of this intrinsic function ?

signPower(x,Y)

It will get you the value of the real branch when it exists (which is your case).
freesix
User
User
Posts: 3
Joined: 6 years ago

Re: Getting error (rPower: FUNC DOMAIN: x**y, x < 0)

Post by freesix »

Thank you.

Sorry Sir, can you be more explicit?
because first of all, I'm not a Mathematician, I'm just a programmer.
I also don't know much of Gams as I just started, I'm busy on Gams Training session.

It's an exercise which my teacher gave us in order to solve.

Can you please tell me exactly what to do in order to get it worked please, because I have to return it soon, Please.

Thanks in advance.
Post Reply