Hi, I'm new
이전 댓글 표시
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
2016년 5월 22일
Hi, I'm new, can't be a title to your question
답변 (2개)
Image Analyst
2016년 5월 22일
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
2016년 5월 22일
Image Analyst
2016년 5월 22일
I don't know what "The Method of Taylor" is. What is it? Who was he?
kvk lord
2016년 5월 22일
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
2016년 5월 22일
kvk lord
2016년 5월 22일
kvk lord
2016년 5월 22일
Roger Stafford
2016년 5월 22일
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]);
카테고리
도움말 센터 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

