I would like to solve equations, but I got some errors.
Show older comments
Dear Matlab experts,
My coding is below, and I would like to get t. Please let me know how to solve this problem.
Thank you very much in advance.
Sincerely yours,
R
z = 17267.895; a = - 7354.746; b = - 1881.38; c = - 4032.548; d = - 2814.639; e = - 3915.966; f = - 4932.209; g = - 3241.126; h = - 7162.355; aa = 34126547; bb = 1337705000; cc = 81776930; dd = 60483385; ee = 127450459; ff = 142389000; gg = 62271177; hh = 309326225; i = aa*exp(-t.*a) + bb*exp(-t.*b) + cc*exp(-t.*c) + dd*exp(-t.*d) + ee*exp(-t.*e) + ff*exp(-t.*f) + gg*exp(-t.*g) + hh*exp(-t.*h); j = (aa*exp(-t.*a))./i; k = (bb*exp(-t.*b))./i; l = (cc*exp(-t.*c))./i; m = (dd*exp(-t.*d))./i; n = (ee*exp(-t.*e))./i; o = (ff*exp(-t.*f))./i; p = (gg*exp(-t.*g))./i; q = (hh*exp(-t.*h))./i; jj = z*j; kk = z*k; ll = z*l; mm = z*m; nn = z*n; oo = z*o; pp = z*p; qq = z*q; r = 499.137372; rr = 8286.891952; s = 745.383756; ss = 406.307267; u = 1170.715419; uu = 1740.776238; v = 493.50486; vv = 5433.056536; x = r + rr + s + ss + u + uu + v + vv; w = z*r/x; ww = z*rr/x; y = z*s/x; yy = z*ss/x; zz = z*u/x; tt = z*uu/x; ab = z*v/x; cd = z*vv/x; solve ((bb*exp(-t*b))/i == rr/x , t)
Answers (1)
Walter Roberson
on 3 Jan 2014
When I pushed it through the MATLAB -> Maple interface, it complained that the exponents were too large to solve. When I copied over the floating point form of the expression to be solved to Maple, the same error occurred.
I then copied into Maple and edited to get Maple syntax, and along the way converted each floating point number to rational. The MATLAB MuPAD-based symbolic engine by default converts each floating point number to rational as the floating point number gets involved in a symbolic expression, but when floating-floating operations are done before the expression is entangled with a symbol, floating point results are calculated. To get the same effect in MuPAD you would have to sym() each of the floating point numbers as you went.
Having transcribed into Maple, I started Maple towards solving it. After it had proceeded for a moment I realized the complexity of the expression and knew that Maple would take a long time on it, as Maple would be trying to find an exact solution. I then interrupted Maple, plotted the function over a limited range, narrowed in on a portion of the range, and asked Maple to find a numeric solution within that range. The result was that the solution is 0.000195281103070472
For the record, the Maple code version become:
Q := v -> convert(v, rational);
z := Q(17267.895);
a := Q(-7354.746);
b := Q(-1881.38);
c := Q(-4032.548);
d := Q(-2814.639);
e := Q(-3915.966);
f := Q(-4932.209);
g := Q(-3241.126);
h := Q(-7162.355);
aa := Q(34126547);
bb := Q(1337705000);
cc := Q(81776930);
dd := Q(60483385);
ee := Q(127450459);
ff := Q(142389000);
gg := Q(62271177);
hh := Q(309326225);
i := aa * exp(-t*a) + bb * exp(-t*b) + cc * exp(-t*c) + dd * exp(-t*d) + ee * exp(-t*e) + ff * exp(-t*f) + gg * exp(-t*g) + hh * exp(-t*h);
j := aa*exp(-t*a)/i;
k := bb*exp(-t*b)/i;
l := cc*exp(-t*c)/i;
m := dd*exp(-t*d)/i;
n := ee*exp(-t*e)/i;
o := ff*exp(-t*f)/i;
p := gg*exp(-t*g)/i;
q := hh*exp(-t*h)/i;
jj := z*j;
kk = z*k;
ll := z*l;
mm := z*m;
nn := z*n;
oo = z*o;
pp := z*p;
qq := z*q;
r := Q(499.137372);
rr := Q(8286.891952);
s := Q(745.383756);
ss := Q(406.307267);
u := Q(1170.715419);
uu := Q(1740.776238);
v := Q(493.50486);
vv := Q(5433.056536);
x := r+rr+s+ss+u+uu+v+vv;
w := z*r/x; ww := z*rr/x;
y := z*s/x;
yy := z*ss/x;
zz := z*u/x;
tt := z*uu/x;
ab := z*v/x;
cd := z*vv/x;
fsolve(bb*exp(-t*b)/i - rr/x, t=-1/1000..1/1000)
2 Comments
Redwood
on 3 Jan 2014
Walter Roberson
on 3 Jan 2014
The code I show above is Maple code, not MATLAB code. The closest you would get would be to open a MuPAD notebook and paste the code there. I believe the command to open a MuPAD notebook is
notebook
MuPAD's method of converting to rational looks different. In MuPAD you would have to replace
Q := v -> convert(v, rational);
with something like
Q := v -> coerce(v, DOM_RAT);
You might also have to replace
fsolve(bb*exp(-t*b)/i - rr/x, t=-1/1000..1/1000)
with
numeric::solve(bb*exp(-t*b)/i - rr/x, t=-1/1000..1/1000)
Categories
Find more on Functional Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!