Ask Your Question
1

Interactive maxima question on fraction value during solve()

asked 2011-08-04 09:16:47 +0200

MaikB gravatar image

Context

I executed this code

var('x, k')
As(x) = (2*k/(k-1))^(-0.5) * (( x^(2/k)  - x^((k+1)/k)) )^(-0.5)
dAs(x) = As.derivative(x)
ns = solve(dAs(x), x)
print ns

which results in

[
(1/(x^((k - 2)/k))) == 1/2*(k + 1)*x^(1/k)
]

My goal is the have sage solve this equation for x, where the result should look something like

x == ( 2/(k+1) )^( k/(k-1) )

The Problem

This code

myEqs = [ (1/(x^((k - 2)/k))) == 1/2*(k + 1)*x^(1/k) ]
assume(k>1)
solve(myEqs, x)

results in

       
Traceback (click to the left of this block for traceback)
...
TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(k-1)/k>0)' before integral or limit evaluation, for example):
Is (k-1)/k an integer?

But the suggested assume(k-1)/k>0) isn't even valid syntax.

My question: How can I cover this question with assume() so that maxima doesn't have to ask (and hence fail because it doesn't support interactive communication with another process)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-08-04 17:47:38 +0200

benjaminfjones gravatar image

updated 2011-08-04 17:49:13 +0200

Looks like you found a typo in the Sage code that is raising that exception. I'll start a ticket for that. Thanks.

To your question:

It is probably the case that without changing some settings/assumptions in Maxima directly, it's not going to be able to solve your particular equation. The assumptions you need relating x and k are tricky.. you have fractional exponents depending on k, so you've got to assume x is real and positive. But doing that doesn't seem to help Maxima.

Here is a work around, though. If you know the form of the equation is going to be like the one you have, the human mathematician would probably take the log of both sides and solve for log(x), then exponentiate. This kind of process is easy to automate:

sage: var('x,y,k')
sage: eq = (1/(x^((k - 2)/k))) == 1/2*(k + 1)*x^(1/k)
sage: eq = log(eq)
sage: eq.full_simplify()
-(k - 2)*log(x)/k == -(k*log(2/(k + 1)) - log(x))/k

sage: eq = eq.full_simplify()
sage: eq = eq.subs(log(x) == y)
sage: solve(eq, y)
[y == k*log(2/(k + 1))/(k - 1)]
sage: S = solve(eq, y)
sage: soln = exp(S[0].rhs())
sage: soln
e^(k*log(2/(k + 1))/(k - 1))

Hopefully there is a better answer which involves telling Maxima to load a package for doing "logarithmic solving" or whatever the process I just described is called.

edit flag offensive delete link more

Comments

For me .simplify_full() doesnt factor out the variables in exponents: eq.simplify_full() results in 2*log(x^(1/k)) - log(x) == log(1/2*(k + 1)*x^(1/k)). A simpler example log(x^(2*k)).full_simplify() 2*log(x^k) . I guess some option variable in maxima has to be altered.

MaikB gravatar imageMaikB ( 2011-08-05 03:49:02 +0200 )edit

I found the variable in maxima: logexpand. Sage offers .expand_log(), which ".. uses the Maxima simplifier and sets logexpand option for this simplifier." log(eq).log_expand().full_simplify() now results in the desired -(k - 2)*log(x)/k == -(k*log(2/(k + 1)) - log(x))/k

MaikB gravatar imageMaikB ( 2011-08-05 04:07:40 +0200 )edit

I see, that's probably my fault , when I was testing I was using a computer with an old version of Sage. `.full_simplify()` must have changed..

benjaminfjones gravatar imagebenjaminfjones ( 2011-08-05 19:30:32 +0200 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2011-08-04 09:16:47 +0200

Seen: 640 times

Last updated: Aug 04 '11