Reputation: 23
how to write a formula like
v_r (t)=∑_(n=0)^(N-1)▒〖A_r (L_2-L_1 ) e^j(ω_c t-4π/λ (R+υt+L_(1+L_2 )/2 cos〖(θ)sin(ω_r t+2πn/N)))〗 ┤) sinc(4π/λ-L_(2-L_1 )/2 cos(θ) sin(ω_r t+2πn/N))〗
in c#?
Upvotes: 1
Views: 4681
Reputation: 882426
Well, first you have to figure out what all those symbols mean. I see the sigma which usually indicates sum-of, with ∑_(n=0)^(N-1)
probably translating to:
N-1
∑
n=0
This generally means the sum of the following expression where n
varies from 0
to N-1
. So I gather you'd need a loop there.
The expression to be calculated within that loop consists of a lof of trigonometric-type functions involving π
, θ
, sin
and cos
, and the little known sinc
which I assume is a typo :-)
The bottom line is that you need to understand the current expression before you can think about converting it to another form like a C# program. Short of knowing where it came from, or a little bit of context, we probably can't help you that much though there's always a possibility that we have a savant/genius here that will recognise that formula off the top of their head.
Upvotes: 0
Reputation: 839
You have to convert the formula to something the compiler recognizes.
To it's equivalent using the a combination of basic algebra and the Math class like so:
p = rho*R*T + (B_0*R*T-A_0-((C_0) / (T*T))+((E_0) / (Math.Pow(T, 4))))*rho*rho +
(b*R*T-a-((d) / (T)))*Math.Pow(rho, 3) +
alpha*(a+((d) / (t)))*Math.Pow(rho, 6) +
((c*Math.Pow(rho, 3)) / (T*T))*(1+gamma*rho*rho)*Math.Exp(-gamma*rho*rho);
Example taken from: Converting Math Equations in C#
Upvotes: 2