simplifying an algebraic expression in 6 variables

hello,
can you please help me with the following , I am trying to write matlab code to simplyfy this expression :
0.95 x1 -0.85 x2-0.14 x3+0.13 x4 -0.88 x5 -1.52 x6 - 1.64 * sqrt{ ( 0.100 x1 + 0.06 x2 + 1.03 x3 + 0.88 x4+0.02 x5 +0.19x6) ^2 + (0.04 x1 -0.05 x2+0.057 x3+0.15 x4-0.01 x5 -0.08 x6) ^2 }
I want to combine all x1 together and x2 as well ..etc
Thank you in advance

6 comentarios

Torsten
Torsten el 7 de Jun. de 2022
It depends on what you mean is a "simpler" expression than the one you posted.
In my opinion, it's the simplest one you can have.
Az.Sa
Az.Sa el 7 de Jun. de 2022
I mean I want to combine all x1 together and x2 as well ..etc
Sam Chak
Sam Chak el 7 de Jun. de 2022
Editada: Sam Chak el 7 de Jun. de 2022
@FA.A, can you edit your Question and specify your request there so that people can clearly understand what you really want and they provide the best answers that suit your need?
Edit: Thanks.
Is it allowed to manipulate the function fcn so that and can be factored?
syms x1 x2 x3 x4 x5 x6
fcn = 0.95*x1 - 0.85*x2 - 0.14*x3 + 0.13*x4 - 0.88*x5 - 1.52*x6 - 1.64*sqrt((0.100*x1 + 0.06*x2 + 1.03*x3 + 0.88*x4 + 0.02*x5 + 0.19*x6)^2 + (0.04*x1 - 0.05*x2 + 0.057*x3 + 0.15*x4 - 0.01*x5 - 0.08*x6)^2)
Az.Sa
Az.Sa el 7 de Jun. de 2022
Editada: Az.Sa el 7 de Jun. de 2022
Thank you,
Actully what I am trying to do is to solve the following minimization problem which contains a square root term
where yi is the value of the ith observation of the dependent variable, and aij ,bij,cij the value of the ith observation of the jth independent variable, k is constant
I am trying to setup my optimization problem correctly. so I thought it might be a good idea to simplyfy the expression before then I may be able to solve the problem.
Torsten
Torsten el 7 de Jun. de 2022
Editada: Torsten el 7 de Jun. de 2022
I'm surprised that the expression under curly brackets is not squared.
Just use lsqnonlin or lsqcurvefit and set up the model function as is (with the square root). No simplification is possible (and needed).
Az.Sa
Az.Sa el 7 de Jun. de 2022
Editada: Az.Sa el 7 de Jun. de 2022
I am sorry can you give me a clue how to setup my optimization problem correctly. I am not sure how to construct the code corresponding to the above equation. Also, You are right the expression suppose to be squared if I am applying least square. However, If I want to use least absolute deviation insted of least square how can I deal with that ?

Iniciar sesión para comentar.

 Respuesta aceptada

Torsten
Torsten el 7 de Jun. de 2022
Editada: Torsten el 8 de Jun. de 2022
fun = @(x) sum( (y - A.'*x - K*sqrt((B.'*x).^2 + (C.'*x).^2) ).^2 );
Aeq = ones(1,6);
beq = 1;
lb = zeros(1,6);
ub = ones(1,6);
x0 = ones(1,6)/6;
x = fmincon(fun,x0,[],[],Aeq,beq,lb,ub)

3 comentarios

Az.Sa
Az.Sa el 8 de Jun. de 2022
Thank you very much , can I ask how would I knw the value of my objective function ? I want to change the initial point and compare the results
[x,fval] = fmincon(fun,x0,[],[],Aeq,beq,lb,ub)
Az.Sa
Az.Sa el 8 de Jun. de 2022
Editada: Torsten el 8 de Jun. de 2022
Thank you very much

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 7 de Jun. de 2022

Editada:

el 8 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by