How to solve the below numerical

1 view (last 30 days)
How to solve the below equation for x and plot the values of x with respect to y and z where y varies from 100 - 500 and z varies from 200-600.
H = x*exp((3*x*y/sin(x))* z) + cos(2*x*z/y) + exp(-0.5*x);
%%I tried the below
syms x;
z = poles(H, x, 0, 3);
%%Not working for me

Accepted Answer

John D'Errico
John D'Errico on 26 Feb 2022
So for any given value of H, y, znd z, you want to be able to write x as a function of them, then drawing a nice pretty picture.
It is trivially easy to write an expression that has no analytical solution. This is probably one of them, with x falling both inside and outside the exponentials, as well as a trig function. Worse, it may almost certainly be the case where there are mutliple solutions. Trig functions always create those situations.
Finally, you will have the problem that if such a relationship did exist, it would be a function of THREE variables, H,y,z. Unless perhaps you mean that H is supposed to be zero. But if H is some general parameter, then the plot you would generate would be a 4-dimensional plot, difficult to view on your monitor.
If you want to plot the solutions with H=0, this will do it:
H = @(x,y,z) x.*exp((3*x.*y./sin(x)).*z) + cos(2*x.*z./y) + exp(-0.5*x);
fimplicit3(H)
Note the complexity of the result, which suggests that no simple solution will exist. The above is merely a plot. There is no analytical form produced to generate that result.
  4 Comments
John D'Errico
John D'Errico on 26 Feb 2022
Edited: John D'Errico on 26 Feb 2022
Consider what happens when x and y are vectors or matrices.
x = 1:5;
y = [2 3 5 7 11];
Suppose we just wanted to multiply the elements in each and find the product? See that
x.*y
ans = 1×5
2 6 15 28 55
succeeds, but x*y fails.
x*y
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.
The difference is that the * operator is used in MATLAB to perform a DOT product, used in linear algebra.
As I wrote it, had I not used the dotted operators in that expression, while fimplicit3 would not have overtly failed, it would have issued warning messages.
Note that you do NOT need to use a dotted operator to multiply a scalar with a vector or matrix. MATLAB understands how to multiply 2*x.
Amy Topaz
Amy Topaz on 28 Feb 2022
Thank you so much for your replies

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays 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!