symbolic basic calculus help

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

symbolic basic calculus help

Jimmie713
clear all
clc
% Data
syms t
v=((1\(60^2))+0.8*t)^(-0.5);
T0=0;
T1=4;
S0=0;
%Velocity
vT1=((1\(60^2))+0.8*T1)^(-0.5);
% Position
s=int(v, T0,T1);
% Acceleration
a=diff(v,t);
t=T1;
a=eval(a);
% Display results
vT1
s
a
% End

On octave it gives me a passing floating point error.
In matlab it gives me the wrong value.  What the fuck am I doing wrong?



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: symbolic basic calculus help

Thomas D. Dean-2
Please punch ypur computer and then yourself.  Then, go somewhere and
learn maanners.


Reply | Threaded
Open this post in threaded view
|

Re: symbolic basic calculus help

Shadders
In reply to this post by Jimmie713
Hi,

I have not used the symbolic package but the warnings i get are that
passing floating point values to the symbolic process is a bad idea :

OctSymPy: Communication established.  SymPy v1.1.1.
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
     double_to_sym_heuristic at line 50 column 7
     sym at line 373 column 13
     mtimes at line 65 column 5
     /home/richard/DSP/2018 09 05 Octave issue bug forum.m at line 5
column 3
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
     double_to_sym_heuristic at line 50 column 7
     sym at line 373 column 13
     mpower at line 76 column 5
     /home/richard/DSP/2018 09 05 Octave issue bug forum.m at line 5
column 3
error: wrong type argument 'class'
error: eval: expecting std::string argument
error: parse error

As such, is there a way of running the process and not use floating
point values ?

Also, the class error indicates that using floating points (numerical
calculations) are not supported.

Regards,

Richard.


On 05/09/18 18:11, Jimmie713 wrote:

> clear all
> clc
> % Data
> syms t
> v=((1\(60^2))+0.8*t)^(-0.5);
> T0=0;
> T1=4;
> S0=0;
> %Velocity
> vT1=((1\(60^2))+0.8*T1)^(-0.5);
> % Position
> s=int(v, T0,T1);
> % Acceleration
> a=diff(v,t);
> t=T1;
> a=eval(a);
> % Display results
> vT1
> s
> a
> % End
>
> On octave it gives me a passing floating point error.
> In matlab it gives me the wrong value.  What the fuck am I doing wrong?
>
>
>
> --
> Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: symbolic basic calculus help

Andreas Weber-6
Am 05.09.2018 um 20:03 schrieb Richard Shadbolt:
> I have not used the symbolic package but the warnings i get are that
> passing floating point values to the symbolic process is a bad idea :

Using floating point values is not a bad idea per se but you have to
keep in mind that

0.1 == 1/10

can be not true, or also

0.1 + 0.2 == 0.3

"help sym" has a good explanation.

-- Andy


Reply | Threaded
Open this post in threaded view
|

Re: symbolic basic calculus help

Anton Dereventsov
In reply to this post by Jimmie713
Octave does not like doing symbolic arithmetic with non-integer numbers. To
bypass that, use 'vpa' command (type 'help vpa' in octave command window for
more info). Basically, you should define v as follows:
v = (vpa(1/(60^2)) + vpa(0.8)*t) ^ vpa(-0.5);

Note also that I wrote 1/(60^2) and not 1\(60^2) since \ is the left
division so that's probably not what you wanted.

Additionally, if you want to evaluate acceleration a at a point, say, T1 you
should use 'subs' command and not 'eval':
subs(a,T1);

Hope that helps,
Anton



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html