how to transfer a function parameters to small degree
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi fellows,
Somehow I get the function as below
f4 =
-0.0699999999999999928 exp(0.0139999999999999986 x)
- 0.0525000000000000050 exp(0.0140000000000000020 x)
+ 0.269999999999999962 exp(-0.0719999999999999946 x)
The parameters of the function is calculated in the previous steps. When I run
syms x
solve(f4,x);
there is an error message
??? Error using ==> sym.solve at 73
Error using ==> maplemex
Error, (in gcd/gcdchrem1) input polynomials have too large a degree
I guess it is becasue the parameters have too much degree of decimals. Is there any way to transfer f4 to something like
-0.07exp(0.014x)-0.052exp(0.014)+0.027exp(-0.072x)?
In fact, the parameter in the first part and the second part should equal since they are the same according to the way they being calculated. But somehow the result shows there is a very small difference. I dont understand why this either...
Is anyone could help with this? Thanks!
0 commentaires
Réponses (1)
Walter Roberson
le 18 Jan 2013
I notice you are using Maple as your symbolic engine. I never got a chance to play with Maple as the MATLAB symbolic engine, just with Maple itself. Inside Maple itself, this is easily handled as
solve(convert(f4, rational), x)
but I do not know if you have access to Maple's "convert" function. Experiment with
feval(symengine, 'convert', '0.0699999999999999928', 'rational')
and see if it complains about convert or if it returns 7/100
In general the difficulty you are running into is mixing floating point computation at the MATLAB level with calculations at the Symbolic Toolbox level. When you are going to be making symbolic computations, then for accuracy purposes is is best to switch over to symbolic form as soon as possible. For example, instead of using
3.52 * exp(pi/2) * x
you would use
sym('3.52') * exp(sym('Pi/2')) * x
Notice how I have converted every constant in the place it occurs. Do not get lazy and do things like
sym(3.52 * exp(pi/2)) * x
because you will already have lost precision through the floating point calculations at the MATLAB level. For example,
cos(pi/2)
will not be exactly 0 due to round-off error, but
cos(sym('Pi/2'))
will be exactly 0.
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!