How can I solve a cubic equation using method of Taylor in MATLAB? for example this one: x^3+x^2-16*x=16. please, help me :) if you already have the similar task please send me or attach file. thanks

2 Kommentare

Azzi Abdelmalek
Azzi Abdelmalek am 22 Mai 2016
Hi, I'm new, can't be a title to your question

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Image Analyst
Image Analyst am 22 Mai 2016

0 Stimmen

Try using fzero() like this, all in an m-file called test3.m. It correctly gives a root of -1:
function test3
clc; % Clear the command window.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Plot the data
% Make 400 points along the x axis from -3 to +3.
x = linspace(-3, 3, 400);
yValues = x.^3 + x .^ 2 - 16 * x;
% Plot the function.
plot(x, yValues, 'b-', 'LineWidth', 2);
grid on;
title('y = x.^3 + x .^ 2 - 16 * x', 'FontSize', fontSize);
% Plot a line along the x and y axes.
hold on;
line(xlim, [0, 0], 'Color', 'k', 'LineWidth', 2); % Plot x axis.
line([0, 0], ylim, 'Color', 'k', 'LineWidth', 2); % Plot y axis.
% Plot a line at y = +16
line(xlim, [16, 16], 'Color', 'b', 'LineWidth', 2);
x0 = -2; % initial point
theRoot = fzero(@f, x0)
function y = f(x)
y = x.^3 + x .^ 2 - 16 * x - 16; % Subtract 16 so the function is zero at the root.
%

7 Kommentare

kvk lord
kvk lord am 22 Mai 2016
thank you :))
Image Analyst
Image Analyst am 22 Mai 2016
I don't know what "The Method of Taylor" is. What is it? Who was he?
kvk lord
kvk lord am 22 Mai 2016
In this case you used the code which is already used in matlab. I need to write the similar algorithm "my algorithm/code", step by step, using method of Taylor. Do you know what I mean?
Image Analyst
Image Analyst am 22 Mai 2016
No I don't. Did you see my last comment? All I've heard of is the "Taylor Series", which doesn't seem related to this at all. Again, I don't know what "The Method of Taylor" is. What is it? Who was he?
kvk lord
kvk lord am 22 Mai 2016
kvk lord
kvk lord am 22 Mai 2016
kvk lord
kvk lord am 22 Mai 2016
sorry for my bad English (

Melden Sie sich an, um zu kommentieren.

Roger Stafford
Roger Stafford am 22 Mai 2016

0 Stimmen

It’s a lot easier to do this one by hand and bypass matlab altogether:
x^3+x^2-16*x-16 = (x-4)*(x+4)*(x+1) = 0
which gives you its three possible solutions immediately: 4, -4, and -1. However, if you are determined to have the computer do it, use ‘roots’:
r = roots([1,1,-16,-16]);

1 Kommentar

kvk lord
kvk lord am 22 Mai 2016
Bearbeitet: kvk lord am 22 Mai 2016
I know how I can solve this without matlab but I want using Taylor's method

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 22 Mai 2016

Bearbeitet:

am 22 Mai 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by