Month: August 2025
Analytic solution of quatric polynomial does not add up
Dear friends,
I currently ran into a math-issue when trying to get the analytical roots of a polynomial of order 4.
What I want to solve is:
The solution shall run on a microcontroller with dynamically changing parameters [a,d,e]. All parameters are real. I am searching for the real results, imaginary solutions are to be prevented. When applying Matlab symbolic, The parameters [a,d,e] are simplified and represent longer sub-terms. In accordance to the article Wiki: quartic function, I will receive quite a long solution, that is futile to reproduce here. I used the following short code to generate it:
syms x a d e
y= a*x^4+d*x+e
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
To check the solution, I tested it on an easier sub-problem: When d=0 is chosen follows:
When chosing a>0, e<0 this clearly yields some real results, besides the imaginary ones. Now the problem: the above given long solution cannot reproduce this result. Even if I force assumptions that should solve it, follows something that does not look equal:
syms x a d e
assume(a>=0)
assume(d>=0)
assume(e<=0)
y= a*x^4+d*x+e
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
testresult=simplify(subs(sol.x, d,0))
latex(testresult)
However, if I change the equation before solving the quartic function, the solution of it looks as on paper:
y= a*x^4+e
assume(a>=0)
assume(d>=0)
assume(e<=0)
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
testresult2=sol.x
latex(testresult2)
Numerical testing via inserting numbers in the two solutions according to the assumptions a>0, e<0 confirms the difference of the results. Chosing a=1 and e=-2 yields:
1) the general solution of the quartic polynomial (inserting d=0 after solving the quartic polynomial):
vpares1=vpa(subs(testresult,{a,e},{1,-2}))
vpares1 =
0
0
0
0
2) the solution of the simplified quartic polynomial (inserting d=0 before solving):
vpares2=vpa(subs(testresult2,{a,e},{1,-2}))
vpares2 =
1.1892071150027210667174999705605
-1.1892071150027210667174999705605
-1.1892071150027210667174999705605i
1.1892071150027210667174999705605i
Visibly, the trivial solution is not permissible given the solution of case 2). Interestingly, if the requirement is switched from {a>0,e<0} to {a<0, e>0} the solutions match again.
Similar difficulties have shown, when I hand-coded the general solution from the mentioned Wikipedia article. As I need the solution for , I now have trust-issues with the long solution. Therefore, I ask for your help or comment, why the "general solution" does not end in the same result as the simplified problem.
Thank you in advance for your help!Dear friends,
I currently ran into a math-issue when trying to get the analytical roots of a polynomial of order 4.
What I want to solve is:
The solution shall run on a microcontroller with dynamically changing parameters [a,d,e]. All parameters are real. I am searching for the real results, imaginary solutions are to be prevented. When applying Matlab symbolic, The parameters [a,d,e] are simplified and represent longer sub-terms. In accordance to the article Wiki: quartic function, I will receive quite a long solution, that is futile to reproduce here. I used the following short code to generate it:
syms x a d e
y= a*x^4+d*x+e
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
To check the solution, I tested it on an easier sub-problem: When d=0 is chosen follows:
When chosing a>0, e<0 this clearly yields some real results, besides the imaginary ones. Now the problem: the above given long solution cannot reproduce this result. Even if I force assumptions that should solve it, follows something that does not look equal:
syms x a d e
assume(a>=0)
assume(d>=0)
assume(e<=0)
y= a*x^4+d*x+e
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
testresult=simplify(subs(sol.x, d,0))
latex(testresult)
However, if I change the equation before solving the quartic function, the solution of it looks as on paper:
y= a*x^4+e
assume(a>=0)
assume(d>=0)
assume(e<=0)
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
testresult2=sol.x
latex(testresult2)
Numerical testing via inserting numbers in the two solutions according to the assumptions a>0, e<0 confirms the difference of the results. Chosing a=1 and e=-2 yields:
1) the general solution of the quartic polynomial (inserting d=0 after solving the quartic polynomial):
vpares1=vpa(subs(testresult,{a,e},{1,-2}))
vpares1 =
0
0
0
0
2) the solution of the simplified quartic polynomial (inserting d=0 before solving):
vpares2=vpa(subs(testresult2,{a,e},{1,-2}))
vpares2 =
1.1892071150027210667174999705605
-1.1892071150027210667174999705605
-1.1892071150027210667174999705605i
1.1892071150027210667174999705605i
Visibly, the trivial solution is not permissible given the solution of case 2). Interestingly, if the requirement is switched from {a>0,e<0} to {a<0, e>0} the solutions match again.
Similar difficulties have shown, when I hand-coded the general solution from the mentioned Wikipedia article. As I need the solution for , I now have trust-issues with the long solution. Therefore, I ask for your help or comment, why the "general solution" does not end in the same result as the simplified problem.
Thank you in advance for your help! Dear friends,
I currently ran into a math-issue when trying to get the analytical roots of a polynomial of order 4.
What I want to solve is:
The solution shall run on a microcontroller with dynamically changing parameters [a,d,e]. All parameters are real. I am searching for the real results, imaginary solutions are to be prevented. When applying Matlab symbolic, The parameters [a,d,e] are simplified and represent longer sub-terms. In accordance to the article Wiki: quartic function, I will receive quite a long solution, that is futile to reproduce here. I used the following short code to generate it:
syms x a d e
y= a*x^4+d*x+e
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
To check the solution, I tested it on an easier sub-problem: When d=0 is chosen follows:
When chosing a>0, e<0 this clearly yields some real results, besides the imaginary ones. Now the problem: the above given long solution cannot reproduce this result. Even if I force assumptions that should solve it, follows something that does not look equal:
syms x a d e
assume(a>=0)
assume(d>=0)
assume(e<=0)
y= a*x^4+d*x+e
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
testresult=simplify(subs(sol.x, d,0))
latex(testresult)
However, if I change the equation before solving the quartic function, the solution of it looks as on paper:
y= a*x^4+e
assume(a>=0)
assume(d>=0)
assume(e<=0)
sol=solve(y==0,x,’MaxDegree’,4,’ReturnConditions’,true)
testresult2=sol.x
latex(testresult2)
Numerical testing via inserting numbers in the two solutions according to the assumptions a>0, e<0 confirms the difference of the results. Chosing a=1 and e=-2 yields:
1) the general solution of the quartic polynomial (inserting d=0 after solving the quartic polynomial):
vpares1=vpa(subs(testresult,{a,e},{1,-2}))
vpares1 =
0
0
0
0
2) the solution of the simplified quartic polynomial (inserting d=0 before solving):
vpares2=vpa(subs(testresult2,{a,e},{1,-2}))
vpares2 =
1.1892071150027210667174999705605
-1.1892071150027210667174999705605
-1.1892071150027210667174999705605i
1.1892071150027210667174999705605i
Visibly, the trivial solution is not permissible given the solution of case 2). Interestingly, if the requirement is switched from {a>0,e<0} to {a<0, e>0} the solutions match again.
Similar difficulties have shown, when I hand-coded the general solution from the mentioned Wikipedia article. As I need the solution for , I now have trust-issues with the long solution. Therefore, I ask for your help or comment, why the "general solution" does not end in the same result as the simplified problem.
Thank you in advance for your help! mathematics, symbolic, 4th order polynomial, polynomial MATLAB Answers — New Questions
Fatal error starting Matlab 1. time in Ubuntu 25.04
Starting Matlab in CLI on an Ubuntu 25.04 with 16 Gb of RAM I get this:
MATLAB is selecting SOFTWARE OPENGL rendering.
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
library initialization failed – unable to allocate file descriptor table – out of memory
MATLAB is exiting because of fatal error.
I have installed to /home/pgl/matlab as a user (not su).
What is the issue?
Best
PålStarting Matlab in CLI on an Ubuntu 25.04 with 16 Gb of RAM I get this:
MATLAB is selecting SOFTWARE OPENGL rendering.
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
library initialization failed – unable to allocate file descriptor table – out of memory
MATLAB is exiting because of fatal error.
I have installed to /home/pgl/matlab as a user (not su).
What is the issue?
Best
Pål Starting Matlab in CLI on an Ubuntu 25.04 with 16 Gb of RAM I get this:
MATLAB is selecting SOFTWARE OPENGL rendering.
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
library initialization failed – unable to allocate file descriptor table – out of memory
MATLAB is exiting because of fatal error.
I have installed to /home/pgl/matlab as a user (not su).
What is the issue?
Best
Pål ubuntu 25.04, font rendering, opengl MATLAB Answers — New Questions
Errors in listener callbacks
I have an app built in MATLAB App Designer. the underlying code utlizes events and listeners. my problem is this: Whenever an error occurs in the code, the app needs to know about this. when the error occurs in the code itself, there are built in "catch" commands that notify the GUI.
However, when an error occurs in one of the listener callbacks, there is some built in mechanism that replaces the error with a warning. Instead of getting an error message we get a warning: "error occurred during execution of listener callback" and a description of the error message.
Is there a way to cancel this mechanism? to let the errors in listener callbacks become actual error messages? or maybe a way to notify the app in case of a warning? something like try catch that includes warnings?
many thanks
NathanI have an app built in MATLAB App Designer. the underlying code utlizes events and listeners. my problem is this: Whenever an error occurs in the code, the app needs to know about this. when the error occurs in the code itself, there are built in "catch" commands that notify the GUI.
However, when an error occurs in one of the listener callbacks, there is some built in mechanism that replaces the error with a warning. Instead of getting an error message we get a warning: "error occurred during execution of listener callback" and a description of the error message.
Is there a way to cancel this mechanism? to let the errors in listener callbacks become actual error messages? or maybe a way to notify the app in case of a warning? something like try catch that includes warnings?
many thanks
Nathan I have an app built in MATLAB App Designer. the underlying code utlizes events and listeners. my problem is this: Whenever an error occurs in the code, the app needs to know about this. when the error occurs in the code itself, there are built in "catch" commands that notify the GUI.
However, when an error occurs in one of the listener callbacks, there is some built in mechanism that replaces the error with a warning. Instead of getting an error message we get a warning: "error occurred during execution of listener callback" and a description of the error message.
Is there a way to cancel this mechanism? to let the errors in listener callbacks become actual error messages? or maybe a way to notify the app in case of a warning? something like try catch that includes warnings?
many thanks
Nathan app designer, listener, event, callback, error MATLAB Answers — New Questions
DDPG Agent for Battery Control: Scalar action vs Full trajectory?
I’m implementing a Reinforcement Learning solution to control a home battery, similar to a Model Predictive Control (MPC) approach. The observation includes the current state of charge (SoC) and N-step forecasts for PV generation, electrical demand, import price, and export price.
In MPC, I calculate an optimal charge/discharge trajectory over the prediction horizon and output the entire plan. Now, I’m trying to implement the same using a DDPG agent in MATLAB.
My questions:
Should the DDPG agent output a scalar action (charging/discharging power) for each timestep, which is then used to update the SoC based on the sampling time,
or should the agent output a full trajectory, where I execute only the first action but discard the remaining ones, while still using the full trajectory for the reward calculation?
My thoughts:
In MPC, I get the entire optimal trajectory for charging and discharging over the horizon. Initially, I considered using the same approach with the DDPG agent. However, I’m wondering if this is necessary because the value function already accounts for downstream benefits (future prices/loads) since they are included in the state, right?
But if the agent returns just one action for the next state, it seems like this would lead to a result similar to what I would get if I had no prediction horizon at all.
Thanks in advance for any suggestions.I’m implementing a Reinforcement Learning solution to control a home battery, similar to a Model Predictive Control (MPC) approach. The observation includes the current state of charge (SoC) and N-step forecasts for PV generation, electrical demand, import price, and export price.
In MPC, I calculate an optimal charge/discharge trajectory over the prediction horizon and output the entire plan. Now, I’m trying to implement the same using a DDPG agent in MATLAB.
My questions:
Should the DDPG agent output a scalar action (charging/discharging power) for each timestep, which is then used to update the SoC based on the sampling time,
or should the agent output a full trajectory, where I execute only the first action but discard the remaining ones, while still using the full trajectory for the reward calculation?
My thoughts:
In MPC, I get the entire optimal trajectory for charging and discharging over the horizon. Initially, I considered using the same approach with the DDPG agent. However, I’m wondering if this is necessary because the value function already accounts for downstream benefits (future prices/loads) since they are included in the state, right?
But if the agent returns just one action for the next state, it seems like this would lead to a result similar to what I would get if I had no prediction horizon at all.
Thanks in advance for any suggestions. I’m implementing a Reinforcement Learning solution to control a home battery, similar to a Model Predictive Control (MPC) approach. The observation includes the current state of charge (SoC) and N-step forecasts for PV generation, electrical demand, import price, and export price.
In MPC, I calculate an optimal charge/discharge trajectory over the prediction horizon and output the entire plan. Now, I’m trying to implement the same using a DDPG agent in MATLAB.
My questions:
Should the DDPG agent output a scalar action (charging/discharging power) for each timestep, which is then used to update the SoC based on the sampling time,
or should the agent output a full trajectory, where I execute only the first action but discard the remaining ones, while still using the full trajectory for the reward calculation?
My thoughts:
In MPC, I get the entire optimal trajectory for charging and discharging over the horizon. Initially, I considered using the same approach with the DDPG agent. However, I’m wondering if this is necessary because the value function already accounts for downstream benefits (future prices/loads) since they are included in the state, right?
But if the agent returns just one action for the next state, it seems like this would lead to a result similar to what I would get if I had no prediction horizon at all.
Thanks in advance for any suggestions. reinforcement-learning, ddpg, simulink, mpc, matlab MATLAB Answers — New Questions
TreeTable in Matlab 2025a
Since javacomponents are deprecated as of MATLAB 2025a, has anyone found a way to generate treetables similar to what was possible with jide ?
We have been relying on those for a lot of GUI and see nothing in UITABLE/UITREE that would be similar. Necessary features are
tree opening
resizable columns
cell renderer allowing push buttons and pull down menus
column sorting is a bonusSince javacomponents are deprecated as of MATLAB 2025a, has anyone found a way to generate treetables similar to what was possible with jide ?
We have been relying on those for a lot of GUI and see nothing in UITABLE/UITREE that would be similar. Necessary features are
tree opening
resizable columns
cell renderer allowing push buttons and pull down menus
column sorting is a bonus Since javacomponents are deprecated as of MATLAB 2025a, has anyone found a way to generate treetables similar to what was possible with jide ?
We have been relying on those for a lot of GUI and see nothing in UITABLE/UITREE that would be similar. Necessary features are
tree opening
resizable columns
cell renderer allowing push buttons and pull down menus
column sorting is a bonus uitable, uitree, treetable MATLAB Answers — New Questions









