Re: conversion when using solve



Dana Damian wrote:

allow me to insist on the matter because i simply don't find a sense. and i'm asking myself
whether it is me that is missing something or it's matlab.
referring to the message below , i find strange that matlab can solve the system of equations:
solve(c1*log(x1)+c2*log(x2)=0, c3*log(x1)+cp*log(x2)=0)
with x1 , x2 unknown,
but can't solve:
solve(c1*log(x1)+c2*log(x2)+t1=0, c3*log(x1)+cp*log(x2)+t2=0)
where t1 and t2 are real numbers!

Which Matlab version are you using? In particular, are you using R2008b, as that
changed the default symbolic engine.

Before R2008b, the symbolic engine was Maple. Maple has no problem solving
equations of the form you indicate:

solve({c1*log(x1)+c2*log(x2)+t1,c3*log(x1)+cp*log(x2)+t2},{x1,x2});
{x1 = exp(-1/(cp*c1-c2*c3)*(cp*t1-c2*t2)), x2 = exp((c3*t1-t2*c1)/(cp*c1-c2*c3))}

before i insert them into he equation they look like t1=-1.4855
and when inserted, they look like this:
t1= -6689985995061099/4503599627370496
and matlab is blocked in the process and doesn't come out.

The Maple symbolic engine never [*] automatically converts floating point numbers
into rationals. Just the opposite: if you have a floating point number
then the Maple symbolic engine automatically collapses rationals and
folds them into the floating constant. For example,

-1.4855 + 6689985995061099/4503599627370496;
-0.000024703

Which, incidentally, tells us that -6689985995061099/4503599627370496
is -not- the rational equivalent of -1.4855, which is -2971/2000 .
Thus your statement about "they look" that is talking about display
formats, printable approximations, with the output characteristics
controlled by the 'format' command. And
-6689985995061099/4503599627370496 looks to me to be another
Matlab display approximation, one invoked by the 'format rat'
command.

In other words, my suspicion would be that the values you see
are being generated by Matlab's "format rat", rather than being
values computed by the Maple symbolic engine. But I don't know how
the new MuPad based symbolic engine acts; I haven't used it.


But I don't know why your session might hang in attempting to solve
such equations, not unless you are using R2008b and are encountering
a MuPad bug.


[*] Okay, it isn't -never- for converting floating point values into
rationals for Maple. The standard Maple library converts floating point
values into rationals for -some- operations when the floating point
values are exponents. But it is decidedly uncommon in Maple.
.