Ask Your Question

Revision history [back]

How to split a function into separate components (according to their variables)?

Hello there,

I had come across this question on the MATLAB Help Center website and was wondering if there was an equivalent answer in Sage......

if I defined an equation/function as below

x1, x2, y1, y2 = var("x1, x2, y1, y2")

f = 10*x1 + 20*x2 + 10*y1 + 10*y2

how can I split it as below ? :

f_x1 = 10*x1 ;
f_x2 = 20*x2 ; 
f_y1 = 10*y1 ; 
f_y2 = 20*y2 ;

I'd appreciate any suggestions.....

--Moh

How to split a function into separate components (according to their variables)?

Hello there,

I had come across this question on the MATLAB Help Center website and was wondering if there was an equivalent answer in Sage......

if I defined an equation/function as below

x1, x2, y1, y2 = var("x1, x2, y1, y2")

f = 10*x1 + 20*x2 + 10*y1 + 10*y2

how can I split it as below ? :

f_x1 = 10*x1 ;
f_x2 = 20*x2 ; 
f_y1 = 10*y1 ; 
f_y2 = 20*y2 ;

I'd appreciate any suggestions.....

--Moh