Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    13
    ReputationRep:
    So was bored so installed matlab.

    I have a questions if anyone is proficient in matlab.

    Thanks :P
    Offline

    17
    ReputationRep:
    I wouldn't say I'm proficient but I do know it to a certain extent, so I can help with some things
    • Thread Starter
    Offline

    13
    ReputationRep:
    (Original post by Eternalflames)
    I wouldn't say I'm proficient but I do know it to a certain extent, so I can help with some things
    Thanks, just playing around with it.
    Spoiler:
    Show
    Find the Matlab code of Newton Raphson method for f(x)=x^2-747

    % Find the root of f(x)=x^2-747 using Newton Raphson method
    % initial value: x=27, f(x(i))should be less than 1e-7
    % Solution:
    % f(x)=x^2-747=0
    % f'(x)=2*x
    % x(i+1)=x(i)-(f(x(i))/f'(x(i)))
    clear; %clear the previous variables
    clc; %clear the command window
    format('long','g') %format of the numeric values: each number represented by about 15 digits
    i=1;
    x(i)=27;
    f(i)=(-18);
    fd(i)=54;
    iter=0;
    while abs(f(i))>1e-07 %termination condition
    iter=iter+1;
    x(i+1)=(x(i)-(f(i))/(fd(i)));
    f(i+1)=((x(i+1))^2-747);
    fd(i+1)=(2*x(i+1));
    i=i+1;
    end
    disp(' root function value ' );% root and error
    disp([x',f']);
    disp ('total iterations needed');disp(iter); %displays number of iterations
    Am I missing anything, thanks if you read this :P
    Offline

    17
    ReputationRep:
    (Original post by Mihael_Keehl)
    Thanks, just playing around with it.
    Spoiler:
    Show
    Find the Matlab code of Newton Raphson method for f(x)=x^2-747

    % Find the root of f(x)=x^2-747 using Newton Raphson method
    % initial value: x=27, f(x(i))should be less than 1e-7
    % Solution:
    % f(x)=x^2-747=0
    % f'(x)=2*x
    % x(i+1)=x(i)-(f(x(i))/f'(x(i)))
    clear; %clear the previous variables
    clc; %clear the command window
    format('long','g' %format of the numeric values: each number represented by about 15 digits
    i=1;
    x(i)=27;
    f(i)=(-18);
    fd(i)=54;
    iter=0;
    while abs(f(i))>1e-07 %termination condition
    iter=iter+1;
    x(i+1)=(x(i)-(f(i))/(fd(i)));
    f(i+1)=((x(i+1))^2-747);
    fd(i+1)=(2*x(i+1));
    i=i+1;
    end
    disp(' root function value ' );% root and error
    disp([x',f']);
    disp ('total iterations needed';disp(iter); %displays number of iterations
    Am I missing anything, thanks if you read this :P
    That all looks good to me, I put it into my Matlab and there were no errors, that would flag up if anything was missing, so I'd say all is good and have fun!
    • Thread Starter
    Offline

    13
    ReputationRep:
    (Original post by Eternalflames)
    That all looks good to me, I put it into my Matlab and there were no errors, that would flag up if anything was missing, so I'd say all is good and have fun!
    thanks so much for the time and effort
    Offline

    17
    ReputationRep:
    (Original post by Mihael_Keehl)
    thanks so much for the time and effort
    No problem! Feel free to discuss any more questions here, I'll be more than happy to have a go at them
 
 
 
Poll
Do you agree with the PM's proposal to cut tuition fees for some courses?
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.