Ilaplace and simplify and more roots

1 visualizzazione (ultimi 30 giorni)
john
john il 26 Apr 2014
Modificato: Prateekshya il 22 Ott 2024
For numeric solution I use and it works:
s=ilaplace(result(i,1));
s=feval(symengine, 'float', s);
syms t 'real'
s=vpa(sqrt(2)*real(s),4);
but now I have problem with command simplify. If I use this command, than Matlab stop working, not responding.
s=simplify(s)
What is wrong?
  1 Commento
john
john il 27 Apr 2014
Only during first calculation it takes aprox. 2 minutes. All next calculation take aprox 1 second?
Why?
Matlabu GUI has for it any memory? For results or what?
Thank you

Accedi per commentare.

Risposte (1)

Prateekshya
Prateekshya il 22 Ott 2024
Modificato: Prateekshya il 22 Ott 2024
Hello John,
The behavior you are experiencing with the simplify command in MATLAB can be attributed to several factors, including the complexity of the symbolic expression, the version of MATLAB you are using, and the way MATLAB handles symbolic computations internally. Here are some insights and suggestions for why simplify might be slow:
  • Complexity of Expression: If the symbolic expression is complex, simplify can take a significant amount of time to find a simpler form. This is because simplify attempts numerous algebraic transformations to reduce the expression's complexity.
  • MATLAB's Internal Optimization: MATLAB might cache intermediate results or optimization paths during the first run. This can make subsequent calls faster, as MATLAB might reuse previous computations or optimizations.
  • Symbolic Engine: The symbolic engine (MuPAD or the newer symbolic engine in recent MATLAB versions) has its own optimizations and might improve performance after the first computation.
Suggestions to Improve Performance:
  • Use simplify with Options: You can control the behavior of simplify using additional options. For example, you can specify a Steps parameter to limit the number of simplification steps:
s = simplify(s, 'Steps', 100); % Adjust the number of steps as needed
  • Use simplifyFraction: If your expression is a fraction, using simplifyFraction might be more efficient:
s = simplifyFraction(s);
  • Use simplify Selectively: Apply simplify only to parts of the expression that are known to be complex or need simplification.
  • Check Expression Complexity: Before simplifying, check the complexity of the expression with length or size to decide if simplification is necessary.
  • Optimize Code: Ensure that other parts of your code are optimized to reduce the expression's complexity before calling simplify.
To know more about simplify and simplifyFraction, please follow the below links:
I hope this helps!

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by