MATLAB: Is this a symbolic math bug

symbolic

1. Let's a=log(2), I want create with only 5 digits:
>>digits(5);b=sym(a,'d')
b = 0.69315
But what is another way? This way isn't good while – by command digits I effect global changes — and I am forced to return: digits(32)
2. Perhaps one wants to include periodic ratio Suppose a working example: >> b=sym(0.69696969696969,'r') true result 69/99=23/33, but many signs are needed — on contrary: >> b=sym(0.6969,'r') b = 6969/10000
How to easy include, for example, 1.23(45) as ratio?
3. >> syms x positive;
>> x=solve('y=-1')
x = -1
But why was quiet reaction? How to clarify the attribute "positive" (in order to machine feel)?
4. And critical and scandal bug:
>> sym(0.6915 – 0.69,'d')
ans = 0.0015000000000000568434188608080149
at this: >>0.6915000-0.69
ans = 0.001500000000000
and also you may see:
>> sym(0.6915 – 0.69,'r')
ans = 211106232533/140737488355328
>> 211106232533/140737488355328
ans = 0.001500000000000
instead of sholar simple 15/10000

Best Answer

Thanks. To continue:
Q1 Solution based on your idea (oh.. I am stupid :)- ): >>a=log(2);a=sym(vpa(a,5))
Q2: to clarify -- notice for developer I want such reaction: >>a=sym('1.23(45)','r')
a= 679/550
MATLAB MUST tranform periodic kind of rational numbers in math: 1.234545454545..=1.23(45)=1.23+0.01*45/99=...=679/550
A valid script on this topic from another forum user (but I don't like it)
----
function numrat = forMatigor(numch)
% numch -> char ?????: numch = '1.23(45)'
I = regexp(numch,'[.(]');
J = length(numch)-1;
numrat = rats(eval([numch(1:I(2)-1) repmat( numch( I(2)+1:J),1,1+ceil((20-diff(I)+1)/(J-I(2))))]));
----
Also MATLAB would realize reverse: for example -- '1/3' -> '0.(3)'
Q3: yes, here is different (>>syms x positive):
solve('x=-1') VS solve('y=-1')
if both commands run without assigning to x -- it seems results are equavalent:
ans
-1
I don't understand difference... YES -- I HAVE CLARIFYED solve() uses directly noted variable or create it on flying, and assigning x=.. gives us new var. at same name
Q4: The conclusion become obvious. But no good construction. In general:
Let's x,y real anyway created, needed (x-y) as symbolic ratio. I wish be guaranteed:
sym(0.5-0.8) --> -3/10 %normal
sym(0.6915 - 0.69) --> 211106232533/140737488355328 %wrong
sym(rats(0.5)-rats(0.8)) --> [ 0, 0, 0, 0, 0, 0, -3, 0, -3, 0, 0, 0, 0, 0] %what is it?
sym(0.69315)-sym(0.69) --> 63/20000 % best way
>>a=log(2);a=sym(vpa(a,5));a-sym(0.69)
0.0031471805598357605049386620521545 % again wrong