Hi guys ,(adsbygoogle = window.adsbygoogle || []).push({});

I'm a little new with Mathematica and I'm trying to write down some functions.

the first one is writing a functions that square the elements in a vector ,recursively,

using patterns .

so , I tried this one :

x = Range[1, 10];

sq[0,list_]=list^2;

sq[sum_,list_] := Sum[sum*sq[sum, list[n - 1]], _list]

but it isn't working . what's the problem ?

2. The second function is writing a function that sorts a list of numbers , by checking each time two numbers that are adjacent .

if I write this :sort[list_] :=

how can I tell mathematica that I want to use an actual list of numbers ? can I saylist?

thank you

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Mathematica functions

Loading...

Similar Threads - Mathematica functions | Date |
---|---|

Mathematica Cannot do the integral of the Hyper-geometric function? | Mar 11, 2018 |

Mathematica Cannot Plot This Function in Mathematica | Feb 26, 2018 |

Mathematica How to append functions to a list of functions? | Oct 8, 2017 |

Is the integral for current correct? | Jul 7, 2017 |

Trying to define a integrating function in Mathematica | Jun 11, 2016 |

**Physics Forums - The Fusion of Science and Community**