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

Azzi Abdelmalek
Azzi Abdelmalek 2016년 5월 22일
Hi, I'm new, can't be a title to your question

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2016년 5월 22일

0 개 추천

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

kvk lord
kvk lord 2016년 5월 22일
thank you :))
Image Analyst
Image Analyst 2016년 5월 22일
I don't know what "The Method of Taylor" is. What is it? Who was he?
kvk lord
kvk lord 2016년 5월 22일
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 2016년 5월 22일
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 2016년 5월 22일
kvk lord
kvk lord 2016년 5월 22일
kvk lord
kvk lord 2016년 5월 22일
sorry for my bad English (

댓글을 달려면 로그인하십시오.

Roger Stafford
Roger Stafford 2016년 5월 22일

0 개 추천

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

kvk lord
kvk lord 2016년 5월 22일
편집: kvk lord 2016년 5월 22일
I know how I can solve this without matlab but I want using Taylor's method

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

질문:

2016년 5월 22일

편집:

2016년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by