Ask Your Question
0

Dealing with undefined exponents in SAGE

asked 2020-07-16 18:06:03 +0100

EconJohn gravatar image

I've been playing with sage a bit and have been running into a number of walls in terms of getting analytical solutions so I decided to check if my beliefs are true about SAGE's difficulty with trying to solve the following algebraic problem in sage. $$x^a-c=0, c\geq0$$ on paper if we were to solve for this problem on paper we get $$x^*=c^{\frac{1}{a}}$$

What is simply done on paper seems to be an issue to run in sage:

x,a,c = var('x a c')
solve(x^a - c== 0)

This code does not work and wont give me the simple pen and paper solution to this problem. why is this the case?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2020-07-16 19:25:14 +0100

Emmanuel Charpentier gravatar image

updated 2020-07-16 19:27:33 +0100

Your code doesn't work because you didn't specify what to solve for. If you try solve(x^a==c,x), Sage becomes nosy (verging on indiscrete...;-). You have a couple of solutions :

  • add assumptions about a and c (see assume?).

  • add temporary assumptions (useful for testing different branches) :

For example:

sage: with assuming(a,"noninteger", c>0): solve(x^a==c,x)
[x == c^(1/a)]
sage: with assuming(a,"noninteger", c<0): solve(x^a==c,x)
[x^a == c]
sage: with assuming(a,"noninteger", c==0): solve(x^a==c,x)
[x == c^(1/a)]

(one notes that the latter is nonsens, while formally correct...).

Transform your equation yourself :

sage: (x^a==c).log().log_expand().solve(x)
[x == c^(1/a)]

(but beware of transformations introducing spurious roots...).

HTH,

edit flag offensive delete link more

Comments

My man you are saving me alot of time today! Thank you!

EconJohn gravatar imageEconJohn ( 2020-07-16 19:44:34 +0100 )edit
1

answered 2020-07-16 20:27:18 +0100

EconJohn gravatar image

updated 2020-07-16 20:28:02 +0100

The quick and dirty code for this is:

x,a,c = var('x a c')
assume(x>0,a>0,c>0)
solve(x^a - c== 0,x)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-16 18:06:03 +0100

Seen: 641 times

Last updated: Jul 16 '20