Double Star calculation - double

I am a newbie in Python and I request help! Use Python to calculate this:
(((1+2)*3)/4)5
How do you calculate this in Python using double star operator? It shows errors when I try it this way:
print(((1+2)*3)/4)**5

As per my understnding on your code you should use the statement print((((1+2)*3)/4)**5) to calculate your operation. If you use * it means multiply or if you use ** it means to the power of.

Related

How to use series in the GR-tensor package?

How can I use the series command for a specific quantity to find it up to a certain order of magnitude?
Is it possible to have an expanded series of a tensor in GR-tensor package?
Yes. You can apply series expansion to an object using the grmap() command.
The help for this function gives an example:
e.g. to do a taylor series expansion about r=a to second order
grmap(R(dn,dn,dn,dn), taylor, 'x',r=a,2);
See the help for grmap: ?grmap

How to Matlab code combining to make it easier

Hello I wanted to reshape this code to make it easier.
sins=1/3*(sind(50)+sind(300)+sind(340));
coses=1/3*(cosd(50)+cosd(300)+cosd(340));
result=atand(sins/coses);
it will be more input like 50,300,340... so I wanted to like this
a=[50 300 340];
sins=1/3*(sind(a));
coses=1/3*(cosd(b));
result=atand(sins/coses);
but it doesnt work.
How can I make it ?
Thanks in advance.
In your first example, you sum all three values returned by sind, in your second code you don't sum them. Inputting a matrix, sind (like most mathematical functions in MATLAB) returns a matrix of the same size, applying the function to each element. Use sum to get the sum of a vector.
sins=1/3*(sum(sind(a)));

'exact' numerical value after numerical optimization MATLAB

I'm having the following issue with my code. I've been trying to use some other posts that I found on line, like this one. But they didn't what I'm looking for.
My code uses a MATLAB Exchange function which optimize a numerical value that is important to be with 32 digits after the dot such as
0.59329669191989231613604260928696
The optimization function can be found here and it is called fminsearchbnd
The optimization function calculate this and store the value in a variable that I use all over my code. In order not to perform the optimization everytime I want to store the variable (I tried either on a *.mat and on a label in the string form.
But when I retrieve it, MATLAB transforms it in a double precision variable 'cutting' all the numbers after the 14th. However I need all of them because they are important!
Is it possible to read a number like that w/o using vpa() because with a symbolic value I can't do anything.
Any help is really appreciated.
Thanks
EDIT:
fminsearchbnd gives me this class(bb) -> double and when I want to see it on the workspace it is 0.586675392365899. But when I set formatSpec = '%.32f\n'; because I want to see all the numbers that the optimization gives me, typing set(editLabel,'String',num2str(bb,formatSpec))
You're trying to store/use a number that cannot be represented exactly in an IEEE754 64-bit double-precision floating point number.
I'm not sure how you got that number without using vpa() in the first place, since 64-bit double is Matlab's maximum of precision...
You could use the multiple precision toolbox by Ben Barrowes, or HPF by John d'Errico, also from the FEX. You'll have to convert/construct to/from string if you want to store/load it to/from file.
But I have to agree with John's comment there:
The fact is, most of the time, if you can't do it with a double, you
are doing something wrong
so...why exactly are those 32-or-more digits important?

Problem in getting 100 th power of any particluar value

Suppose i need 100 power of say 1.5 then how can i get that .
Any formula how to get this in iphone .For example i need the value of 1.5^100 , then how can i get that in objective c.
Use the pow() function from math.h:
NSLog(#"%.f", pow(1.5,100) );
If you need any other math related operations, I would check out:
Objective-C Math functions

How to convert a z score to a percentage in Perl

Seems like in Perl this should be easy or a module, but I have not found an easy answer yet. I have a calculated z normal score and the mean, but have not found an easy method to calculate the percentage. The solutions I have found are for looking it up using a statistics table, but it seems like something that common would have a module or something easy. (ie a z-score of -3 is -3 sigma and has a percentage of 0.1%). I don't want to have to build a table in perl and then interpolate if I don't need to. Anyone know?
I'm not 100% sure since the only description you gave is "the percentage", but I think the function you need is the cumulative probability function for the normal function. You can get this from the module Math::CDF.
use Math::CDF;
my $prob = Math::CDF::pnorm(-3);
printf "%.1f%%\n", $prob * 100; # Prints 0.1%