How to make and plot a function with a summation?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bas Helfrich
am 11 Jan. 2018
Kommentiert: Steven Lord
am 12 Jan. 2018
Goodevening everybody,
I've been trying to make and plot the following function in Matlab:

I have the values for ak in a vector (n is max 100). I've been trying with symsum function and for loops in a sorts of ways but can't get it to work.
I hope someone can help me :)
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (2)
Steven Lord
am 11 Jan. 2018
Do you want this to be a symbolic expression with x as the symbolic variable? Or do you have a numeric value for x and want the result of evaluating this polynomial?
In the latter case, I would be very careful about doing anything with a polynomial of degree 99. You're almost begging for catastrophic cancellation. But if you are careful you could use the polyval function.
2 Kommentare
Steven Lord
am 12 Jan. 2018
Keep in mind:
>> x = 8^99
x =
2.5463e+89
You're going to be adding and subtracting extremely large numbers at the edges of your ranges if you go up to a degree 99 polynomial. See the catastrophic cancellation link I included in my response.
If your polynomial is of modest degree, you already have the polynomial you need to use polyval. It takes a coefficient vector and you said "I have the values for ak [the coefficients] in a vector".
x = polyval([1 2 3], 4)
y = 1*4^2 + 2*4^1 + 3*4^0
f = @(x) x.^2 + 2*x.^1 + 3;
z = f(4)
Torsten
am 12 Jan. 2018
Is this the partial Taylor series of a certain function f ?
In this case, you could use
f=...;
n=...;
fn = taylor(f,x,'order',n);
fplot(fn);
xlim([-4 4])
grid on
Best wishes
Torsten.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!