Borrar filtros
Borrar filtros

fixed point taylor sine/cosine approximation model

9 visualizaciones (últimos 30 días)
Gary
Gary el 19 de Jun. de 2022
Comentada: Gary el 17 de Jul. de 2022
Can anybody share sine/cosine taylor approx model which is compatible with hdl coder?
  2 comentarios
Walter Roberson
Walter Roberson el 19 de Jun. de 2022
is there a reason why you are not using https://www.mathworks.com/help/fixedpoint/ref/cordicsin.html
Gary
Gary el 21 de Jun. de 2022
I do not wish to use the inbuilt model of simulink but to build one.

Iniciar sesión para comentar.

Respuestas (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 19 de Jun. de 2022
WHy not to use matlab's built-in taylor() expansion fcn: https://www.mathworks.com/help/symbolic/sym.taylor.html?s_tid=doc_ta
E.g.:
syms x
taylor(sin(x), x, pi)
ans = 
taylor(cos(x), x, pi/2)
ans = 
  20 comentarios
Walter Roberson
Walter Roberson el 22 de Jun. de 2022
You need order 22 (x^21) to have an error of less than 1/1000
syms x
f = sin(x);
target = 1/1000;
for order = 2:50
t = taylor(f, x, 0, 'order', order);
val_at_end = subs(t, x, 2*pi);
if abs(val_at_end) < target; break; end
end
order
order = 22
t
t = 
fplot([t, f], [0 2*pi])
fplot(t-f, [0 2*pi])
Gary
Gary el 23 de Jun. de 2022
Thank you . It was excellent analysis. I am clear now.

Iniciar sesión para comentar.


Kiran Kintali
Kiran Kintali el 4 de Jul. de 2022
HDL Coder supports code generation for single precision trigonometric functions.
Getting Started with HDL Coder Native Floating-Point Support
Taylor series approximation using HDL Coder
If you want to build Taylor series approximation by youself you could build using basic Math operations and sufficient amount of fixed-point conversion.
syms x
f = sin(x);
T2sin = taylor(f, x, 'Order', 2); % T2sin = x
T4sin = taylor(f, x, 'Order', 4); % T4sin = -x^3/6 + x
T6sin = taylor(f, x, 'Order', 6); % T6sin = x^5/120 - x^3/6 + x
On you build such a model you can further use optimizations such as multiplier partitioning, resource sharing and pipelining options to optimize the model for area/performance/latency/power.
  2 comentarios
Walter Roberson
Walter Roberson el 4 de Jul. de 2022
They were already using a model with basic math blocks to calculate Taylor series of sine and cosine. I showed, however, that in their target range 0 to 2π that the error for their model was unacceptable, and that to bring the error to 1/1000 you need taylor order 21.
Gary
Gary el 17 de Jul. de 2022
I managed to get 3 digits accuracy sine/cosine using chebhyshev polynomials(order 3). Thank you for sharing all the resources

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by