# solving equation in matlab

13 Ansichten (letzte 30 Tage)
Esraa El-Basha am 28 Dez. 2017
Bearbeitet: John BG am 4 Jan. 2018
I want to solve this equation in matlab to get the values of y knowing that
x =[0:0.1:7];
eq1 = ((x/7)^2*sqrt(abs(abs(x)-3)/(abs(x)-3))+(y/3)^2*sqrt(abs(y+3/7*sqrt(33))/(y+3/7*sqrt(33)))-1);
then draw x and y together.
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Esraa El-Basha am 31 Dez. 2017
Yes, eq1 = 0 and i need to get all the values of y substituting by this range of x. and then draw x and y together.

Melden Sie sich an, um zu kommentieren.

### Antworten (3)

Malhar Ashtaputre am 2 Jan. 2018
Hello Esraa El-Basha,
Try to make the equation in following form.
y = function(eq1,x)
Then define x and eq1=0, then try running.
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Walter Roberson am 2 Jan. 2018
syms x y
eq1 = ((x/7)^2*sqrt(abs(abs(x)-3)/(abs(x)-3))+(y/3)^2*sqrt(abs(y+3/7*sqrt(33))/(y+3/7*sqrt(33)))-1);
fimplicit(eq1, [-8 8 -3 3])
##### 1 KommentarKeine anzeigenKeine ausblenden
John BG am 4 Jan. 2018
fimplicit returns a result that is all zeros except a single NaN
z=fimplicit(eq1, [-8 8 -3 3])
z.ZData
Then one realizes that it's a complex function, so solving complex functions requires to check both real and imaginary parts, or to work with abs.
Also, one wonders if the graph that fimplicit returns is of any use: Melden Sie sich an, um zu kommentieren.

John BG am 4 Jan. 2018
Bearbeitet: John BG am 4 Jan. 2018
Hi Esraa
1. Check Real and Imaginary
Since the equation is complex, it's useful to check both real and imaginary parts of the equation:
clear all;clc;close all
x =[0:0.1:7];
y =[0:0.1:7];
[X Y]=meshgrid(x,y);
Z = ((X/7).^2*sqrt(abs(abs(X)-3)./(abs(X)-3))+(Y/3).^2*sqrt(abs(Y+3/7*sqrt(33))./(Y+3/7*sqrt(33)))-1);
figure(1);surf(X,Y,abs(Z));xlabel('X');ylabel('Y');
. .
figure(2);surf(X,Y,imag(Z));xlabel('X');ylabel('Y');
. .
the apparent minimum value is
min(min(Z))
ans =
22.835714285714282
for
x =[0:0.001:7];
y =[0:0.001:7];
..
min(min(Z))
=
2.332833357142857e+03
For abs(x)<3 the solution is complex
When x=>3 then the solution doesn't get any smaller than min(min(Z)) that seems to be 23.32
2. Asymptotic behavior apparently changes minimum
When changing x y ranges, such minimum value changes too
x =[-7:0.1:7];
y =[-7:0.1:7];
[X Y]=meshgrid(x,y);
Z = ((X/7).^2*sqrt(abs(abs(X)-3)./(abs(X)-3))+(Y/3).^2*sqrt(abs(Y+3/7*sqrt(33))./(Y+3/7*sqrt(33)))-1);
figure(1);surf(X,Y,abs(Z));xlabel('X');ylabel('Y');
figure(2);surf(X,Y,imag(Z));xlabel('X');ylabel('Y');
. now
min(min(Z))
=
46.671428571428571
I tried smaller steps than 0.001, for the given range, which slowed down things.
Then when narrowing the range
x =[0:0.0001:.5];
y =[0:0.0001:.5];
..
min(min(Z))
=
-0.001044693333332 + 8.505952551020407i
3. Simplify
Stepping back on realizes that your the equation is the same, regarding zeros search, as
X^2*1./sqrt(abs(abs(X)-3))+
Y^2*1./(Y+3/7*sqrt(33)))-1)
these 2 terms will not zero for any both large values of X Y.
When approaching x=3 or y=-3/7*sqrt(33) the result rockets.
Now try this
x =[-5:0.01:5];
y =[-5:0.01:5];
[X Y]=meshgrid(x,y);
Z=X.^2*1./sqrt(abs(abs(X)-3))-Y.^2*1./(Y+3/7*sqrt(33))+1;
figure(1);surf(X,Y,10*log10(abs(Z)));xlabel('X');ylabel('Y'); .
that resembles the 'parenthesis like' curves obtained with fimplicit,
however, again increasing the range one realizes that the solutions are not a simple circle or ellipse but these two conic-like notch curves, plus the nearly flat notch running along X axis :
. .
Therefore the solution to your equation are the zeros of
Z=X.^2*1./sqrt(abs(abs(X)-3))-Y.^2*1./(Y+3/7*sqrt(33))+1
Esraa
thanks in advance for time and attention
John BG
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Calculus finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!