Solve equation without symbolic math toolbox

145 views (last 30 days)
Benoit
Benoit on 19 Mar 2014
Commented: Paul on 12 Oct 2025 at 19:55
Hello ,
I'm trying to solve this equation : 0 = (U/r.^3)* sqrt(-2+((3*r.^3)*(Bx/U)))-B
U is a constant
Bx and B are column matrix
I would have as a result a value of r for each value of Bx and B
is it possible to do this without the Symbolic math toolbox ?
Thank you

Accepted Answer

Chris C
Chris C on 19 Mar 2014
You can run this with two functions. The first function I have designated as myMain.m and it is written as..
r0 = rand(3,3);
fsolve(@myfun,r0)
The second function myfun.m is called by the first function by passing initial guesses of r as r0. I altered the way your equation above was written and wrote the function as...
function F = myfun(r)
Bx = rand(3,1);
B = rand(3,1);
U = rand(1);
F = (U)*sqrt(-2+((3*r.^3)*(Bx/U)))-r.^3*B;
end
Change the matrices to whatever numbers you need and it should work.
Good luck.
  2 Comments
Benoit
Benoit on 20 Mar 2014
Moved: John D'Errico on 4 Sep 2025
Hello,
Thank you for reactivity, I've tried you're solution. Im new to fsolve function so maybe I am missing something but your answer gives me just one solution.
Benoit
Benoit on 20 Mar 2014
Moved: John D'Errico on 4 Sep 2025
Ok , i've got it.
Thank you

Sign in to comment.

More Answers (1)

glady
glady on 4 Oct 2025 at 10:58
Two fair dice are thrown and the product of the numbers on the dice is recorded. Given that one die lands on 5, find the probability that the product on the dice is
(a) Exactly 15 =
(b) More than 12 =
  8 Comments
Torsten
Torsten on 11 Oct 2025 at 17:56
Edited: Torsten on 11 Oct 2025 at 17:58
Google's AI supports Sam Chak's last interpretation and gives probabilities of 2/11 and 7/11 :-)
Paul
Paul on 12 Oct 2025 at 19:55
Well, we can't really trust AI w/o verification, can we? :-)
[D1,D2] = deal((1:6).');
S = combinations(D1,D2);
N = sym(height(S));
S.A1 = prod(S{:,"D"+(1:2)},2) == 15;
S.A2 = prod(S{:,"D"+(1:2)},2) > 12;
B1 = or(S.D1 == 5,S.D2 == 5); % at least one
B2 = S.D1 == 5; % one specific
B3 = xor(S.D1 == 5,S.D2 == 5); % exactly one
S.B = [B1,B2,B3];
PA1gB = (sum(S.A1 & S.B,1)/N) ./ (sum(S.B,1)/N)
PA1gB = 
PA2gB = (sum(S.A2 & S.B,1)/N) ./ (sum(S.B,1)/N)
PA2gB = 

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!