Simplification or equality check



On 04/01/13 07:23, Stavros Macrakis wrote:
> I suspect that the difference is that float chooses the real value of
> negative numbers to odd fractional powers, e.g., (-1)^(1/3) => -1, while
> rectform chooses the principal value => 1/2+sqrt(3)/2*%i.  This is with
> the default value of domain:real.  With domain:complex, float leaves
> (-1)^(1/3) unevaluated.
>
> But as I said before (not sure why I bother to write my emails if you
> don't read them--this is the second time), you are more likely to get
> tractable solutions if you substitute for x /before/ solving, e.g.

Thank you for looking at this.  I did read your post, which provided a 
useful pointer to radcan(imagpart(...));

I am sorry I was not clear.

I need to find a real root of the equation, in terms of x, to use in 
plot2d(...), as my first post indicated rather poorly.

solve(...) retains the relationship between the solutions and the 
original equation.

I can substitute, apply solve and use the result to pick the correct 
member of solve(eq,y).

Maybe this is finally getting through my thick head.

Thank you.

Tom Dean

kill(all);
/* the equation - find the equation of the tangent line at p */
depends(y,x);
eq:2*x^3-x^2*y+y^3-1=0; p:[2,-3];
/* diff and use first to extract the solution from list */
eq1:rhs(first(solve(diff(eq,x),diff(y,x))));
define(df(x,y),''eq1);
/* equation of line */
pointslope(p,m):=y-p[2]=m*(x-p[1]);
/* equation with real coeff */
eq2:pointslope(p,df(p[1],p[2]));
/* solve for y to use in plot2d() */
soln:rhs(first(solve(eq2,y)));
/* At this point, with a different equation, there may be more than
    one real solution.  This uses p to pick the correct real solution of
    eq for use with plot2d(...)
    */
eq3:solve(subst(y=p[2],eq),x);
eq4:solve(eq,y);
for i:1 thru length(eq3) do if imagpart(eq3[i]) then plteq:eq4[i];
/* need to check to see if actually found a real solution */
/* plot the real part of eq and the soln */
plot2d([rhs(plteq),soln],[x,-4,4],[y,-10,10]);
gnuplot_close();