How to write equations ?

Hi,
I want to write this equation:
and also to to write the all element of that equation.
The equation is:
fullsimplify[series[sqrt(1+X), {x,0,3}]].
The element should be as:
1+x/2-x^2/8+x^3/16+O[x]^4/
Can someone guide how to write it in MATLAB code?
Thanks,
Ron

 Risposta accettata

Walter Roberson
Walter Roberson il 23 Dic 2017
syms x
simplify(series(sqrt(1+x), x, 0, 'Order', 4))

5 Commenti

Ron Rivva
Ron Rivva il 23 Dic 2017
Modificato: Walter Roberson il 23 Dic 2017
Hi,
Thanks.
After applying your answer, an error occur:
>> equation
Error using sym/subsindex (line 769)
Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic variables and
the body of the function is a SYM expression. When indexing, the input must be numeric, logical, or ':'.
Error in sym/subsref (line 814)
R_tilde = builtin('subsref',L_tilde,Idx);
Error in equation (line 2)
simplify(series(sqrt(1+x), x, 0, 'Order', 4))
Can you figure why ?
I suspect you had defined x as numeric not with the
syms x
that I showed.
>> syms x
simplify(series(sqrt(1+x), x, 0, 'Order', 4))
ans =
x^3/16 - x^2/8 + x/2 + 1
Ron Rivva
Ron Rivva il 24 Dic 2017
Hi, Thank you Walter for your response. Where do I need to define x ? in the line code? Can you guide how to write it ?
Ron Rivva
Ron Rivva il 24 Dic 2017
Got it.
Thanks Walter.
x is defined by
syms x
which is equivalent to
x = sym('x');
If you want to evaluate the expression with particular numeric versions of x, then use subs()
syms x
s = simplify(series(sqrt(1+x), x, 0, 'Order', 4));
xn = linspace(-10,10);
sn = double( subs(s, x, xn) );

Accedi per commentare.

Più risposte (1)

Image Analyst
Image Analyst il 23 Dic 2017
Modificato: Image Analyst il 23 Dic 2017
What does "O[]^4/" mean???
Anyway, start here:
for x = 0 : 3
s(x+1) = 1+x/2-x^2/8+x^3/16
end
plot(s, 'b*-', 'LineWidth', 2);
grid on;
xlabel('x', 'FontSize', 20);
ylabel('s', 'FontSize', 20);
Adapt as needed. Like maybe after you have s, do
series = sqrt(1+s)
I didn't use X because we've already used lower case x and using both upper case X and lower case X would be confusing.

3 Commenti

Ron Rivva
Ron Rivva il 23 Dic 2017
Modificato: Ron Rivva il 23 Dic 2017
hi, I made a correction to my question. Can you check it again ?
Thanks
Image Analyst
Image Analyst il 23 Dic 2017
Modificato: Image Analyst il 23 Dic 2017
OK, so now what does "O[x]^4/" mean? Is that zero times x to the fourth power divided by (some missing denominator)?
When you say "The element should be as:" do you mean that EACH element is that, so plus in 0 for x for the first term, plug in 1 for x for the second term, and so on? OR do you mean that that is is the first 5 terms, so 1 for was x=0, the second term is x/2 = 1/2 when x=1, and the third term is x^2/8 = 2^2/8 = 4/8 = 1/2 when x is 2, and so on?
Actually, can you just post a photo of the series because I'm not sure you can describe it unambiguously and I'd like to just see the standard mathematical notation?
Walter Roberson
Walter Roberson il 23 Dic 2017
Modificato: Image Analyst il 25 Dic 2017
The image that is shown in the original Question
is Mathematica code. The O[x]^4 is the Mathematica way of indicating that the series has been truncated at order 4 and that you need to add to the series some value that is proportional to x^4

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by