When I run this code I get empty strings for when setting a range for vpasolve, when I do not set the range I only get one solution, even with random on. The range is set so that it does include the one solution matlab gives me, x=2, y=0 and b=1.5. for the range I've tried -Inf Inf and NaN NaN, to have it try all numbers. So please do not give me the answer of saying that my system has no solution, it clearly does. It also won't solve it symbolicly (same issue with solve), while I can give 1 possible solution. 0.5*(x+y)=1, b*(x+y)=3 ---> x+y=2 and b=1.5
So something else must be wrong, I would appreciate it if you let me know what I'm doing wrong here.
clear all; %just to be safe
syms x y b
a=0.5;
somevalue=1;
someothervalue=3;
eq1= a*x+a*y == somevalue; %this is your first equation
eq2= b*x+b*y == someothervalue; %this is your 2nd equation
eqs=[eq1,eq2]; %use this for vpasolve and set range in range
vars=[x,y,b]; %these are the variable you want to solve for
range = [-1 3; -2 5; -Inf Inf]; %NaN means you set no range
%you can use solve or vpasolve, second one being numeric, which is the one you'll probably want
sol=zeros(5,3);
for i = 1:5
temp = vpasolve(eqs, vars, range, 'random', true);
temp = solve(eqs2, vars);
sol(i,1) = temp.x;
sol(i,2) = temp.y;
sol(i,3) = temp.b;
end
sol
temp1.x
temp1.y
temp1.b
Now I have another clear problem/error when using the solve option, obviously the answer here should be 9:
syms x
eq12 = -3 == sqrt(x);
solve(eq12)
ans =
Empty sym: 0-by-1
as well as:
syms x
eq12 = -3 == (x)^(1/2);
solve(eq12)
ans =
Empty sym: 0-by-1
Obviously the answer here would be 9, so what do I change to let matlab solve this and before you tell me to change the equation, this is the equation I would have to change by hand and not just once but a 100 times or so.
More specifically I need to solve something way more complicated which has a solution; negative and positive, the negative value is physically unrealistic but it's the only Matlab can give me.
93659574124777211691008 H
H + ---------------------------------------------
1208925819614629174706176 H + 762832192176831
1
== -----------------
100000000000000 H
29250045579840375 #1
- --------------------------------------------------------------------
H (922337203685477580800 H + 927343445063259249) 4611686018427387904
2
12879770070323045125 #1
+ ----------------------------------------------------------------------
2
55340232221128654848 H (922337203685477580800 H + 927343445063259249)
where
/ 2
| 181939 H 852912375078609598437 H
#1 == 9223372036854775808 H - sqrt| --------- + -----------------------
\ 5539 25544128856069301600256
\
39917248404619332215368770561441 |
+ -------------------------------------- | 9223372036854775808 + 6318009845245521
85070591730234615865843651857942052864 /
The trouble maker is the minus in front of the sqrt I assume