Solve equation without symbolic math toolbox
Show older comments
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
2 Comments
mylene
on 20 Dec 2025
Edited: Walter Roberson
on 20 Dec 2025
Move B to the right:
Square both sides: 

Let
: 

Multiply by
and rearrange: 

Walter Roberson
on 20 Dec 2025
This appears to be the same technique described at https://www.mathworks.com/matlabcentral/answers/122212-solve-equation-without-symbolic-math-toolbox#comment_3343869
Accepted Answer
More Answers (2)
Sudesh
on 28 Oct 2025
Edited: Walter Roberson
on 29 Oct 2025
can solve this numerically without the Symbolic Math Toolbox. Since you want a value of rrr for each pair of BxBxBx and BBB, you can use numerical root-finding methods like fzero in MATLAB. Here’s a step-by-step guide:
Your equation is:
You want to solve for rrr, given UUU, BxBxBx (a column vector), and BBB (a column vector of the same size).
MATLAB Approach:
U = 1; % Example value
Bx = [0.5; 1.2; 0.8]; % Example column vector
B = [0.1; 0.2; 0.15]; % Example column vector
r_values = zeros(size(Bx)); % Preallocate
for k = 1:length(Bx)
func = @(r) (U./r.^3).*sqrt(-2 + (3*r.^3)*(Bx(k)/U)) - B(k);
% Provide an initial guess for r, say 0.5
r_guess = 0.5;
% Solve numerically
r_values(k) = fzero(func, r_guess);
end
disp(r_values)
Notes:
- Initial guess: fzero requires a starting point. You might need to adjust it depending on the expected range of r.
- Vectorization: Each r depends on a pair (Bx(k), B(k)), so a for loop is appropriate.
mylene
on 20 Dec 2025
0 votes
% Example data U = 1; Bx = [1.5; 2.0; 2.5]; % Column vector B = [1.1; 1.2; 1.3]; % Column vector
% Define quadratic coefficients: c2*a^2 + c1*a + c0 = 0 c2 = B.^2; c1 = -3 * U * Bx; c0 = 2 * U^2;
% Solving for r for each row r_results = zeros(length(B), 2); % Preallocate for two possible roots
for i = 1:length(B) % Find roots of the quadratic for a (which is r^3) a_roots = roots([c2(i), c1(i), c0(i)]);
% Convert back to r
r_results(i, :) = a_roots.^(1/3);
endCategories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!