🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Symbolic function

User: "Ivan_22202"
Altair Community Member
Updated by Ivan_22202

Good day,

 

I'm new to Compose and i have some questions, i hope u can help me out. 

 

What is the equivalence for syms function (in Matlab) in Altair Compose? And how can I derivate symbolically in this software?

 

I'm testing this software and trying to get used to it, so i'm programming a simple Newton-Raphson method, this is the way i did it with matlab:


syms x 
fx=input('Enter the function: ')
dfx=diff(fx);
E=1; e=0.0001; i=1;
Ai=zeros(3,1); Axr=zeros(3,1); AE=zeros(3,1);
xo=input('Initial value:  ');
while E>e
    fxp=subs(fx,xo);
    dfxp=subs(dfx,xo);
    xr=xo-fxp/dfxp;
    E=abs((xr-xo)/xr);
    xo=xr;
    Ai(i)=i; Axr(i)=xr; AE(i)=E;
    i=i+1;
end
Res=[Ai Axr AE]

 

and here it is the way i did it with compose:

 

f=@(x) exp(-x)-x;   
df=@(x) -exp(-x)-1;
E=1; e=0.0001; i=1;
Ai=zeros(3,1); Ar=Ai; AE=Ai;
%xo=0;
xo=input('Initial value: ')
while E>e
    fxp=f(xo);
    dfxp=df(xo);
    xr=xo-fxp/dfxp;
    E=abs((xr-xo)/xr);
    xo=xr;
    Ai(i)=i; Ar(i)=xr; AE(i)=E;
    i=i+1;
end
Res=[Ai Ar AE]

 

The questions are as stated above, because I want to differentiate any simple function I give as input.

 

btw, sorry for broken english.

Find more posts tagged with

Sort by:
1 - 2 of 21
    User: "L Moretti"
    New Altair Community Member
    Updated by L Moretti

    Hi Ivan,

     

    Unfortunately oml language doesn't support yet symbolic math.

     

    You can try to leverage Python-bridges provided by Compose though.

     

    Cheers,

     

    Lorenzo

    User: "Ivan_22202"
    Altair Community Member
    OP
    Updated by Ivan_22202

    Oh, I understand.

     

    Thank you so much for the information, I'll look into this new option you mentioned.