Question

In: Computer Science

Using Matlab create an m. file that solves the following problem. Ramanujan's taxi. S. Ramanujan was...

Using Matlab create an m. file that solves the following problem. Ramanujan's taxi. S. Ramanujan was an Indian mathematician who became famous for his intuition for numbers. When the English mathematician G. H. Hardy came to visit him in the hospital one day, Hardy remarked that the number of his taxi was 1729, a rather dull number. To which Ramanujan replied, "No, Hardy! No, Hardy! It is a very interesting number. It is the smallest number expressible as the sum of two cubes in two different ways." Verify this claim by writing a program ​that takes an integer command-line argument n and prints all integers less than or equal to n that can be expressed as the sum of two cubes in two different ways - find distinct positive integers ​a ,​b ,​c , and​ d such that​ a3 + b3 = c3 + d3. Use four nests for loops. Now, the license plate 87539319 seems like a rather dull number. Determine why it's not.

Solutions

Expert Solution

Please find the required MATLAB script as the following:

%=======================================================================

clear all;clc;

n = input('Input number ''n'': '); % Taking input value for n

for i=1:n % For number till n
temp_list = []; % Creating temporary list to store cube paris
for j=1:ceil(i^(1/3)) % As j^3 can not exceed i, iterate j till i^(1/3)

    k_difr = (i-j^3); % From relation j^3+k^3 = i
  
for k=1:ceil(i^(1/3)) % As k^3 can not exceed i, iterate k till i^(1/3)
    if(k^3==k_difr)   % Checking if such k exists
        temp_list = [temp_list;sort([j,k])]; % Store pairs in sorted
        temp_list = unique(temp_list,'rows'); % Select such unique pairs
        break;
    end
end

end
if(size(temp_list,1)>=2) % Printing numbers with atleast 2 feasible pairs
    fprintf('n=%d, (a=%d,b=%d), (c=%d,d=%d)\n',i,temp_list(1,1),temp_list(1,2),temp_list(2,1),temp_list(2,2));
end
end

%=======================================================================

Sample output for n = 200000

==================================================================================

==================================================================================

The number 87539319 is the first number that can be represented by three pairs of number for which the sum of cubes of each number in a pair equals number 87539319 . These pairs are

87539319 = 1673 + 4363 = 2283 + 4233 = 2553 + 4143

In case of any clarificaiton, please comment!


Related Solutions

Fluid Mechanics Friction Problem: Write one MATLAB m-file that solves the Type I and II problems...
Fluid Mechanics Friction Problem: Write one MATLAB m-file that solves the Type I and II problems presented in class based on the file posted for the Type III problem (use Colebrook to estimate f). Type I: Solve hL for v=0.74x10-5ft^2/s, D=3 in, L=1000 ft, e=0.006 in, and Re=80000. f=0.0258 from Moody Chart. Type II: Solve Q for v=10^-6 m^2/s, D=0.2 m, L=500 m, e=0.046 mm, and hL=30m. Use “rough” Colebrook to generate an estimate for f.
Use MATLAB to create a script which solves for problem 5.9 in the book (5.11 in...
Use MATLAB to create a script which solves for problem 5.9 in the book (5.11 in the 4th edition). Given are the equations for the moment, as a function of x, starting from the leftmost side of the beam with x=0 and ending at the other end of the beam with x=12. This piecewise function together makes up the moment equation for the beam given. 0 ≤ ? ≤ 3 ?(?) = 265? − 5.56?3 , 3 < ? ≤...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following problem using problem specifications: Plot x vs y when y=sin(x), y=cos(x), y=sin (2*x), and y=2*sin(x) when x = 1:0.1:10. Use 2 by 2 subplot, sin(x) is in location 1, cos(x) is in location 2, sin(2*x) is in location 3 and 2*sin(x) is in location 4. The plot should have: (1) x label = ‘x value’, y label = ‘y value’, legend ‘y=sin(x)’,’ y=cos(x)’,’ y=sin...
Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The...
Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The words that need to be found are in the file 'WordList.txt'. There are 100 words to be found. You must find the location of the first and last letter of each word as well as the cardinal direction that describes the word's orientation. The location of first and last letters are to be described in terms of row and column, with indexing starting at...
BY Using MATLAB software: Exercise 3: Calculation of the parameters of a dipole. % M-File: ML0804...
BY Using MATLAB software: Exercise 3: Calculation of the parameters of a dipole. % M-File: ML0804 % % Perform numerical integration to find % beam solid angle, directivity, and the % maximum power function for a given length % dipole. % % Variables % L dipole length (in wavelengths) % bL2 phase constant * length/2 % N number of theta points % th,thr angle theta in degrees,radians % dth differential theta % num,den temporary variables % F un-normalized power function...
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio...
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds), takes Fourier transform of the signal (probably FFT).
Write a .m function file on MATLAB that reads the parameters stored in the file missile...
Write a .m function file on MATLAB that reads the parameters stored in the file missile data.txt into MATLAB. The function should have the following declaration: function [X0, Y0, Z0, m0, mf, Thmag0, theta, phi, Tburn] = read input( input filename, M id) where input filename is a string variable denoting the name of the file to be read and M_id is an integer which denotes the missile ID. The outputs are the initial position (X0, Y0, Z0), initial and...
Critique how FTP solves the problem of file transfer – what is good? What is bad?...
Critique how FTP solves the problem of file transfer – what is good? What is bad? What is weird?
Using Matlab functions ‘fdesign’ and ‘design’, create the following filters (do not forget to create an...
Using Matlab functions ‘fdesign’ and ‘design’, create the following filters (do not forget to create an m file to write a script that should be printed in your report). [0.5] a-c each (a) Low pass Hamming and low pass Hann filters, with cut off frequency Fc=300 Hz, sampling frequency Fs=2000 Hz, filter order N=100. Plot both filters on the same graph and use legend in the figure to mark each filter. Comment on the figure. (b) Low pass Hamming filter...
create a function in matlab that sums two m x n matrices using nested loops, then...
create a function in matlab that sums two m x n matrices using nested loops, then returns result into a new matrix. Use nesed for loops to add matrices piece by piece. Basically means, dont program simply A+B Function should perform error check to make sure both matrices have same number of rows/ columns.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT