1
$\begingroup$

If I have the following code:

 temperature[q_] := 
      RSolveValue[{b[n] == ((b[n - 1] + 273.15) - q*time) - 273.15, 
        b[0] == 90}, b, n];
temperature[0.1][Range[0, 100]];

where "time" is a number, say 5, and the code generates a list of 100 values, starting with the value 90. How can I make the code such as "time" can be a list of numbers (e.g. time={2,3,5,8,9,10...etc.}) and q gets multiply each time by each element of time?. I am not very familiar with RSolveValue and how or if it is possible to do this. Is there a code or function that will give the same answer but allowing time to be a list where each element can be multiplied by q?

PS:This question is an extension of another question asked here: General question about programing

$\endgroup$
  • $\begingroup$ Table[{time, temperature[0.1][Range[0, 100]]}, {time, {2, 3, 5, 8, 9, 10}}] $\endgroup$ – Bob Hanlon Apr 29 at 0:36
  • $\begingroup$ Hi Bob, thank you very much. Unfortunately, this does not work. It multiplies the whole expresion of temperature[0.1][Range[0, 100]] by time. time in this case is inside and has to multiply q only and not the whole expression. $\endgroup$ – John Apr 29 at 0:59
  • $\begingroup$ Look at a smaller sample say temperature[0.1][Range[0, 5]] and Table[{time, temperature[0.1][Range[0, 5]]}, {time, {2, 3, 5}}] and you will be able to more readily see that for each line, time is evaluated for the corresponding value from the list of time values. $\endgroup$ – Bob Hanlon Apr 29 at 1:13
  • $\begingroup$ If you want the values transposed, use Transpose@ Table[temperature[0.1][Range[0, 100]], {time, {2, 3, 5, 8, 9, 10}}]; $\endgroup$ – Bob Hanlon Apr 29 at 1:22
  • $\begingroup$ Hi Bob! This does a similar job of what I need but not exactly. What this does is that it applies the first element of time to the entire expression and then the second element of time to the entire expression and so on. What I need is to multiply the first term of the entire expression by the first element of time and then the second term of the entire expression by second element of time and so on. I hope this makes more clear what I want. I appreciate in advanced your help $\endgroup$ – John Apr 29 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.