Lionel has a calculator that displays a maximum of ten digits (for example: 3,478,062,139 and 0.073672932)
• Lionel chose 4 distinct prime numbers p,q,r and s all less than 100 and he calculates p/q – r/s. The result is 0.180451127. Determine p,q,r and s.
• Consider the two base ten numbers 0.728101457 and 0.635149023. One of these numbers is the result displayed by Lionel's calculator of an irreducible fraction u/v with u and v, that are positive integers less than 1000. The decimals of the other number are taken from a table of random numbers.
Determine the terms u and v of the irreducible fraction.
Part 1:
pr=primes(100);
for a=1:25
p=pr(a);
for b=1:25
q=pr(b);
for c=1:25
r=pr(c);
for d=1:25
s=pr(d);
if abs(p/q-r/s - .180451127) < .00000001
fprintf('%3d %3d %3d %3d %15.13f\n',p,q,r,s,p/q-r/s)
end
end
end
end
end
finds
p q r s p/q-r/s
2 7 2 19 0.1804511278195
17 19 5 7 0.1804511278195
23 7 59 19 0.1804511278195
37 7 97 19 0.1804511278195
The first row has repeated primes, which is disallowed by the need for distinct primes.
The second row is presumably the expected answer, as it uses "proper" fractions.
The last two rows involve so-called improper fractions.
Lionel's calculator apparently truncates rather than rounds, I guess as a result of having no guard digits.
Part 2:
for goal=[0.728101457 0.635149023]
disp(' ')
disp(goal)
matrix=[1 0; 0 1];
x=goal; y=1;
for i=1:15
q=floor(x/y);
r=x-q*y;
x=y; y=r;
newrow=matrix(1,:)-q*matrix(2,:);
matrix(1,:)=matrix(2,:);
matrix(2,:)=newrow;
fprintf('%9d %9d %14.12f\n',newrow, abs(newrow(2)/newrow(1)))
end
end
finds
(showing the goal and successively better rational approximations to it.)
0.728101457
1 0 0.000000000000
-1 1 1.000000000000
3 -2 0.666666666667
-4 3 0.750000000000
11 -8 0.727272727273
-103 75 0.728155339806
114 -83 0.728070175439
-217 158 0.728110599078
331 -241 0.728096676737
-548 399 0.728102189781
1975 -1438 0.728101265823
-2523 1837 0.728101466508
39820 -28993 0.728101456554
-42343 30830 0.728101457148
It took 5 digits each in numerator and denominator to get 30830/42343 as a good enough approximation to 0.728101457, so this is the random-digit number. u=618 v=973
124506 -90653 0.728101456958
0.635149023
1 0 0.000000000000
-1 1 1.000000000000
2 -1 0.500000000000
-3 2 0.666666666667
8 -5 0.625000000000
-11 7 0.636363636364
74 -47 0.635135135135
-973 618 0.635149023638
u=618 v=973
1609416 -1022219 0.635149023000
-1610389 1022837 0.635149023000
17713306 -11250589 0.635149023000
-19323695 12273426 0.635149023000
56360696 -35797441 0.635149023000
-132045087 83868308 0.635149023000
452495957 -287402365 0.635149023000
|
Posted by Charlie
on 2023-03-02 15:38:38 |