DOUBLE cannot convert the input expression into a double array?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abdullah Türk
le 8 Oct 2019
Réponse apportée : Stephan
le 10 Oct 2019
Hi everybody,
I want to calculate a problem about Taylor series from a book but an error message occurred as follows:
Thank you from now.
The following error occurred converting from sym to double:
Error using symengine (line 59)
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.
Error in example_four3 (line 35)
sol(i+1) = sol(i+1) + (diff(f,(i+1))) * (h^(i+1)/factorial(i+1));
Here is my code:
clc;
clear;
anglout = radtodeg(pi);
true_value = cos(pi/3);
h = pi/3-pi/4;
n = 6;
syms x
f = cos(x);
sol(1) = cos(pi/4);
for i = 0:n
sol(i+1) = sol(i+1) + (diff(f,(i+1))) * (h^(i+1)/factorial(i+1));
sol(1) = sol(i);
end
0 commentaires
Réponse acceptée
Stephan
le 10 Oct 2019
clc;
clear;
anglout = rad2deg(pi);
true_value = cos(pi/3);
h = pi/3-pi/4;
n = 6;
syms f(x) op(x)
f(x) = cos(x);
sol = zeros(1,7);
sol = cos(pi/4);
for i = 0:n
op(x) = (diff(f,x,(i+1)));
sol = double(sol + op(i+1) * (h^(i+1)/factorial(i+1)));
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Number Theory dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!