Hello
My equation is developed in a step-by-step manner as follows with some assumptions. x is the unknown in here. This is just a simplified form of my equation.
E(1,1)=0
E(2,1)=(2/x)+(4*E(1,1))
E(3,1)=(2/x)+(4*E(2,1))
.....
E(n+1,1)=(2/x)+(4*E(n,1))
I set E(n+1,1) equal to zero and find the x via sym. However, it takes a long time via sym. Is there any alternative solution?

답변 (4개)

Walter Roberson
Walter Roberson 2022년 10월 28일

0 개 추천

https://www.mathworks.com/help/symbolic/compute-z-transforms-and-inverse-z-transforms.html
You appear to have a recurrence relationship. Those are potentially solvable with ztrans.
John D'Errico
John D'Errico 2022년 10월 28일
편집: John D'Errico 2022년 10월 28일

0 개 추천

You have this basic first order linear recurrence relation:
E(n+1,x) = 2/x + 4*E(n,x)
Where E(1,x) = 0 is a given, but also for some chosen value of N, you will then also want E(N,x) = 0.
Of course, the recurrence relation as shown has a trivial solution. 2/x is a effectively a constant with respect to n. Can we solve this problem using z-transforms? That seems the simplest way. The general solution would be to solve for E(n,x), by taking the z-transform of your recurrence, solving using the inverse z-transform, then set the nth term to zero, and solve for x.

댓글 수: 2

Walter Roberson
Walter Roberson 2022년 10월 28일
This particular case can be resolved without ztrans by constructing a numerator (to be divided by x) in base 4. The sequence goes 0, 2, 22, 222, 2222 and so on. At the end, the base 4 numerator divided by x, has to equal 0 because the E(n+1,1) is said to be 0. The only solutions are x being ±infinity
John D'Errico
John D'Errico 2022년 10월 28일
편집: John D'Errico 2022년 10월 28일
And why I did not actually write out a solution to this specific problem, because it was clearly not the problem of interest. I'm not even positive the question is about a simple linear one term recurrence. But a z-transform is probably the solution method to use, as we both suggrested.

댓글을 달려면 로그인하십시오.

Torsten
Torsten 2022년 10월 28일
편집: Torsten 2022년 10월 28일

0 개 추천

Linear system of equations in E(1,1),...,E(n+1) and 2/x.
Setup for n = 4 (solution variables are E(1,1),E(2,1),E(3,1), E(4,1), E(5,1) and 2/x in this order):
A = [1 0 0 0 0 0;-4 1 0 0 0 -1;0 -4 1 0 0 -1; 0 0 -4 1 0 -1; 0 0 0 -4 1 -1; 0 0 0 0 1 0];
b = [0 0 0 0 0 0].';
rank(A)
ans = 6
sol = A\b
sol = 6×1
0 0 0 0 0 0
x = 2/sol(6)
x = -Inf
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2022년 10월 28일
편집: Pooneh Shah Malekpoor 2022년 10월 28일

0 개 추천

Thanks for yur response. Ok, let me explain in detail. In equation below, E(1,1)=0, E(2,1) has E(1,1) inside it, in the same line E(3,1) has E(2,1).... till E(n,1) has E(n-1,1) and finally E(n+1,1) which is equal to zero and from E(n+1,1)=0 , x can be found.
how to solve this equation as fast as possible?
E(i,1)=((CC(i-1)'.*l(i-1)./x)+(((tan(phii(i-1)*pi/180)')./x)*((rho*9.81*A(i-1)*(cos(beta(i-1))))+(-rho*9.81*KH*A(i-1)*(sin(beta(i-1))))+(E(i-1)*(sin(beta(i-1)-(L*j(i-1)))))))-(rho*9.81*A(i-1)*(sin(beta(i-1))))-(KH*rho*9.81*A(i-1)*cos(beta(i-1)))+(E(i-1)*(cos(beta(i-1)-(L*j(i-1))))))./(cos(beta(i-1)-(L*j(i)))+((sin(beta(i-1)-(L*j(i))))*(tan(phii(i-1)*pi/180)')./x));
%
P.S. CC, l, phii, rho, A, beta, KH, are all known values

댓글 수: 9

Torsten
Torsten 2022년 10월 28일
편집: Torsten 2022년 10월 28일
How large is n in your computations ?
And all other arrays/constants except for E and x are known ?
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2022년 10월 28일
편집: Pooneh Shah Malekpoor 2022년 10월 28일
It may have 200 arrays. Other contants have the same size az n
For the time being, I am using n=10 as this is a trial one and I want to debug the code
Just rho=18. Except for x, everything is known (E only contains x as the unknown)
Torsten
Torsten 2022년 10월 28일
편집: Torsten 2022년 10월 28일
The sizes of the arrays CC, phii, A, beta, j and E are 200x1 or do you have 200 arrays ?
And where do the equations stem from ? Maybe from the discretization of a boundary-value problem ?
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2022년 10월 28일
편집: Pooneh Shah Malekpoor 2022년 10월 28일
they are all (200*1) double arrays
These double arrays are the results from another function that I previously defined in the code and imported here
Torsten
Torsten 2022년 10월 28일
편집: Torsten 2022년 10월 28일
For a given value of x, compute E1,...,En and return resid_(N+1) to a nonlinear solver, e.g. fzero or fsolve.
Here, resid_(N+1) is the residual of the (N+1)th equation where you want E(n+1) = 0.
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2022년 10월 28일
could you explain with a simple example?
Torsten
Torsten 2022년 10월 28일
편집: Torsten 2022년 10월 28일
x1 = 4;
sol1 = fzero(@fun,x1)
sol1 = 3.1724
fun(sol1)
ans = -4.9058e-15
x2 = -2;
sol2 = fzero(@fun,x2)
sol2 = -2.7814
fun(sol2)
ans = 7.6050e-15
x = -10:0.01:10;
plot(x,fun(x),x1,sol1,'o',x2,sol2,'o')
%E(1) = 0;
%E(2) = 4*E(1) + 2/x;
%E(3) = 4*E(2) + 3/x;
%E(4) = 4*E(3) - 5*x + 2;
%E(5) = 4*E(4) + sin(x)
%E(5) = 0;
function res = fun(x)
res = 0;
res = 4*res + 2./x;
res = 4*res + 3./x;
res = 4*res - 5*x + 2;
res = 4*res + sin(x);
end
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2022년 10월 31일
thanks, whats the fun here?
Torsten
Torsten 2022년 10월 31일
Given x, the function "fun" calculates the resulting value for E(5).
"fzero" tries to adjust x so that E(5) becomes 0.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

질문:

2022년 10월 28일

댓글:

2022년 10월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by