F =
vpasolve does not solve simple equation
Ältere Kommentare anzeigen
I have a simple function and equation to solve: A - 2/(9*(1 - x)^(1/2)) - B*x =0, where A>B>1. The function is clearly continuous, at x = 0 it is positive, and it goes to minus infinity as x goes to 1. This means that there must be a solution on the interval (0, 1). Indeed, Mathematica says the solution is x = 0.987436 for A = 6.742 and B = 4.82. Yet Matlab finds no solution:
syms x; A = 6.742; B = 4.82;
vpasolve((A - 2/(9*(1 - x)^(1/2)) - B*x) == 0, x, [-0.001 1])
ans =
Empty sym: 0-by-1
My good friend ChatGPT suggests that the problem is that the solution is too close to the singularity (i.e. 1). So it suggested restricting the search interval (which I really don’t want, because the solution can indeed be very close to 1), giving good initial values, but none of this works. Curiously, if I get rid of the last term B*x, everything is fine:
vpasolve((A - 2/(9*(1 - x)^(1/2))) == 0, x, [-0.001 1])
ans =
0.99891358069017265865646884840762
Interestingly, this value is indeed very close to 1, closer than the Mathematica solution to the original equation, but poses no problem for Matlab.
Questions:
- What am I doing wrong, why can’t Matlab solve the original simple equation?
- Can it be fixed and if so how?
- Bonus: which AI chatbot is best to use for coding questions?
Thank you!! aron
1 Kommentar
"which AI chatbot is best to use for coding questions?"
Currently: Claude. ChatGPT is good for writing emails. But as John D'Errico stated, this could be different next week.
And AI is just a tool: in the hands of a good programmer it can make writing code faster, but it does not (yet) replace that good programmer. If you want to use AI to help write good code then you still need to be able to write and iteratively improve prompts, review the results critically, and know where it missed something.
AI does not currently replace experience.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Equation Solving finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


