## issue with fsolve and Directsearch command in mapl...

Hi,

I have three simultaneous equations  with three unknown variables (E, W, T). When I solve these  simultaneous equations with fsolve command without specifying any range for variables, I don't get desirable root ( equation sol4 in maple worksheet- {E = 0.1007672475e-2, T = .7969434549, W = 0.1937272759e-2}). For this problem, I know the correct root {E = 2843.916504, T = .2782913990, W = 5344.844134} beforehand which maximize the objective function TP (equation sol8 in maple worksheet) and when I specify the narrow range of variables around the already known correct root in the fsolve command, then I get correct root ( equation sol5 in maple worksheet). If I don't know the actual answer (correct roots of the simultaneous equation) beforehand, How  could I get the correct root with fsolve command because it is very tedious work to specify different range in fsolve command repetitively to solve it by trial and error.

I also tried Direct Search method as suggested in this forum  but DirectSearch is also not able to provide the correct root (equation sol6 in maple worksheet). If I specify the narrow range around known root in direct search method ( equation sol6a in maple worksheet), then it would provide close to optimal root but if I don't know the correct root beforehand, then I couldn't specify the narrow range of variables, then how can I get correct root through direct search command.

Equation sol10 in maple worksheet  (objective function value at correct root) confirms that {E = 2843.916504, T = .2782913990, W = 5344.844134} is the correct root because it provide the value of objective function (TP) equal to 78285.85621 as opposed to negative value (TP value -12.53348074 in equation sol9)  produced by incorrect root  {E = 0.1007672475e-2, T = .7969434549, W = 0.1937272759e-2}).

Is there any method which would provide all the roots of these simultaneous equations which also include correct root. Maple worksheet is attached.

I am trying fsolve and direct search method with known root so that I could get the proper procedure to get the correct root which I can apply to another problem (set of similar simultaneous equations) for which I don't know correct root beforehand.

Ok, so i have this functions

where f(x) represent urban population and g(x) represent the rural population.

And i have to implement an algortihm in Maple to find out after what period of time x the rural population will be with 20% bigger than urban population.

I'm new in Maple and is a little bit hard for me to implement algorithms in this program.If you can help me with any idea, i will really apreciate.Thank you :).

## How to olve system of Non linear equations...

Hi,

I need to solve system of 6 non linear equations.

Down here you can see the code I wrote and at the end used to fsolve function, and it is not running. I get an error about the const 'V': Error, (in fsolve) V is in the equation, and is not solved for.

What is the right way to solve this system?

Thank you very much!

omega1 := 1.562;
omega2 := 2.449;
omega3 := 3.325;
y1 := c1*sin(omega1*t+phi1)+c2*sin(omega2*t+phi2)+c3*sin(omega3*t+phi3);

y2 := .1019*c1*sin(omega1*t+phi1)+.75*c2*sin(omega2*t+phi2)+.4608*c3*sin(omega3*t+phi3);

y3 := .407*c1*sin(omega1*t+phi1)+(0*c2)*sin(omega2*t+phi2)+1.844*c3*sin(omega3*t+phi3);

eq1 := subs(t = 0, y1) = 0;

eq2 := subs(t = 0, y2) = 0;

eq3 := subs(t = 0, y3) = 0;

eq4 := subs(t = 0, diff(y1, t)) = V;
eq5 := subs(t = 0, diff(y2, t)) = 0;
eq6 := subs(t = 0, diff(y3, t)) = 0;

eqs := [eq1, eq2, eq3, eq4, eq5, eq6];

vars := [c1, c2, c3, phi1, phi2, phi3];

fsolve({eq1, eq2, eq3, eq4, eq5, eq6}, {c1, c2, c3, phi1, phi2, phi3});

## fsolve returns unevaluated ...

i have set of equations and variable that i want to solve them using fsolve, but after about 20mintues of computations, fsolve retrun these set unevaluated, could anyone help?

 > restart:with(linalg):with(LinearAlgebra):with(orthopoly):Digits:=40: M:=3: N:=2: l:=2: for m from 0 to M-1 do L[m]:=unapply(P(m,t),t); end do: for n from 1 to N do; for m from 0 to M-1 do; BB[n,m]:=unapply(piecewise((n-1)/N<=t and t
 > ############################################# k:=Matrix(2,2,[[t*s^2,t*s^2],[s*t^2,s*t^2]]):
 >
 >
 >
 >
 >
 >
 >
 >
 >
 > ######################################
 > for i from 1 to 2 do; for j from 1 to 2 do; T[i,j]:=Matrix(N*M,N*M): for n from 1 to M*N do; for m from 1 to M*N do; T[i,j](n,m):=evalf(int(int(B[n]*k(i,j)*BS[m],t=0..1),s=0..1)): end do: end do: od: od: evalm(T[1,1]): evalm(T[1,2]): evalm(T[2,1]): evalm(T[2,2]):
 >
 >
 > ########################################## X[1]:=Matrix(M*N,1): for n from 1 to M*N do; X[1](n,1):=Y[n,1]: od: evalm(X[1]): #### yadet bashe k dar in mesal majhulat y1,y2 ####ba bordarhaye X1, X2 neshun dadi...darvaghe ####dar mesale avale maghale 2ta y dashti k bayad moadele ash ro hal mikardi...
 >
 > X[2]:=Matrix(M*N,1): for n from 1 to M*N do; X[2](n,1):=yY[n,1]: od: evalm(X[2]):
 > U[1,1]:=Matrix(M*N,1): for n from 1 to M*N do; U[1,1](n,1):=u[n,1]: od: evalm(U[1,1]):
 > U[1,2]:=Matrix(M*N,1): for n from 1 to M*N do; U[1,2](n,1):=uU[n,1]: od:
 > evalm(U[1,2]): Transpose(U[1,2]):
 > U[2,1]:=Matrix(N*M,1): for n from 1 to M*N do; U[2,1](n,1):=w[n,1]: od: evalm(U[2,1]):
 > U[2,2]:=Matrix(M*N,1): for n from 1 to M*N do; U[2,2](n,1):=wW[n,1]: od: evalm(U[2,2]):
 >
 > z[1]:=Matrix(1,M*N): z[2]:=Matrix(1,M*N): for i from 1 to 2 do; Z[i]:=Transpose(A)-add(Transpose(U[i,j]).T[i,j], j=1..2); evalm(Z[i]): z[i]:=Z[i]-convert(p[i],Matrix): od: evalm(z[1]): ############## z[1](1,2):
 > ########################################## for s from 1 to M*N do; t:=((2*s)-1)/(2*M*N); ff[1,1]:=eval(VectorMatrixMultiply(Transpose(X[1]),eval(B,t=((2*s)-1)/(2*M*N)))); F[1,s]:=multiply(ff[1,1],ff[1,1]); expand(%): H[1,s]:=VectorMatrixMultiply(Transpose(U[1,1]),eval(B,t=((2*s)-1)/(2*M*N))); hh[1,s]:=F[1,s]-H[1,s][1]; od:
 >
 > ff[1,1]:
 > F[1,1]:
 > H[1,1]:
 > hh[1,2]:
 >
 > for s from 1 to M*N do; t:=((2*s)-1)/(2*M*N); ff[2,1]:=eval(VectorMatrixMultiply(Transpose(X[1]),eval(B,t=((2*s)-1)/(2*M*N)))); G[1,s]:=multiply(ff[2,1],ff[2,1]); expand(%): J[1,s]:=VectorMatrixMultiply(Transpose(U[2,1]),eval(B,t=((2*s)-1)/(2*M*N))); JJ[1,s]:=G[1,s]-J[1,s][1]; od: JJ[1,1]: JJ[1,2]:
 > for s from 1 to M*N do; t:=((2*s)-1)/(2*M*N); ff[1,2]:=eval(VectorMatrixMultiply(Transpose(X[2]),eval(B,t=((2*s)-1)/(2*M*N)))); GG[1,s]:=multiply(ff[1,2],ff[1,2]); expand(%): g[1,s]:=VectorMatrixMultiply(Transpose(U[1,2]),eval(B,t=((2*s)-1)/(2*M*N))); gg[1,s]:=GG[1,s]-g[1,s][1]; od: gg[1,1]: gg[1,2]:
 > for s from 1 to M*N do; t:=((2*s)-1)/(2*M*N); ff[2,2]:=eval(VectorMatrixMultiply(Transpose(X[2]),eval(B,t=((2*s)-1)/(2*M*N)))); DD[1,s]:=multiply(ff[2,2],ff[2,2]); expand(%): d[1,s]:=VectorMatrixMultiply(Transpose(U[2,2]),eval(B,t=((2*s)-1)/(2*M*N))); dd[1,s]:=DD[1,s]-d[1,s][1]; od: dd[1,1]: dd[1,2]:
 > eqq[1]:=seq(hh[1,s],s=1..M*N):
 > eqq[2]:=seq(gg[1,s],s=1..M*N):
 >
 > eqq[3]:=seq(JJ[1,s],s=1..M*N):
 > eqq[4]:=seq(dd[1,s],s=1..M*N): eqq[5]:=seq(z[1](1,s),s=1..M*N): eqq[6]:=seq(z[2](1,s),s=1..M*N):
 > eq:=seq(eqq[s],s=1..M*N):
 > var[1]:=seq(X[1](s,1),s=1..M*N): var[2]:=seq(X[2](s,1),s=1..M*N): var[3]:=seq(U[1,1](s,1),s=1..M*N): var[4]:=seq(U[1,2](s,1),s=1..M*N): var[5]:=seq(U[2,1](s,1),s=1..M*N): var[6]:=seq(U[2,2](s,1),s=1..M*N):
 > EQ:=Matrix(36,1):
 > for i to 6 do EQ(6*i-5,1):=hh[1,i]; EQ(6*i-4,1):=gg[1,i]; EQ(6*i-3,1):=JJ[1,i]; EQ(6*i-2,1):=dd[1,i]; EQ(6*i-1,1):=z[1](1,i); EQ(6*i,1):=z[2](1,i); od:
 > indets(EQ);
 (1)
 >
 >
 > Var:=[seq](var[s],s=1..M*N);
 (2)
 >
 >
 >
 >
 > for i to 36 do EQQ[i]:=simplify(expand(subs([seq](indets(EQ)[i]=AA[i],i=1..36),EQ[i][1])=0)); od;
 (3)
 > fsolve({seq}(EQQ[i],i=1..36),{seq}(AA[i],i=1..36));
 (4)
 >

## fsolve in a range gives error...

I am trying to do fsolve in a range (-7..14), however, it gives no solution.

But when I solve the same equations with solve (after removing all the Imaginary solutions), I get two results, one of them is in the range (-7..14).

I even expanded the range of fsolve, say (-10..20), but still got no solution...

This is just getting weirder and weirder. Attached kindly find the Maple file, note that the first solve takes about 1 minute (on my laptop: CPU i7 + MEM 8G + SSD).

fsolve_In_Range.mw

## I'd like to have some advice to solve a non linear...

Hi everybody,

I have to solve a system  of 3 equations in 3 unknowns.
One equation is linear while the others are not because of some  sinh(cste*unknown) term.
More of this the unknowns must verify some constraints of inequality type (but always very simple ; for instance “unknown <= value”).

solve fails because of the sinh terms
fsolve fails due to the inequalities

What Maple procedure do you advise me to use to solve this system ?
(at this stage I think advices could be sufficient ; if I keep coming up against the problem I will submit you a more detailed question)

## How to find equation of the intersection between ...

With the following command I can plot two spheres and plot them.

f1 := x^2+y^2+z^2 = 1

f2 := x+y+z = 1

with(plottools);

with(plots);

S1 := implicitplot3d(f1, x = -1 .. 1, y = -1 .. 1, z = -1 .. 1, style = patchnogrid, color = blue, scaling = constrained, axes = boxed)

S2 := implicitplot3d(f2, x = -1 .. 1, y = -1 .. 1, z = -1 .. 1, style = patchnogrid, color = gold, scaling = constrained, axes = boxed)

dispaly(S1,S2)

My questions are:

1- How can I display (highlight) the circle which is the intersection between these two sphere on the same figure?

2- How can I find the equation of this circle?

Thank you.

## plot of system of equations...

Hi

I have a system of equations (4) which I would like to plot in regards to a fifth variable. Is there a good way to do this. Some of the solutions would end up as negative values, which is not an option I am interested in having.

C__A is my variable, and the other variables I would like to solve are tau,C__B,C__C,C__D. Im specifically interested in tau with regards to C__A. I hope this makes sense :)

regards

C__A := .75;
0.75

a := tau = (C__A0-C__A)/(-r__A);
0.75
tau = - ------------------------------------------------
2
-0.00900 C__B + 0.03500000000 C__C  - 0.075 C__C
b := tau = (C__B0-C__B)/(-r__B);
2 - C__B
tau = - -----------------------------------
2
-0.00900 C__B + 0.03500000000 C__C
c := tau = (C__C0-C__C)/(-r__C);
C__C
tau = ---------------------------------------
2
0.01800 C__B - 0.070 C__C  - 0.075 C__C
d := tau = (C__D0-C__D)/(-r__D);
13.33333333 C__D
tau = ----------------
C__C
sol := fsolve([a, b, c, d], {C__B = 1, C__C = .2, C__D = .2, tau = 50});

{C__B = 1.673672109, C__C = 0.2289836744, C__D = 0.4236721086,

tau = 24.66971264}

## solve with a variable or fsolve without variable...

I've encountered a very strange issue with Maple.

The result returns differently with solve and fsolve after/before a variable is given a certain value. See attachment.

The result comes from solve (with variable epsilon) returns value of the same variable with imaginary part while the fsolve returns the correct answer.

Now how can I achieve the same result as fsolve via solve?

Thanks!

Maple_Question_Solve_Fsolve.mw

Maple_Question_Solve_Fsolve.pdf  (exported PDF from Maple)

## trouble using fsolve. Different solver needed?...

I have trouble solving this equation

fsolve(5000 = int(1/(0.1060444429e-1-0.2120888857e-1*X+0.1033933318e-1*X^2), X = 0 .. x), x)

It has a few points where the solution will go towards infinite, but that is not something that is an issue normally. I have no problems what so ever to solve this using my trusty TI-89, so Im wondering what needs to be done to actually solve this. I have tried giving an initial guess, and I have tried using solve, but it doesnt seem to do the trick.

Regards

## fsolve range problem...

Hello everyone,

I have 5 equations (fa,fb,fc,fk,fv) and 5 variables (V0,A0,A1,A2,k1) and I want to solve them numerically. Problem is my inability to set properly intervals and starting values.

Here is my command: fsolve({fa,fb,fc,fk,fv},{V0,A0,A1,A2,k1});

If I run it just like this, I get some values, lets say V0=0.00045 etc.But when I set range for V0 like this:

fsolve({fa,fb,fc,fk,fv},{V0=0.0004..0.0005,A0,A1,A2,k1});

I get this:

Error, (in fsolve) fsolve cannot solve on V0 = 0.4e-3 .. 0.5e-3

I used interval 0.0004..0.0005 only to prove that there must be the wrong syntax, because obviously 0.0004<0.00045<0.0005. In reality i need interval 0.0001..0.0002 and it is also necessary.to set some initial values (A0=0.0023) but first I need to solve my problem with syntax.

## How can I solve a set of equations that one of the...

I solve a set of equations in this way and I have three set of answers ,but I don`t know wich one is true.

and I have another question ,how can I assume v[0] like a constant?

alpha[2]:= 2.727272728*10^5: alpha[4]:= 3738.685337: alpha[6]:= -30.18675539: alpha[7] := -4.116375735*10^6: alpha[8] := 1.859504132*10^10: alpha[9]:= 2.489142857*10^(-12):

l10:=(alpha[7]*v[0]^2+1)*gamma[i*n]^4+(-alpha[4]*beta[n]^2+alpha[8]*v[0]^2-alpha[9])*gamma[i*n]^2+(2*I)*gamma[i*n]*alpha[2]*beta[n]*v[0]+(2*I)*gamma[i*n]^3*alpha[6]*beta[n]*v[0]-beta[n]^2 = 0:

l11 := subs(i = 1, l10);

l12 := subs(i = 2, l10);

l13 := subs(i = 3, l10);

l14 := subs(i = 4, l10);

l15 := (exp(I*(gamma[n]+gamma[2*n]))+exp(I*(gamma[3*n]+gamma[4*n])))*(gamma[3*n]^2-gamma[4*n]^2)*(gamma[n]^2-gamma[2*n]^2)+(exp(I*(gamma[n]+gamma[4*n]))+exp(I*(gamma[2*n]+gamma[3*n])))*(gamma[2*n]^2-gamma[3*n]^2)*(gamma[n]^2-gamma[4*n]^2)+(exp(I*(gamma[2*n]+gamma[4*n]))+exp(I*(gamma[n]+gamma[3*n])))*(gamma[2*n]^2-gamma[4*n]^2)*(-gamma[n]^2+gamma[3*n]^2) = 0;

l1 := combine(expand(evalc(l15)), trig):

l2 := combine(expand(evalc(Re(l15))), trig):

l3 := combine(expand(evalc(Im(l15))), trig): v[0] := 1; 1

fsolve({l1, l11, l12, l13, l14}, {beta[n], gamma[n], gamma[2*n], gamma[3*n], gamma[4*n]}):

fsolve({l11, l12, l13, l14, l2}):

solve({l11, l12, l13, l14, l3}):

thanks

Reyhaneh

## Solve... well it depends...

Here is one that the students generated which caused confusion.

a := 0.76;
eq1 := 2*cot(a*sqrt(2*E)) = (2*E-5.4)/(sqrt(E*(5.4-E));
solve(eq1, E)

And the results are: 0., 4.411954070, 2.423743792

The problem is with the second answer because it does not exist. If we plot the LHS and the RHS of eq1 vs E where E=0..5.4

And it gets more interesting, if we calculate:

solve(evalf(eq1), E)

The answers are: 0., 2.423743793, 14.33807304+27.39159712*I

where the 3rd answer is again incorrect.

Finally, if a = 0.8 or larger, the incorrect answers disappear.

Note - fsolve does handle this problem correctly. And despite my attempts to remind them to use fsolve, they see the solve command as the universal truth. Apparently this will be another teaching moment for next year.

So any thoughts about why this happens and why there is a difference in the outcomes between 0.76 and 0.8 for the value of a?

## how i can fsolve 8 equations.......

hi .how i can fsolve 8 equations, in which obtained from

for k from 2 to m do eq1[k_] end do

AND

for k from 2 to m do eq2[k_] end do  and so on........

And gain unknown functions as f3[2], f4[4],....

thanks?

############################Define some parameters

############################Define some equation

######################################  APPLY BOUNDARY CONDITIONS

 (1)

 (2)

 (3)

 (4)

 (5)

## how i can solve or fsolve this equations?...

hi.how i can solve or fsolve this equations?

i can not with fsolve?

thanks alot

SOLVE.mw

Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/SOLVE.mw .